Hike Interview Experience | Off Campus September 2019
Round 1: Online Coding Round
5 Programming Questions, Duration: 75 minutes
- Given two coordinates (a, b) and (c, d), check if (a, b) can be made (c, d). At every step (a, b) can be converted to (a+b, b) or (a, a+b). Since there are two choices to be made at each step, recursion is the approach. Only “Yes” or “No” had to be the output.
- Given a 26 length array which indicates whether a character is normal or special(0/1), a string and an integer k, find the longest substring in input string such that their are atmost k special characters in it. Looking for each substring would timeout so use sliding window technique and keep the count of special characters encountered, Whenever the count>k, reduce the window form the beginning.
- Given an array of strings, we can move from one string to another by deleting one character. Find the longest chain that can be formed by performing this operation. Since the chain will constitute of strings with difference of length 1, we can sort the strings on the basis of length and then create the chain.
- Given a 2D array with 0 and 1, find the largest square with all 1s. DP question.
- Given an array, find the minimum number of swaps needed to move all even elements to beginning and odd elements to end of array.
- GetMin() function in Stack.
- Given two sorted linked lists, merge them. Then he modified the question to given k sorted linked lists, merge them. This can be done by using k-sized min-heap.
- Given an array you have sort it based on the relative ordering of another array. Modify custom sort.
- Minimum platforms needed in a railway station. I told him O(nlogn) approach. He asked for O(n) approach. I wasn’t able to think of O(n) approach so he asked another question which would help to solve the current question. How to check if two strings are anagrams? This question helped to find the O(n) solution.
- Given an array find all the subsets whose sum is divisible by 8. I knew that cumulative sum had to be taken but then I couldn’t think how to use that. So he told me that I can form an equation of numbers divisible by 8. If say sum(i, j) (i<j)is divisible by 8 then, sum(0, j) = 8*sum(i, j) + sum(0, i-1). And the possible remainders are 0-7. So we can store the remainder at each j, and such combination to determine the answer.
- How is HashMap implemented in Java? Handling Collisions and how is the hashmap size handled as more and more data comes in. The hashmap size is doubled and existing keys are remapped.
- Singleton class and its implementation.
- Reader Writer Problem with modifications to give preference to writer if it arrives, since standard implementation starves writers.
- LRU Cache implementation.
- Then he modified the question. Each key has a Time to expiry field. So those keys had to be removed from the cache. I started with hashmap but he was looking for a different data structure.
Round with VP. Asked me behavioral questions. About my CV, my interests.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course. In case you are prepared, test your skills using TCS, Wipro, Amazon. Google and Microsoft Test Serieses.