Tip 1 : Practice as many questions as you can
Tip 2 : Always try to optimize (space and time both) your solution
Tip 3 : Think twice before you start to write your code.
Tip 1 : It is better to have at least 2 projects in resume
Tip 2 : Be sure of what you wright in your resume
It was completely objective based.
#include int a=10;int main(){ int a=20; cout<<::a; return 0;}The output of this program isOptions- Syntax error- 10 20- 20 10- 20 20
Ans:- 20 10
The above program can have same name for local and global variables but value of local variable inside a function will take preference. When the above code is compiled and executed, it produces the following result:
2010
#include using namespace std;class Base1 { public: Base1() { cout << " Base1's constructor called" << endl; }}; class Base2 { public: Base2() { cout << "Base2's constructor called" << endl; }}; class Derived: public Base1, public Base2 { public: Derived() { cout << "Derived's constructor called" << endl; }}; int main(){ Derived d; return 0;}(A)Base1's destructorBase2's destructorDerived's destructor(B)Derived's destructorBase2's destructorBase1's destructorC) Compiler Dependent
Answer: (B)
Explanation: Destructors are always called in reverse order of constructors
#include int main(){ int x = 80; int y& = x; x++; cout << x << " " << --y; return 0;}Options :- [A]. The program will print the output 80 80.[B]. The program will print the output 81 80.[C]. The program will print the output 81 81.[D]. It will result in a compile time error
Ans D
Answer is D as Y is storing the address of X, so --Y will result in error.
#include enum bix{ a=1, b, c};int main(){ int x = c; int &y = x; int &z = x; y = b; cout<< z--; return 0; }Options :- [A]. It will result in a compile time error.[B]. The program will print the output 1.[C]. The program will print the output 2[D]. The program will print the output 3.
Ans : - C
x=3
y=3
z=3
y=2 i.e.
x=2 i.e.
z=2
And decrement operator will effect only after the output !
Thus output = 2.
But z = 1.
consisted of 3 coding questions and 1 output based question




1. You are not required to print the output explicitly, it has already been taken care of. Just implement the function and return the ‘K-th’ smallest element of BST.
2. You don’t need to return ‘K-th’ smallest node, return just value of that node.
3. If ‘K-th’ smallest element is not present in BST then return -1.



• The left subtree of a node contains only nodes with data less than the node’s data.
• The right subtree of a node contains only nodes with data greater than the node’s data.
• Both the left and right subtrees must also be binary search trees.

For the given BST and target value ‘K’ = 32, the closest element is 30 as the absolute difference between 30 and 32 (|32 - 30|) is the minimum among all other possible node-target pairs.



Anagrams are defined as words or names that can be formed by rearranging the letters of another word. Such as "spar" can be formed by rearranging letters of "rasp". Hence, "spar" and "rasp" are anagrams.
'triangle' and 'integral'
'listen' and 'silent'
Since it is a binary problem, there is no partial marking. Marks will only be awarded if you get all the test cases correct.
consisted of 3 medium level coding questions



Input: Linked List: 1 <-> 2 <-> 2 <-> 2 <-> 3
Output: Modified Linked List: 1 <-> 2 <-> 3
Explanation: We will delete the duplicate values ‘2’ present in the linked list.



“{}{}”, “{{}}”, “{{}{}}” are valid strings while “}{}”, “{}}{{}”, “{{}}}{“ are not valid strings.
Minimum operations to make ‘STR’ = “{{“ valid is 1.
In one operation, we can convert ‘{’ at index ‘1’ (0-based indexing) to ‘}’. The ‘STR’ now becomes "{}" which is a valid string.
Return -1 if it is impossible to make ‘STR’ valid.



1. If you encounter a situation when 'B[i]' is greater than the number of remaining nodes in the list, then simply reverse the remaining nodes as a block and ignore all the block sizes from 'B[i]'.
2. All block sizes are contiguous i.e. suppose that block 'B[i]' ends at a node cur, then the block 'B[i+1]' starts from the node just after the node cur.
Linked list: 1->2->3->4->5
Array B: 3 3 5
Output: 3->2->1->5->4
We reverse the first block of size 3 and then move to block 2. Now, since the number of nodes remaining in the list (2) is less than the block size (3), we reverse the remaining nodes (4 and 5) as a block and ignore all the block sizes that follow.
1st interview was early in the morning.
Interviewer asked for a basic introduction followed by 2 questions.
For coding questions you need to first discuss the approach with the interviewer only when the interviewer is satisfied with your approach, the interviewer will ask you to code.
Questions were of easy level






For coding questions you need to first discuss the approach with the interviewer only when the interviewer is satisfied with your approach, the interviewer will ask you to code.



You need to return the head to the doubly linked list.
The doubly linked list would be: 1 2 3 4 5 and can be represented as:




Given a binary tree :

All the root to leaf paths are :
1 2 4
1 2 5
1 3
1. Two nodes may have the same value associated with it.
2. The root node will be fixed and will be provided in the function.
3. Note that the nodes in a path will appear in a fixed order. For example, 1 2 3 is not the same as 2 1 3.
4. Each path should be returned as a string consisting of nodes in order and separated by a space.
5. The path length may be as small as ‘1’.
The interview started with a basic introduction, some discussion on projects, my journey till now and finally 2 coding questions were asked.Interviewer will make you dry run your code on provided test cases for every coding question in every interview .
As all three interviews were scheduled on the same day, giving 3rd round of approx 2.5 hrs with the same energy and mindset made it a bit difficult. Also the level of questions that were asked was higher than the first 2 interviews.
Try not to mug up things before the interview, that will only make things stressful.
Be calm and relax.
The interviewers were helpful and so you can ask for hints if stuck anywhere.



• The left subtree of a node contains only nodes with data less than the node’s data.
• The right subtree of a node contains only nodes with data greater than the node’s data.
• Both the left and right subtrees must also be binary search trees.
1. All the elements of the Binary Search Tree are unique.
2. You can’t use the same node value/element of BST twice.
tree: 8 5 10 2 6 -1 -1 -1 -1 -1 7 -1 -1
'K' = 13,

The nodes with values 8 and 5 as shown in the above figure gives sum equal to the given target 13.
Therefore, the output will be “true” i.e it is possible to find a pair in the given BST having sum equal to ‘K’.



You can use extra space of the order of not more than O(log n).
A binary search tree (BST) is a binary tree data structure which has the following properties.
• The left subtree of a node contains only nodes with data less than the node’s data.
• The right subtree of a node contains only nodes with data greater than the node’s data.
• Both the left and right subtrees must also be binary search trees.
1. All the elements of the Binary Search Tree are unique.
2. You can’t use the same node value/element of BST twice.
HR round was on the same day, and was short and non technical.
some basic questions like why do you want join JTG, how were the interviews and are there any suggestions or queries were asked.
Be confident and sure of what you say

Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
How do you remove whitespace from the start of a string?