Tip 1 : Practice Atleast 250 DS Questions
Tip 2 : maintain consistency while doing questions
Tip 3 : Do some projects
Tip 1 : Have some projects on resume.
Tip 2 : Do not put false things on resume.
The test consists of 20-30 MCQs and 3 coding questions



An array c is a subarray of array d if c can be obtained from d by deletion of several elements from the beginning and several elements from the end.
For e.g.- The non-empty subarrays of an array [1,2,3] will be- [1],[2],[3],[1,2],[2,3],[1,2,3].
If arr = {-3,4,5}.
All the possible non-empty contiguous subarrays of “arr” are {-3}, {4}, {5}, {-3,4}, {4,5} and {-3,4,5}.
The product of these subarrays are -3, 4, 5, -12, 20 and -60 respectively.
The maximum product is 20. Hence, the answer is 20.
Can you solve this in linear time and constant space complexity?
The idea is to traverse over every contiguous subarrays, find the product of each of these subarrays and return the maximum product from these results.



Consider an array of size six. The elements of the array are { 6, 4, 3, 5, 5, 1 }.
The array should contain elements from one to six. Here, 2 is not present and 5 is occurring twice. Thus, 2 is the missing number (M) and 5 is the repeating number (R).
Can you do this in linear time and constant additional space?
Traverse the array. While traversing, use the absolute value of every element as an index and make the value at this index as negative to mark it visited. If something is already marked negative then this is the repeating element. To find missing, traverse the array again and look for a positive value.



1) Find length of current substring. Use two pointers. Fix one pointer at beginning of substring and move another pointer until a digit is not found.
2) Find frequency of repetition by moving the second pointer further until an alphabet is not found.
3) Find length of substring if it is repeated by multiplying frequency and its original length.
4) If this length is less than k, then required character lies in substring that follows. Subtract this length from k to keep count of number of characters that are required to be covered.
5) If length is less than or equal to k, then required character lies in current substring. As k is 1-indexed reduce it by 1 and then take its mod with original substring length. Required character is kth character from starting of substring which is pointed by first pointer.



Can you solve this using not more than O(S) extra space, where S is the sum of all elements of the given array?
The problem can be solved using dynamic programming when the sum of the elements is not too big. We can create a 2D array part[][] of size (sum/2 + 1)*(n+1). And we can construct the solution in a bottom-up manner such that every filled entry has the following property
part[i][j] = true if a subset of {arr[0], arr[1], ..arr[j-1]} has sum
equal to i, otherwise false



first find the LCA of two nodes. Then find the distance from LCA to two nodes.



Input: 'n' = 3, 'm' = 3, 'mat' = [[1, 1, 1], [0, 0, 1], [0, 0, 0]]
Output: 0
Explanation: The row with the maximum number of ones is 0 (0 - indexed).
A simple method is to do a row-wise traversal of the matrix, count the number of 1s in each row, and compare the count with max. Finally, return the index of the row with maximum 1s. The time complexity of this method is O(m*n) where m is the number of rows and n is the number of columns in the matrix.
2nd Technical Round. The interviewer starts with my introduction. Then He asks question on my projects. After that he asked some DS algo based theory questions like from trees , linked List . after that he game some problems to solve



If A = “aab”, 'B' = “abc”, 'C' = “aaabbc”
Here 'C' is an interleaving string of 'A' and 'B'. because 'C' contains all the characters of 'A' and 'B' and the order of all these characters is also the same in all three strings.

If 'A' = “abc”, 'B' = “def”, 'C' = “abcdefg”
Here 'C' is not an interleaving string of 'A' and 'B'. 'B'ecause neither A nor 'B' contains the character ‘g’.
Make a matrix where rows and columns represent the characters of the string A and B. If C is the interleaved string of A and B then there exists a path from the top left of the Matrix to the bottom right. That is if we can go from index 0,0 to n,m while matching characters of all A and B with C then C is interleaved of A and B.



You need to return the head to the doubly linked list.
The doubly linked list would be: 1 2 3 4 5 and can be represented as:

Algorithm:
Traverse the tree in inorder fashion.
While visiting each node, keep track of DLL’s head and tail pointers, insert each visited node to the end of DLL using tail pointer.
Return head of the list.

Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
How do you remove whitespace from the start of a string?