Tip 1 : striver sheet
Tip 2 : have some good project
Tip 1 : Good project in your resume
Tip 2 : Mention all your skills






1. The heights of the buildings are positive.
2. Santa starts from the cell (0, 0) and he has to reach the building (N - 1, M - 1).
3. Santa cannot leave the grid at any point of time.



class BinaryTreeNode {
int data; // Value of the node.
BinaryTreeNode *left; // Pointer to left child node.
BinaryTreeNode *right; // Pointer to right child node.
BinaryTreeNode *next; // Pointer to next right node at same level.
}
Consider the figure shown below. The left part represents the initial binary tree and right part represents the binary tree after connecting adjacent nodes at the same level.

In the tree shown in the picture above -:
The ‘next’ pointer of the node having value 2 is connected to the node having value 3.
The ‘next’ pointer of the node having value 4 is connected to the node having value 5.
The ‘next’ pointer of the node having value 5 is connected to the node having value 6.
The ‘next’ pointer of nodes having value 1, 3, 6 will have a value NULL as there are no next right nodes in their cases.
1. The structure of the ‘Node’ of a binary tree is already defined. You should not change it.
2. The root of the binary tree is known to you.
3. There is at least one node in the given binary tree.
4. You may only use constant extra space.
class Solution
{
public:
//Function to connect nodes at same level.
void connect(Node *root)
{
queues1;
queues2;
if(root==NULL)
return ;
s1.push(root);
while(s1.size()!=0 || s2.size()!=0)
{
Node* one=NULL;
Node* two=NULL;
while(s1.size()!=0)
{
if(one==NULL)
{
one=s1.front();
s1.pop();
if(one->left!=NULL)
s2.push(one->left);
if(one->right!=NULL)
s2.push(one->right);
}
else
{
one->nextRight=s1.front();
s1.pop();
one=one->nextRight;
if(one->left!=NULL)
s2.push(one->left);
if(one->right!=NULL)
s2.push(one->right);
}
}
while(s2.size()!=0)
{
{
if(two==NULL)
{
two=s2.front();
s2.pop();
if(two->left!=NULL)
s1.push(two->left);
if(two->right!=NULL)
s1.push(two->right);
}
else
{
two->nextRight=s2.front();
s2.pop();
two=two->nextRight;
if(two->left!=NULL)
s1.push(two->left);
if(two->right!=NULL)
s1.push(two->right);
}
}
}
}
}
};



• 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.
class Solution
{
public:
//Function to return a list of integers denoting the node
//values of both the BST in a sorted order.
void inorder(Node* root,vector&v)
{
if(root==NULL)
return ;
inorder(root->left,v);
v.push_back(root->data);
inorder(root->right,v);
}
vector merge(Node *root1, Node *root2)
{
//Your code here
vectorv;
inorder(root1,v);
inorder(root2,v);
sort(v.begin(),v.end());
return v;
}
};

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?