LinkedIn Senior Software Engineer | Final Round | US
Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2024-11-22Added By Anonymous
Source: Link
Nov 2024
Tech Screen:
1.Similar to https://leetcode.com/problems/valid-parentheses/description/?envType=company&envId=linkedin&favoriteSlug=linkedin-six-months
2.https://leetcode.com/problems/nested-list-weight-sum-ii/description/?envType=company&envId=linkedin&favoriteSlug=linkedin-three-months
Final:
Coding 1:
Similar to https://leetcode.com/problems/find-the-celebrity/ except the list is a 2D array representing relations.
1 Example Input:
2 Input List: numbers = [0, 1, 2, 3]
3
4 Relation Matrix:
5 relation = [
6 [0, 1, 1, 1], // Person 0 knows 1, 2, 3
7 [0, 0, 1, 1], // Person 1 knows 2, 3
8 [0, 0, 0, 1], // Person 2 knows 3
9 [0, 0, 0, 0] // Person 3 knows nobody
10 ]
11
12System Design:
13 Top K shared posts
14
15Coding 2:
16 Question 1:
17 Given a tree with an arbitrary number of children, sort the nodes by the order in which they would "fall" off a tree. At every step, all the nodes which have no children are deleted from the tree. This process is repeated until only the root node remains, at which point it falls off the tree as well.
18
19 For example, given the following tree:
20 A
21 / \
22 B C
23 / \
24 D E
25
26 - At the first step, leaves "D," "E," and "C" fall off the tree. That leaves us with the following:
27 A
28 /
29 B
30
31 - At the second step, only leaf "B" falls off the tree.
32 - At the third step, the root "A" falls off the tree.
33
34 Therefore, for the example tree, this method should return: [{C, D, E}, {B}, {A}]
35
36 Another way to think about the result is as follows:
37
38 - Given some nodes, group the nodes into a list of sets such that the following two properties are satisfied:
39 1. A node appears later in the list than its children.
40 2. A node appears as soon as possible in the list.
41
42 class Solution {
43 // Reminder of some of the useful methods of the TreeNode interface
44 public interface TreeNode {
45 // Get all the children of a node
46 Collection<TreeNode> children();
47 }
48 }
49
50 Question 2:
51 https://leetcode.com/problems/max-consecutive-ones-iii/description/
52 Note that the part was worded differently but almost exactly the same.
53