LinkedIn 申请的
第一轮
- He asked me to explain my projects in detail first.
- It started with a puzzle. https://practice.geeksforgeeks.org/problems/the-3-5-litre-die-hard-water-puzzle
- https://www.geeksforgeeks.org/kth-smallestlargest-element-unsorted-array/
- https://www.geeksforgeeks.org/program-reverse-string-iterative-recursive/ (Discussed both the approaches)
- Given a set of paths. Find the maximum common path among all of them.
Eg. /a/b/c and /a/c are the paths. Then, output has to be /a.
It was expected to handle all the corner cases and solve the problem efficiently (eg. returning if after processing some string the path becomes empty and stuffs like that).
第二轮
He asked me to explain my projects in detail first.
- Again started with a puzzle: https://www.geeksforgeeks.org/print-0-and-1-with-50-probability/
- Suppose there is a new number system where 5 is not present. Convert the number given in this number system to the decimal number system.
Example. Input: 6 Output: 5 Explanation: 5 is absent in the new decimal system
I suggested a DP approach similar to this: https://www.geeksforgeeks.org/count-numbers-from-1-to-n-that-have-4-as-a-a-digit/
But the interviewer was expecting a more optimized answer. It can be solved using base notation. Approach will be similar to this: https://www.geeksforgeeks.org/n-th-number-with-digits-in-0-1-2-3-4-5/ - Find the closest square of a given number without using sqrt function.
Can be solved by finding the sqrt using a binary search approach and then looking for +1 and -1 number’s square.
第三轮
This was more of a language which focussed more on language-specific details.
For me, it was C++. First, he asked me to rate myself in C and C++. I rated 9 in C++ but 8 in C. He asked me the reason and I said pointers are my nightmare. Then, he told I am going to ask lot of pointer questions today.
Questions asked were:
- Define a function pointer
- Create a 2D array dynamically using pointers
- A lot of discussions went around virtual functions
- Can virtual functions be inline? Ans: No . Give Reason as well.
- Generalized stack using a template. Create a class and write all the functions.
- A little bit of discussion on process and thread.
- Shared memory and message passing. How does it work? Advantage of one over other.
- Mirror a BST. initially I swapped the data but later he asked me to do using pointer swapping.
- Puzzle on probability
- Many other questions which I don’t remember
一天后收到 HR 电话说 there will be one more round called director round.
第四轮 (Director round)
Brief introduction of the work that I am doing in the company and my role in it.
- WAP to convert decimal number to binary number. After this, he asked me to review my code and consider optimizations, corner cases if any and what comments will you give if you are reviewing this code. In the end, I used some bit operations to make things faster. Like instead of n/2, n>>1 and stuffs like that.
- He asked me my favorite subject. I said operating systems. The discussion went on around shared library, static library, virtual memory, paging, copy-sharing, message passing, etc os concepts.
- In the end, he asked me to provide the approach to compare two files which has 10^9 lines in an efficient way and return the lines that are common in both. The discussion went for around 40 to 45 minutes. This is one of the best discussion I had.
Approaches discussed were mostly on hashing and sorting.
Constraints: Single processor machine
Verdict: Selected