Given a number n, find the smallest number that has same set of digits as n and is greater than n. If x is the greatest possible number with its set of digits, then print
Find the kth number with prime factors 3, 5 and 7
Find the kth number with prime factors 3, 5 and 7
Design an algorithm such that we have to find the k th element in the array such that their only prime factors are 3,5
Print vertical sum of all the axis in the given binary tree
Print Vertical Sum of all the axis in the given binary Tree.
Most of times in written test , you will encounter this very good question.
given a binary tree.
(most of times a complete
N Petrol bunks or City arranged in circle. You have Fuel and distance between petrol bunks. Is it possible to find starting point so that we can travel all Petrol Bunks
Find the first circular tour that visits all petrol pumps
There are n petrol bunks arranged in circle. Each bunk is separated from the rest by a certain distance. You choose some mode of travel
robot standing at first cell of an M*N matrix. It can move only in two directions, right and down. In how many ways, it can reach to the last cell i.e. (M, N) Code it
Robot standing at first cell of an M*N matrix. It can move only in two directions, right and down. In how many ways, it can reach to the last cell i.e. (M, N) Code it.
Rectangular chocolate bar Create at least one piece which consists of exactly nTiles tiles
Rectangular chocolate bar Create at least one piece which consists of exactly nTiles tiles.
You have a rectangular chocolate bar that consists of width x height square tiles. You can split it into two rectangular … Read More
25 horses 5 tracks Find 3 fastest puzzle
Suppose you have 25 horses, and you want to pick the fastest 3 horses out of those 25. In each race, only 5 horses can run at the same time in a race because there
Printing Longest Common Subsequence
Printing Longest Common Subsequence
Given two sequences, print the longest subsequence present in both of them.
Examples:
LCS for input Sequences “ABCDGH” and “AEDFHR” is “ADH” of length 3.
LCS for input Sequences “AGGTAB” and
Given a string, find the first character which is non-repetitive
Given a string, find the first character which is non -repetitive i.e that character must not be present anywhere else in the string.
With two different solutions.
Eg : Input : teeterson Output : r,
flattens 2 D linked list to a single sorted link list
Write a function flatten() which flattens this linked list with each node down sorted link list to a single link list with all the elements in sorted order.
We have given Two methods in O(n^2)