Arnab Chakraborty has Published 4293 Articles

Find all distinct palindromic sub-strings of a given String in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Aug-2020 08:55:03

414 Views

Suppose we have a string with lowercase ASCII characters, we have to find all distinct continuous palindromic substrings of it.So, if the input is like "bddaaa", then the output will be [a, aa, aaa, b, d, dd]To solve this, we will follow these steps −m := a new mapn := ... Read More

Find a string such that every character is lexicographically greater than its immediate next character in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Aug-2020 08:46:39

221 Views

Suppose we have a number n; we have to check a lower case stringof length n+1 so that the character at any position should be lexicographically bigger than its immediate next character.So, if the input is like 15, then the output will be ponmlkjihgfedcba.To solve this, we will follow these ... Read More

Find a string in lexicographic order which is in between given two strings in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Aug-2020 08:43:02

274 Views

Suppose we have two strings S and T, we have to check whether a string of the same length which is lexicographically bigger than S and smaller than T. We have to return -1 if no such string is available. We have to keep in mind that S = S1S2… ... Read More

Find a sorted subsequence of size 3 in linear time in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Aug-2020 08:38:31

202 Views

Suppose we have an array with N numbers, we have to check whether the 3 elements such that b[i]< b[j] < b[k] and i < j < k in linear (O(n)) time. If there are multiple such triplets, then print any one of them.So, if the input is like [13, ... Read More

Find a positive number M such that gcd(N^M,N&M) is maximum in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Aug-2020 08:32:45

154 Views

Suppose we have a number N, we have to find a positive number M such that gcd(N^M, N&M) is as large as possible and m < n. We will also return the largest gcd thus obtained.So, if the input is like 20, then the output will be 31To solve this, ... Read More

Find a permutation that causes worst case of Merge Sort in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Aug-2020 08:25:54

149 Views

Suppose we have a set of elements; we have to find which permutation of these elements would result in worst case of Merge Sort? As we know asymptotically, merge sort always consumes O (n log n) time, but some cases need more comparisons and consumes more time. Here we have ... Read More

Find a pair with given sum in a Balanced BST in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Aug-2020 08:20:06

131 Views

Suppose we have a balanced binary search tree and a target sum, we have to define a method that checks whether it is a pair with sum equals to target sum, or not. In this case. We have to keep in mind that the Binary Search Tree is immutable.So, if ... Read More

Find a number which give minimum sum when XOR with every number of array of integer in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Aug-2020 08:12:07

121 Views

Suppose we have an array A, we have to find a number X such that (A[0] XOR X) + (A[1] XOR X) + … + A[n – 1] XOR X is as minimum as possible.So, if the input is like [3, 4, 5, 6, 7], then the output will be ... Read More

Find a non empty subset in an array of N integers such that sum of elements of subset is divisible by N in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Aug-2020 08:06:17

362 Views

Suppose we have an array of n numbers; we have to find a non-empty subset such that the sum of elements of the subset is divisible by n. So, we have to output any such subset with its size and the indices of elements in the original array when it ... Read More

Final state of the string after modification in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Aug-2020 08:05:57

151 Views

Suppose we have a string S. The length is n. These n boxes adjacent to each other, a character R at position i represents that i-th box is being pushed towards right. similarly, L at position i represents that i-th box is being pushed towards left, a dot '.' indicates ... Read More

Advertisements