LinkedIn | SSE | 6 YOE | India
Tech Screening ------------------------------
- Questions on process vs threads, virtual memory, etc
- Design a data structure that can perform the following:
1. add an element
2. remove a random elementOptimal solution needs to be done in O(1) for all operations - can be done with ArrayList implementation and swapping a random generated index element with the last element and decrementing list size.
Loop ----------------------------------------
Coding Module 1:
- Question based on connected components of a graph
- Celebrity problem [GFG]
I was able to the first one, but the second one optimal solution was expected i could only do the brute force in O(n^2) TC
Coding Module 2:
- Given a BST of Integer numbers and a target, find the k closest points to it. (target may not be present in the BST and closest means absolute distance) - need to do this in O(n) TC and O(k) SC
// Given the following Binary Search Tree:
// 10
// / \
// 5 20
// /\ /\
// 1 6 19 35
// \
// 7
// Given target=8, and k=3, it should return 6,7,10
// Given target=6, and k=3, it should return 5,6,7- Design a datastructure which can store keys, give the key with max frequency and min frequency. The keys can be incremented or decremented by 1 (this is the hint)
/*
* Implement the following interface.
*
* All methods must run in O(1) time.
*/
interface AllForOne {
/**
* Increment the provided key's frequency value by 1. Or add the key with the frequency 1 if it's not present.
*
* Note that the actual frequency value of the key is not necessary to expose to the caller; its value is only kept internally for bookkeeping purposes.
*/
void incrementKey(String key);
/**
* Decrement the provided key's frequency value by 1. Or remove the key if its frequency is 1. Do nothing if the key is not present.
*
* Note that the actual frequency value of the key is not necessary to expose to the caller; its value is only kept internally for bookkeeping purposes.
*/
void decrementKey(String key);
/**
* Get one of the keys with the max frequency, or empty string if there are no keys.
*/
String getMaxKey();
/**
* Get one of the keys with the min frequency, or empty string if there are no keys.
*/
String getMinKey();
}
incrementKey("foo"); // void
incrementKey("foo"); // void
incrementKey("foo"); // void
incrementKey("foo"); // void
incrementKey("bar"); // void
incrementKey("bar"); // void
incrementKey("bar"); // void
incrementKey("bar"); // void
getMaxKey(); // "foo" or "bar" can be returned because foo -> 4, and bar -> 4
getMinKey(); // "foo" or "bar" can be returned because foo -> 4, and bar -> 4
decrementKey("foo"); // void
getMaxKey(); // "bar" because foo -> 3, and bar -> 4
getMinKey(); // "foo" because foo -> 3, and bar -> 4
decrementKey("foo"); // void
decrementKey("foo"); // void
decrementKey("foo"); // void
getMaxKey(); // "bar" because foo is not in the structure, and bar -> 4
getMinKey(); // "bar" because foo is not in the structure, and bar -> 4I couldn't do the first one(it might work with in order traversal + a k size Deque/ doubly linkedList), second one i gave a valid solution approach using the concepts from LRU cache problem.
Complex System Design:
Design a Metric Collection System - focus on the data store.
Host Manager:
General discussion of projects and deep dive into a recent project, your role and impact, challenges.


