Arnab Chakraborty has Published 3734 Articles

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

254 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

309 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

259 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

195 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 pair with given sum in a Balanced BST in C++

Arnab Chakraborty

Arnab Chakraborty

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

173 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

163 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

407 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

187 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

Construct a Maximum Sum Linked List out of two Sorted Linked Lists having some Common nodes in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 27-Aug-2020 14:25:51

322 Views

Suppose we have two sorted linked lists, we have to make a linked list that consists of largest sum path from start node to end node. The final list may consist of nodes from both input lists.When we are creating the result list, we may switch to the other input ... Read More

Construct a linked list from 2D matrix in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 27-Aug-2020 14:20:57

1K+ Views

Suppose we have one matrix, we have to convert it to 2d linked list using recursive approach.The list will have the right and down pointer.So, if the input is like102030405060708090then the output will beTo solve this, we will follow these steps −Define a function make_2d_list(), this will take matrix mat, ... Read More

Advertisements