LinkedIn SSE | Systems and Infra | Rejected
Hackerrank OA:
Cleared all the Test Cases.
Result: Positive
Phone Screen:
(Rescheduled this round thrice. Twice by the recruiter. And once by me)
Coding problem:
I wasn't given a LC problem I guess.
1abstact class NestedInteger {
2 public:
3 virtual bool isInteger() const = 0;
4 virtual int getInteger() const = 0;
5 virtual const vector<NestedInteger> &getList() const = 0;
6};
7/ *
8* nums: {1, {4, {6, 4}}}
9* this would look like
10* 1 depth 3 => 1 * 3 = 3
11* \
12* 4 depth 2 => 2 * 4 = 8
13* \
14* 6, 4 depth 1 => 6*1 + 4*1 = 10
15* Total sum = 10 + 8 + 3 = 21
16*
17* nums: {{1,1}, 2, {1, 1}}
18* 2 depth 2 => 2 * 2 = 4
19* \
20* 1, 1, 1, 1 depth 1 => 1*1 + 1*1 + 1*1 + 1*1 = 4
21* Total sum = 4 + 4 = 8
22// Now complete the below function
23int getDepthSum(vector<NestedInteger>& nums) {
24 // Implement here
25}I solved by doing DFS whenever I a nested list. And saved my result in a new vector. for example 1, my new vector will be [[1], [4], [6,4]] and then I will traverse and calculate the sum. Interviewer was OK with this approach. Dry ran it. Worked.
Follow up: To do it without extra space. They wanted to me calculate sum at each level and complete the sum at each level with the help of current depth and max_depth as I was doing a DFS. Discussed only the approach. Did not dry run it. I had some questions around it and we ran out of time.
Verdict: Rejected
Feedback: I didn't answer about Atomicity. And I used extra space for the vector. Got it directly from the recruiter. "You solved the problem but for an SSE, you gotta solve it without extra space"
I guess I should practice more DFS. Please let me know the topics I should cover to deal with problems like this.
Timeline: 2 weeks with all the rescheduling considered.
Guys please grind hard. Peace ✌️.