Arnab Chakraborty has Published 4293 Articles

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

Arnab Chakraborty

Arnab Chakraborty

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

637 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

801 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

658 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

251 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

357 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

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

301 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

Check if difference of areas of two squares is prime in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Dec-2020 13:50:47

269 Views

Suppose we have two numbers x and y. We have to check whether difference of their areas is prime or not.So, if the input is like x = 7, y = 6, then the output will be True as the difference of their square is 49 - 36 = 13 ... Read More

Check if Decimal representation of an Octal number is divisible by 7 in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Dec-2020 13:48:54

199 Views

Suppose we have one octal number. We have to check whether the decimal representation of the given octal number is divisible by 7 or not.So, if the input is like n = 61, then the output will be True as the decimal representation of 61 is 6*8 + 1 = ... Read More

Check if count of divisors is even or odd in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Dec-2020 13:47:18

832 Views

Suppose we have a number n, we have to find its total number of divisors are even or odd.So, if the input is like n = 75, then the output will be Even, as the divisors are [1, 3, 5, 15, 25, 75].To solve this we shall follow one simple ... Read More

Check if concatenation of two strings is balanced or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Dec-2020 13:45:41

368 Views

Suppose we have two bracket sequences s and t with only these characters '(' and ')'. We have to check whether the concatenated string of s and t is balanced or not. The concatenation can be done by s | t or t | s.So, if the input is like ... Read More

Advertisements