Arnab Chakraborty has Published 4293 Articles

Check if the characters of a given string are in alphabetical order in Python

Arnab Chakraborty

Arnab Chakraborty

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

1K+ Views

Suppose we have a string s. We have to check whether characters in s are in alphabetical order or not.So, if the input is like s = "mnnooop", then the output will be True.To solve this, we will follow these steps −char_arr := a new list from the characters present ... Read More

Check if the characters in a string form a Palindrome in O(1) extra space in Python

Arnab Chakraborty

Arnab Chakraborty

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

515 Views

Suppose we have a string s. This string can contain lowercase characters, other special characters and numbers. We have to check whether only the letters present in the string are palindromic or not. Here one constraint is that there we are not allowed to use extra space to solve this ... Read More

Check if the binary representation of a number has equal number of 0s and 1s in blocks in Python

Arnab Chakraborty

Arnab Chakraborty

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

257 Views

Suppose we have a number num, we have to check whether the binary representation of num has the same number of consecutive blocks of 0s and 1s. We have to keep in mind that 0 and a number with all 1s are not considered to have number of blocks of ... Read More

Check if the array is beautiful in Python

Arnab Chakraborty

Arnab Chakraborty

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

564 Views

Suppose we have an array nums of unique elements. We have to check whether these conditions satisfy or not:Elements will be in range 1 to n.The array must not be sorted in ascending order.So, if the input is like nums = [2, 6, 1, 5, 3, 4], then the output ... Read More

Check if the array has an element which is equal to sum of all the remaining elements in Python

Arnab Chakraborty

Arnab Chakraborty

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

364 Views

Suppose we have an array called nums we have to check whether the array contains an element whose value is same as sum of all other elements.So, if the input is like nums = [3, 2, 10, 4, 1], then the output will be True, 10 = (3+2+4+1).To solve this, ... Read More

Check if the array has an element which is equal to product of remaining elements in Python

Arnab Chakraborty

Arnab Chakraborty

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

154 Views

Suppose we have an array called nums we have to check whether the array contains an element whose value is same as product of all other elements.So, if the input is like nums = [3, 2, 24, 4, 1], then the output will be True, 24 = (3*2*4*1).To solve this, ... Read More

Check if the array can be sorted using swaps between given indices only in Python

Arnab Chakraborty

Arnab Chakraborty

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

182 Views

Suppose we have an array called nums with unique values from range [0, n – 1]. This array is unsorted. We also have another array of pairs where each pair contains indices where the elements of the array can be swapped. We can swap multiple number of times. We have ... Read More

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

228 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

298 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

346 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

Advertisements