Tip 1 : Be thorough with the concepts
Tip 2 : Practice coding questions daily
Tip 1: Be honest and do not lie on resume
Tip 2: Keep it short and precise
2 coding questions



1. Every train will depart on the same day and the departure time will always be greater than the arrival time. For example, A train with arrival time 2240 and departure time 1930 is not possible.
2. Time will be given in 24H format and colons will be omitted for convenience. For example, 9:05AM will be given as "905", or 9:10PM will be given as "2110".
3. Also, there will be no leading zeroes in the given times. For example, 12:10AM will be given as “10” and not as “0010”.
The problem can be solved using Dynamic Programming. Follow the steps below to solve the problem:
traverse the array and for every array index, i.e. ith fountain, find the leftmost fountain up to which the current fountain covers.
Then, find the rightmost fountain that the leftmost fountain obtained in the above step covers up to and update it in the dp[] array.
Initialize a variable cntFount to store the minimum number of fountains that need to be activated.
Now, traverse the dp[] array and keep activating the fountains from the left that covers maximum fountains currently on the right and increment cntFount by 1. Finally, print cntFount as the required answer.



'str' = abcad and 'k' = 2.
We can see that the substrings {ab, bc, ca, ad} are the only substrings with 2 distinct characters.
Therefore, the answer will be 4.
The idea is to traverse through all substrings. We fix a starting point, traverse through all substrings starting with the picked point, we keep incrementing frequencies of all characters. If all frequencies become k, we increment the result. If the count of any frequency becomes more than k, we break and change starting point.



If the given array is [1, 3, 2], then you need to return [3, -1, -1]. Because for 1, 3 is the next greater element, for 3 it does not have any greater number to its right, and similarly for 2.
We sort all elements, then for every element, traverse toward right until we find a greater element



You may assume that duplicates do not exist in the given traversals.
For the preorder sequence = [1, 2, 4, 7, 3] and the inorder sequence = [4, 2, 7, 1, 3], we get the following binary tree.

Even though I have already solved this question thrice before the interview, still I could not code it. Please keep in mind that even the simpler questions seem to be pretty difficult in the tense situation of the interview. However I told the approach for the question (Recursion + left-right pointers) and they wrapped the interview, as we were already out of time.
Puzzle solving
Ishita has 10 bags full of coins. Each bag contains 1000 coins. But one bag is full of forgeries, and she just can’t recall which one. She does know that genuine coins weigh 1 gram, but forgeries weigh 1.1 grams. To hide the fact that she can’t recall which bag contains forgeries, she needs your help. How can she identify the bag with the forgeries with just one weighing?

Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
What is recursion?