Arnab Chakraborty has Published 4452 Articles

Check if the frequency of all the digits in a number is same in Python

Arnab Chakraborty

Arnab Chakraborty

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

1K+ Views

Suppose we have a number num we have to check whether is balanced or not. A number is balanced when frequencies of all digits are same or not.So, if the input is like num = 562256, then the output will be True as frequency of each digit is 2.To solve ... Read More

Check if the first and last digit of the smallest number forms a prime in Python

Arnab Chakraborty

Arnab Chakraborty

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

162 Views

Suppose we have an array called digits that contains only digits. We have to find the minimum possible number from the given digits and then check whether the numbers by taking first and last digits of the generated number are prime or not. We will print the number itself and ... Read More

Check if the elements of stack are pairwise sorted in Python

Arnab Chakraborty

Arnab Chakraborty

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

223 Views

Suppose we have a stack of numbers; we have to check whether values in the stack are pairwise consecutive or not. These pairs can be increasing or decreasing. If the stack has an odd number of values, the top element is left out of a pair. And we should retain ... Read More

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

403 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

166 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

436 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

287 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

120 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

78 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

Advertisements