Yaswanth Varma

Yaswanth Varma

307 Articles Published

Articles by Yaswanth Varma

Page 23 of 31

Check if array can be sorted with one swap in Python

Yaswanth Varma
Yaswanth Varma
Updated on 08-Aug-2025 404 Views

Sorting is a task used to organize the numbers in increasing order. Usually, we use the sorting algorithms to do this, but in most cases, the array is almost sorted, with two or three numbers in the wrong position. In such scenarios, instead of sorting the entire array, we can check if swapping just one pair of elements will make the entire array sorted. Checking if Array can be Sorted with One Swap The given task is to check if an array can be sorted with one swap in Python. i.e., given an array with distinct integers, we need ...

Read More

Check if any square (with one colored cell) can be divided into two equal parts in Python

Yaswanth Varma
Yaswanth Varma
Updated on 08-Aug-2025 258 Views

Dividing a Square into two Equal Parts In this article, we are given a square of size n*n with exactly one cell coloured. The task is to determine whether this square can be divided into two equal splits by making a single straight cut along the square, ensuring that the coloured cell lies entirely within one of the splits. Two equal splits here indicate that both parts must contain the same number of cells, which is possible if the square side length is even. In this article we are not only checking whether the split is possible but also whether the ...

Read More

Check if any permutation of a number is divisible by 3 and is Palindromic in Python

Yaswanth Varma
Yaswanth Varma
Updated on 07-Aug-2025 281 Views

Divisibility by 3 The given task is to determine whether the permutation of the digits of the given number can form a new number that satisfies two conditions: it must be divisible by 3 and also be a palindromic number. A number is said to be palindromic if the reversal of a number is the same as the original, such as 121 or 1331, and a number is said to be divisible by 3 if the sum of its digits is divisible by 3. For example, let's look at the following scenarios:  Scenario 1 Input: 121 Output: False Explanation: ...

Read More

Check if any permutation of a large number is divisible by 8 in Python

Yaswanth Varma
Yaswanth Varma
Updated on 07-Aug-2025 1K+ Views

Divisibility By 8 According to the divisibility rule of 8, if the last three digits of a number are divisible by 8, then the entire number is divisible by 8. While this is easy to check for small numbers, when it comes to large numbers, generating all the possible permutations is impractical for large inputs. However, we can solve this problem by taking advantage of the divisibility rule and limiting our check to possible combinations of three digits. Scenario 1 Input: "61" Output: Yes Explanation: For the given input, the possible permutations of the digits are 16 and 61. Among ...

Read More

Check if any large number is divisible by 19 or not in Python

Yaswanth Varma
Yaswanth Varma
Updated on 07-Aug-2025 481 Views

In mathematics, Divisibility helps us to determine whether a number can be divided by another without leaving a remainder. For example, 6 is divisible by 2 because 6/2 = 3 with no remainder. In this article, we are going to learn how to check if any large number is divisible by 19 or not in Python. Checking if any Large Number is Divisible by 19 Checking for the divisibility with small numbers can be easily handled by using the standard arithmetic operations. While dealing with the large numbers (contains 20, 30 or even 100 digits), the programming languages may run ...

Read More

Check if any interval completely overlaps the other in Python

Yaswanth Varma
Yaswanth Varma
Updated on 07-Aug-2025 2K+ Views

In many programming problems, Intervals are used to represent ranges such as time periods, numeric spans, etc. An interval is typically represented as a pair of numbers (start, end) where start

Read More

Check if any anagram of a string is palindrome or not in Python

Yaswanth Varma
Yaswanth Varma
Updated on 30-Jul-2025 624 Views

Check if any Anagram of a String is Palindrome An anagram is a rearrangement of the characters of a word or a phrase to generate a new word, using all the original characters exactly once. For example, thing and night are anagrams of each other. While palindrome is a word or phrase that reads the same forward and backward, like madam, racecar. In this article, we are going to check if any anagram of a string is a palindrome or not, i.e., we are not just checking whether the given string itself is a palindrome, but also whether it can ...

Read More

Check if an array represents Inorder of Binary Search tree or not in Python

Yaswanth Varma
Yaswanth Varma
Updated on 30-Jul-2025 652 Views

The Binary Search Tree (BST) is a widely used data structure that maintains the elements in a sorted hierarchical order. Each node in the BST follows the specific property: The values in the left subtree are always less than the values of the current node. The values in the right subtree are always greater than the node. In this article, we are going to learn about checking if an array represents the inorder of a BST or not in Python. Checking for inorder of the BST Inorder traversal is the ...

Read More

Check if an array can be divided into pairs whose sum is divisible by k in Python

Yaswanth Varma
Yaswanth Varma
Updated on 30-Jul-2025 339 Views

Check if Array Can Be Divided into Pairs with Sum Divisible by K In this article, we are given an array of integers and a number k. The task is to determine whether it is possible to divide the entire array into pairs such that the sum of every pair is divisible by k. For example, if the given array of integers is [2, 4, 1, 3], and a value k = 5. The task is to form pairs (two elements at a time) from the array such that when you add each pair, the result is divisible by ...

Read More

Check if all rows of a matrix are circular rotations of each other in Python

Yaswanth Varma
Yaswanth Varma
Updated on 30-Jul-2025 266 Views

Matrices are used to represent and manipulate structured data (such as grids, patterns). While working with matrix manipulation, we may find scenarios where to determine whether all the rows in a given matrix are circular rotations of one another. Circular Rotation in a Matrix A circular rotation of a list (or array) is a transformation where elements are shifted to the left (or right), and the element at the end will be wrapped around to the beginning. For example, if the original row is [1, 2, 3], its circular rotations are: [2, 3, 1] (left-rotated ...

Read More
Showing 221–230 of 307 articles
« Prev 1 21 22 23 24 25 31 Next »
Advertisements