Tip 1 : Be very clear with your project explanation.
Tip 2 : Also try to cover all the cs core subjects explanation clearly.
Tip 1 : Make it clean with appropriate knowledge.
Tip 2 : Provide true information and avoid telling lie in which You are not sure.
It was morning time and from 10:00 am . It happened via the google meet online process and it was very smooth onboarding . Interviewer was very friendly kind of nature .



Note: Since the number of ways can be very large, return the answer modulo 1000000007.
N=3

We can climb one step at a time i.e. {(0, 1) ,(1, 2),(2,3)} or we can climb the first two-step and then one step i.e. {(0,2),(1, 3)} or we can climb first one step and then two step i.e. {(0,1), (1,3)}.
int countWays(int n)
{
if(n == 1) return n;
int mod = 1000000000 + 7;
int prev = 2, prev2 = 1, curr = 0;
for(int i = 2 ; i < n ; i++){
curr = (prev + prev2) % mod;
prev2 = prev;
prev = curr;
}
return prev ;
}
It was again the morning session and the interviewer was very supportive in nature and gave me the hint too to think the approach and finally i came up the solution which he was expecting.



If K is 4 and the tree is depicted by the following image then,

The 4th largest element in the given BST is 1. So the output will be 1.
Try to do it in O(1) space without using recursion.
#include
using namespace std;
// Tree Node
struct Node {
int data;
Node *left;
Node *right;
Node(int val) {
data = val;
left = right = NULL;
}
};
// Function to Build Tree
Node* buildTree(string str)
{
// Corner Case
if(str.length() == 0 || str[0] == 'N')
return NULL;
// Creating vector of strings from input
// string after spliting by space
vector ip;
istringstream iss(str);
for(string str; iss >> str; )
ip.push_back(str);
// Create the root of the tree
Node* root = new Node(stoi(ip[0]));
// Push the root to the queue
queue queue;
queue.push(root);
// Starting from the second element
int i = 1;
while(!queue.empty() && i < ip.size()) {
// Get and remove the front of the queue
Node* currNode = queue.front();
queue.pop();
// Get the current node's value from the string
string currVal = ip[i];
// If the left child is not null
if(currVal != "N") {
// Create the left child for the current node
currNode->left = new Node(stoi(currVal));
// Push it to the queue
queue.push(currNode->left);
}
// For the right child
i++;
if(i >= ip.size())
break;
currVal = ip[i];
// If the right child is not null
if(currVal != "N") {
// Create the right child for the current node
currNode->right = new Node(stoi(currVal));
// Push it to the queue
queue.push(currNode->right);
}
i++;
}
return root;
}
// } Driver Code Ends
/*The Node structure is defined as
struct Node {
int data;
Node *left;
Node *right;
Node(int val) {
data = val;
left = right = NULL;
}
};
*/
// return the Kth largest element in the given BST rooted at 'root'
class Solution
{public:
void solve(Node*root,int k,int&c,int &ans){
if(root==NULL||c>=k){
return ;
}
solve(root->right,k,c,ans);
c++;
if(c==k){
ans=root->data;
return;
}
solve(root->left,k,c,ans);
}
public:
int kthLargest(Node *root, int k)
{
int c=0;int ans;
solve(root,k,c,ans);
return ans;
}
};
// { Driver Code Starts.
int main()
{
int t;
cin>>t;
getchar();
while(t--)
{
string s;
getline(cin,s);
Node* head = buildTree(s);
int k;
cin>>k;
getchar();
Solution ob;
cout << ob.kthLargest( head, k ) << endl;
}
return 1;
} }
It was late evening and happened in a very smooth way.
Ques :what are difference between process and thread?
Ques: What is thread in OS?
Tip 1:Try to give answer with the real life examples
Tip 2:Give answers in your own language and avoid the bookish language

Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
What is recursion?