Professional Documents
Culture Documents
Initially she give an solution using Hash map but it was not keeping
the order of integers.
She than suggest using a ordered Hash but time complexity is still
O(N2)
After getting hints she was able to using doubly linked list.
She took many hints to use Hash properly to store list reference as key
- value for fast search within list.
Finally she suggested the solution with overall O(N) time complexity
using hash and doubly linked list.
She find it difficult to crack. I gave her many hints but she find it
challenging to code.
She suggested an recursive approach using input two array filled with
N Left and Right parentheses
But she was not able to code it.
Even her code was nowhere near a solution.
Her final code was.
while(n>0){
for(int i=0; i<n; i++){
System.out.println(left[n]);
System.out.println(right[n]);
}
for(int i=0; i<n; i++){
System.out.println(left[n]);
System.out.println(right[n]);
}
n=n-1;
print(left, right, n);
}