Arnab Chakraborty has Published 4452 Articles

Check if sums of i-th row and i-th column are same in matrix in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Jan-2021 06:22:35

175 Views

Suppose we have a 2D matrix. We have to check whether the sum of i-th row is same as the sum of i-th column or not.So, if the input is like23451064214671567then the output will be True, as the sum of first row and column is (2 + 3 + 4 ... Read More

Check if sum of divisors of two numbers are same in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Jan-2021 06:21:13

234 Views

Suppose we have two numbers p and q. We have to check whether the sum of all divisors of these tow numbers are same or not.So, if the input is like p = 559, q = 703, then the output will be True the divisors of 559 is 1, 13, ... Read More

Check if suffix and prefix of a string are palindromes in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Jan-2021 06:20:34

261 Views

Suppose we have a string s, we have to check whether the string palindromes as its prefix and suffix substrings or not.So, if the input is like s = "levelishighforracecar", then the output will be True as there are palindrome prefix and suffix: "level" and "racecar" respectively.To solve this, we ... Read More

Check if subarray with given product exists in an array in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Jan-2021 06:18:42

454 Views

Suppose we have an array called nums and this contains positive and negative numbers. We have another value k. We have to check whether any subarray whose product is k is present in the array or not.So, if the input is like nums = [-2, -1, 1, 3, 5, 8], ... Read More

Check if strings are rotations of each other or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Jan-2021 06:17:37

436 Views

Suppose we have two strings s and t, we have to check whether t is a rotation of s or not.So, if the input is like s = "hello", t = "llohe", then the output will be True.To solve this, we will follow these steps −if size of s is ... Read More

Check if string follows order of characters defined by a pattern or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Jan-2021 06:16:58

517 Views

Suppose we have a string s and another string t as pattern, we have to check whether characters in s follows the same order as determined by characters present in t. Here we have no duplicate characters in the pattern.So, if the input is like s = "hello world" t ... Read More

Check if right triangle possible from given area and hypotenuse in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Jan-2021 06:15:15

164 Views

Suppose we have the hypotenuse and area of a right angle triangle, we have to find the base and height of this triangle. If it is not possible return False.So, if the input is like hypo = 10, area = 24, then the output will be (6, 8).To solve this, ... Read More

Check if reversing a sub array make the array sorted in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Jan-2021 06:13:40

219 Views

Suppose we have an array called nums with unique elements. We have to check whether the array will be sorted or not after reversing one sub-array of it. If the array is already sorted, then also return true.So, if the input is like nums = [4, 6, 27, 25, 15, ... Read More

Rotate Matrix in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 05-Jan-2021 07:04:02

4K+ Views

Suppose we have one n x n 2D matrix. We have to rotate this matrix 90 degrees clockwise. So if the matrix is like-157963213Then the output will be291165337To solve this, we will follow these steps −Consider temp_mat = [], col := length of matrix – 1for col in range 0 ... Read More

Check if each internal node of a BST has exactly one child in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Dec-2020 13:52:26

246 Views

Suppose we have the preorder traversal of a binary search tree (BST). We have to check whether each internal node has only one child or not.So, if the input is like preorder = [22, 12, 13, 15, 14], then the output will be True as BST is like −To solve ... Read More

Advertisements