Arnab Chakraborty has Published 4452 Articles

Check if an array of 1s and 2s can be divided into 2 parts with equal sum in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Dec-2020 12:46:58

121 Views

Suppose we have an array nums which only stores 1 and 2 in it. We have to check whether the array can be divided into two different parts such that sum of elements in each part is same.So, if the input is like nums = [1, 1, 2, 2, 2], ... Read More

Check if an array is stack sortable in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Dec-2020 12:45:27

207 Views

Suppose we have an array nums of unique elements from 1 through n. We have to check whether it is stack-sortable or not. An array is stack sortable when it can be stored in some other array using a temporary stack.To solve this, we can use any of these operations ... Read More

Check if an array contains all elements of a given range in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Dec-2020 12:41:31

1K+ Views

Suppose we have an array called nums. We also have two numbers x and y defining a range [x, y]. We have to check whether the array contains all elements in the given range or not.So, if the input is like nums = [5, 8, 9, 6, 3, 2, 4] ... Read More

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

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Dec-2020 12:39:36

147 Views

Suppose we have an array of numbers and have another number k, we have to check whether given array can be divided into pairs such that the sum of every pair is divisible by k or not.So, if the input is like arr = [5, 15, 6, 9] k = ... Read More

Check if all the 1s in a binary string are equidistant or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Dec-2020 12:36:14

86 Views

Suppose we have a binary string str, we have to check whether all of the 1s in the string are equidistant or not. In other words, the distance between every two 1s is same. And the string contains at least two 1s.So, if the input is like s = "100001000010000", ... Read More

Check if all sub-numbers have distinct Digit product in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Dec-2020 12:34:56

145 Views

Suppose we have a number n, we have to check whether all sub-numbers of this number have unique digit product or not. As we know, n digit number has n*(n+1)/2 sub-numbers. For example, the sub-numbers of 135 are 1, 3, 5, 13, 35, 135. And the digit product of a ... Read More

Check if all people can vote on two machines in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Dec-2020 12:33:20

57 Views

Suppose we have a number n denotes n people and there are two identical voting machines. We also have an array called time of size n such that time[i] represents total time spent by i-th person to vote on any machine. At one time instant, only one person can be ... Read More

Check if all occurrences of a character appear together in Python

Arnab Chakraborty

Arnab Chakraborty

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

251 Views

Suppose we have a string s and another character c, we have to check whether all occurrences of c appear together in s or not. If the character c is not present in s then also return true.So, if the input is like s = "bbbbaaaaaaaccddd", c = 'a', then ... Read More

Check if all enemies are killed with bombs placed in a matrix in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Dec-2020 13:46:49

109 Views

Suppose we have a matrix mat. There are few different values as follows The cells of matrix can hold any of these 3 characters0 for empty area.1 for bomb.2 for Enemies.Now bomb can blast in only horizontal and vertical directions from one end to another. We have to check whether ... Read More

Check if all elements of the array are palindrome or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Dec-2020 13:45:18

2K+ Views

Suppose we have a list of numbers nums. We have to check whether the list is palindrome or not.So, if the input is like nums = [10, 12, 15, 12, 10], then the output will be True.To solve this, we will follow these steps −n := size of numsreset is_palindromei := 0while i

Advertisements