Linkedin SSE Interview
Summary
I shared my interview experience, which included a discussion on Java internals covering multi-threading, HashMap, Concurrent HashMap, JVM, and a specific Data Structures & Algorithms question about finding common ancestors in a graph.
Full Experience
Helping Leetcode community !
-------------------------------------------------------------
Dicussion on Java internals (multi threading concepts - Callable/Runnable, HashMap internals, Concurrent HashMap, JVM)
One DSA question asked:
Interview Questions (2)
Java Internals Discussion
Discussion on Java internals including multi-threading concepts (Callable/Runnable), HashMap internals, Concurrent HashMap, and JVM.
Find if Two Individuals Share a Common Ancestor
Suppose we have some input data describing a graph of relationships between parents and children over multiple generations.
The data is formatted as a list of (parent, child) pairs, where each individual is assigned a unique positive integer identifier.
For example, in this diagram, 6 and 8 have common ancestors of 4 and 14.
15
/
14 13 21
| |
1 2 4 12
\ / / | \ /
3 5 8 9
\ / \
6 7 11
pairs = [
(1, 3), (2, 3), (3, 6), (5, 6), (5, 7), (4, 5),
(15, 21), (4, 8), (4, 9), (9, 11), (14, 4), (13, 12),
(12, 9), (15, 13)
]
3: [1,2]
4: [14]
6: [3,5,1,2,4,14]
8:[4,14]
Write a function that takes this data and the identifiers of two individuals as inputs and returns true if and only if they share at least one ancestor.
Sample input and output:
hasCommonAncestor(pairs, 3, 8) => false
hasCommonAncestor(pairs, 5, 8) => true
hasCommonAncestor(pairs, 6, 8) => true
hasCommonAncestor(pairs, 6, 9) => true
hasCommonAncestor(pairs, 1, 3) => false
hasCommonAncestor(pairs, 3, 1) => false
hasCommonAncestor(pairs, 7, 11) => true
hasCommonAncestor(pairs, 6, 5) => true
hasCommonAncestor(pairs, 5, 6) => true
hasCommonAncestor(pairs, 3, 6) => true
hasCommonAncestor(pairs, 21, 11) => true