Grey Orange Interview Experience 2019

There were supposed to be 4 rounds. 1 coding and 3 face-to-face.
1st Round: Hackerrank, 4 coding questions and 1 hour limit. Not necessary to pass all 4 questions. If 2 of them have passed all the test cases then the round is cleared.
Ques 1 – Find no of 2 wheeler and 4 wheeler corresponding to every element from a given array. Example: input: [6, 3, 2]
output: [2, 0, 2]
explanation: for 6: 1 4-wheeler and 1 2 wheeler. for 3: not possible so 0. for 2: only 1 2-wheeler is possible.

Ques 2-find sum of all odd factors from a given array. Example: input: [1, 6, 9]
output: sum = 1(1) + 4(1, 3 for 6)+13(1, 3, 9 for 9) = 18

Ques 3- https://www.geeksforgeeks.org/minimum-swaps-required-group-1s-together/

Due to the time limit, I could not attend the 4th question.

2nd Round: Face-To-Face
, 4 questions.
1st Ques: given a sum and an input array. Find all possible ways that an input subarray can form the given sum. Note that you can repeat the numbers of input array any no. of times.
example: input: sum=14, array[]={1, 5, 8}. Output: 5 ways: {1, 5, 8}, {5, 5, 1, 1, 1, 1}, {8, 1, 1, 1, 1, 1, 1}, {5, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
I tried to use iteration and started to write examples and code on white board but could not get to the answer. The interviewer asked me if using recursion is possible? I tried using O(n^2) approach but still was only halfway.
Solution is here: https://www.geeksforgeeks.org/ways-sum-n-using-array-elements-repetition-allowed/

2nd Ques: Find minimum swaps required to convert BT to BST.
I answered using inorder sorting method.
Solution is here: https://www.geeksforgeeks.org/minimum-swap-required-convert-binary-tree-binary-search-tree/

3rd Ques: Reader-Writer problem multithreading. Write the code for it.

4th Ques: SmartPointer Question. I explained the smartPointer with code that how it automatically manages the memory since the destructor always delete the ptr memory allocated and we need not call the destructor explicitly since it gets called automatically when object goes out of scope.
So, the next question asked in this was if the destructor can automatically be called then why don’t we implement the same for every class
(that is, deleting the memory allocated in destructor) and then how the smartPointer is different from that every class. Why do we need smartPointer then. This confused me.

I did not have the further rounds.

All the Best!

Write your Interview Experience or mail it to contribute@geeksforgeeks.org



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.