The online test was conducted on CoCubes on 2017, 5th November. The test was webcam enabled to avoid any kind of cheating. You cannot open any other tab or minimize the window. It consisted of 3 coding questions.
TIME LIMIT: 75 minutes
(*) Marks(Qn-1) = 2
(*) Marks(Qn-2) = 3
(*) Marks(Qn-3) = 5
Question 1: Write a function which accepts an integer array and its size and modifies the array in the following manner:
1) If the elements of index i and (i+1) are equal then, double the value at index i and replace the element at index (i+1) with 0. 2) If the element at index i is 0, then ignore it. 3) Any number (element in an array) must be modified only once. 4) At the end, shift all the zeros (0s) to the right of the array and remaining nonzeros to the left of the array. Example: Input: 2 2 0 4 0 8 Output: 4 4 8 0 0 0 Input: 2 2 0 4 0 2 Output: 4 4 2 0 0 0
Question 2: Write a function which accepts an integer array and its size and returns the maximum index difference i.e. (i-j) such that array[i] < array[j] and i < j. If there is no such case, return -1 .
Input: 2 0 3 5 6 1 Output: 4 There was only one test case given which is mentioned above. But I am providing the below one of the sample cases which is an important thing to be noted. It returns -1 because all the elements after any given element are smaller than it. DO take care of such cases. Input: 9 8 7 6 5 Output: -1
Question 3: Write a function which accepts the root of a tree, and returns a Linked List which contains the leaf nodes of the tree from left to right order.
Assumptions:
(*) Structure of the node of tree is as follows:
struct TreeNode
{
int data;
struct TreeNode* left;
struct TreeNode* right;
};
(*) Don't allocate extra memory for Linked List, just let the right pointer of a leaf
node point to the next leaf node to form a linked list.
Example:
10
/ \
20 100
/ \ / \
30 40 9 66
Output: 30 -> 40 -> 9 -> 66
Keep practicing questions from GeeksForGeeks.
This article is contributed by MAZHAR IMAM KHAN. 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 write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Recommended Posts:
- Amazon interview Experience | Set 141 (For SDE1)
- Tesco Bengaluru Interview Experience | Set 1 (Online Coding Test)
- Amazon Interview Experience | SDE-1 offcampus
- Amazon Interview Experience Offcampus for SDE-1
- Mahindra Comviva Interview Experience 2020 (Product/Software Development OffCampus)
- MakeMyTrip Interview Experience | Set 5 (Online Coding)
- BrowserStack Interview Experience | Set 7 (Online Coding Questions)
- MakeMyTrip Interview Experience | Set 6 (Online Coding)
- Fiberlink (maas360) Interview Experience | Set 5 (Online Coding Question)
- Microsoft IDC Interview Experience | Set 38 (For Internship)
- Microsoft IDC Interview Experience | Set 37B
- Microsoft IDC Interview Experience| Set 44
- Microsoft IDC interview Experience | Set 47 (For 1.7 Years Experienced)
- Microsoft Interview Experience | Set 62 (On-Campus for IDC)
- Microsoft Interview Experience | Set 61 (On-Campus for IDC)
- Microsoft Interview Experience | Set 65 (On-Campus for Internship IT and IDC)
- Microsoft IDC Interview Experience | Set 66 (On-Campus for Internship)
- Microsoft IDC Interview Experience | Set 67 (On-Campus for Internship)
- Microsoft IDC Interview Experience | Set 68 (For SDE)
- Microsoft IDC Interview Experience | Set 69 (For SDE)


