Category: Interview

Topological Sort

Read More

Tree Traversal code implementation in Recursive and Iterative Ways

1. Description Recursive way is based on computer program, the function calling stack. While iterative way is programmer use stack to simulate it. 2. Solution

Read More

LRU Cache – LeetCode 146

1. Description Design and Implement a data structure for LRU cache. It should support get and put. get(key) – Get the value (will always be positive) of the key if the key exists in the cache, otherwise return -1.put(key, value) – Set or insert the value if the key is not already present. When the cache reached […]

Read More

Find the sum of the two elements of a given array which is equal to an given integer

1. Description Asked by Google. Given a list of numbers and a number k, return whether any two numbers from the list add up to k. 2. Example Given [10, 15, 3, 7] and k of 17, return true, since 10+7 is 17. 3. Solution – 3 ways to solve it.

Read More

Google Initial Phone Screen with Recruiter

1. Questions What’s the best/worst running time of Merge Sort? O(nlogn), O(nlogn) What’s the best/worst running time of Quick Sort? O(n), O(n^2) What’s the worst running time for a look up in a HashTable? O(n) two reasons: if too many elements were hashed into the same key: looking inside this key may take O(n) time; […]

Read More