LinkedIn Interview | Senior Software Engineer | Bangalore | 2022 | Reject
Telephone screen round
Started with a brief Introduction
Asked to draw an HLD of the current services you’re working upon
Design a thread - hashMap of your own
1class HashMap {
2
3 private static int bucketSize = 1000;
4 List<Entry>[] map = new List[bucketSize];//value;
5
6 public void put(String key, String value) {
7 int idx = hashCode(key, bucketSize);
8
9 synchronized {
10 if(map[idx] == null) map[idx] = new ArrayList();
11
12 for(Entry e : map[idx]) {
13 if(e.key == key) {
14 e.value = value;
15 return;
16 }
17 }
18 map[idx].add(new Entry(key, value);
19 }
20 }
21
22 public String get(String key) {
23
24 int idx = hashCode(key, bucketSize);
25 List<Entry> list = map[idx];
26
27 if(list==null) return "Key not found";
28
29 for(Entry e : list) {
30 if(e.key == key) return e.value;
31 }
32 return "Key not found"
33 }
34
35
36}
37
38public class Entry {
39 String key, value;
40 public(String key, String value) {
41 this.key = key;
42 this.value = value;
43 }
44}Round 1
Inclusive time is defined as all the time spent on a particular function, including time spent on its child calls.
Exclusive time is defined as the time spent on a particular function only, excluding time spent on its child calls.
In the above example, inclusive time for function "abc" is 200-100=100, while exclusive time for function "abc" is (200-100) - (180-150) = 70
Given such a list of strings, figure out the inclusive and exclusive time for any given function call.
Round 2
Round 3
We have a big deployment with hundreds of machines each of which is exposing thousands of statistics. You can think that each statistic is represented by the tuple [source, metric-name, value].
We want to be able to collect and aggregate those tuples in a scalable manner.
The main consumers for this system are:
The engineer who wants to see how the application’s latency is from last 1 month
As an alert service we setup alerts
Source metric ( t1 to t2) we want to see the metrics how to query the values
Round 4 (Concurrency round)
1import java.util.PriorityQueue;
2import java.util.concurrent.Semaphore;
3
4public class BlockingQueue {
5
6 PriorityQueue heap;
7 Semaphore read;
8 Semaphore write;
9
10 BlockingQueue() {
11 write = new Semaphore(1);
12 read = new Semaphore(0);
13 this.heap = new PriorityQueue<Tuple>((a,b) -> a.key - b.key);
14 }
15
16 public void write(Tuple tuple) throws InterruptedException {
17 synchronized (heap) {
18 write.acquire();
19 heap.add(tuple);
20
21 write.release();
22 read.release();
23 }
24 }
25
26 public Tuple read() throws InterruptedException {
27 read.acquire();
28 synchronized (heap) {
29
30 Tuple t = (Tuple)heap.peek();
31
32 heap.poll();
33 return t;
34 }
35 }
36}
37
38public class Tuple {
39
40 int key;
41 int value;
42
43 public Tuple(int key, int value) {
44 this.key = key;
45 this.value = value;
46 }
47}Result: Reject as I couldn't solve - find all palindromic subsequences.