Hike Interview Experience | Set 5

Round I
1.Implement expiry cache system : every page in cache have id and expiry time (TTL of few seconds). After page expires it behaves as free space and can be used for new pages/replacement. Had a long discussion on everything.

Round II
very boring round
1. https://www.geeksforgeeks.org/print-nodes-distance-k-given-node-binary-tree/
2. https://www.geeksforgeeks.org/check-if-two-trees-are-mirror/
3. https://www.geeksforgeeks.org/largest-sum-contiguous-subarray/

Round III
very boring round
2. ZigZag traversal of tree
3. https://www.geeksforgeeks.org/search-an-element-in-a-sorted-and-pivoted-array/
4. https://www.geeksforgeeks.org/find-a-fixed-point-in-a-given-array/

finally something new..
5. given a sorted array say A : (-4,-2,0,1,4,6,8,10). There is a function f(x) = a*x^2 + b*x + c , apply this function on A where x is any ith element from array A and a,b,c belongs to set of real numbers. Will f(A) will be sorted, if not then sort it in O(n).
It is very easy if you still remember concepts of quadratic equation from maths. I did not remember so he helped me.
Logic is that any quadratic equation is represented by parabola on graph and graph has minimum value at dy/dx = 0,i.e, 2*a*x + b = 0. Both sides of this point graph keeps increasing/decreasing to the infinity depending upon value of a. Calculate value of x = -b/(2*a). find it in sorted array or find its ceiling in log n. starting from this point to both ends, perform merge sort.

Round IV
1. implement LRU cache
2. Implement following.
There are three type of request :
i) www.someurl.com/conn_id=?&timeout=? -: for this conn_id you will wait for timeout sec and after that return reponse, in meantime you can get some more requests of any one of three types
ii) www.someurl.com/stat/ -: return all id waiting to timeout along with their remaining timeout interval
ii) www.someurl.com/kill/conn_id=? -: end wait timeout of this conn_id and return response for this conn_id

I gave a solution with heap. He asked how to handle case when a request is waiting for timout and new request came in meantime. How to do server side scalability in this case.

3. He asked about current work and technologies I am working upon. I said Java, Spring MVC for backend and html,css, javascript for front end and suddenly he asked what is difference between Java and javascript. Could not figure out at that time. Javascript is also an object oriented language an can be used at server side like node js. Still there are lot of differences.


If you like GeeksforGeeks and would like to contribute, you can also write an article and mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above

Write your Interview Experience or mail it to contribute@geeksforgeeks.org

My Personal Notes arrow_drop_up