Tip 1: Search for top interview questions on your topic on Google and read them thoroughly.
Tip 2: Be prepared for general questions as well. For example, "Tell me something about yourself," "Why do you want to join?" "What do you know about the company?" etc.
Tip 3: Practice as many questions as you can, as this will help you build logic in a short time.
Tip 4: Complete at least two projects.
Tip 1: Make concise, to-the-point statements in your resume.
Tip 2: Mention your projects, skills, and experiences in detail.
For the given binary tree
The level order traversal will be {1,2,3,4,5,6,7}.
Step 1: Create an empty queue that accepts BinaryTreeNode.
Step 2: Put the root of the binary tree in the queue.
Step 3: Loop while the queue is not empty:
1. The given node 'TARGET_NODE_VAL' is always present in the tree.
2. The value of each node in the tree is unique.
3. Notice that the Kth ancestor node if present will always be unique.
I solved this question recursively.
Step 1: Find the given node in the tree.
Step 2: If the node is not found, simply return null. Otherwise, check if K is greater than 0. If yes, that means we haven't found the Kth ancestor, so we decrement the value of K. Also, check if K is 0. If it is, we have found the Kth ancestor, so we print it, return null, and if the root is null, we return.
You need to modify the given tree only. You are not allowed to create a new tree.
For the given binary search tree
11 will be replaced by {15 + 29 + 35 + 40}, i.e. 119.
2 will be replaced by {7 + 11 + 15 + 29 + 35 + 40}, i.e. 137.
29 will be replaced by {35 + 40}, i.e. 75.
1 will be replaced by {2 + 7 + 11 + 15 + 29 + 35 + 40}, i.e. 139.
7 will be replaced by {11 + 15 + 29 + 35 + 40}, i.e. 130.
15 will be replaced by {15 + 29 + 35 + 40}, i.e. 104.
40 will be replaced by 0 {as there is no node with a value greater than 40}.
35 will be replaced by {40}, i.e. 40.
Step 1: I made a helper function where I passed the root node and 0, which worked as the sum in it.
Step 2: Made a base case: if the root is null, return.
Step 3: Went to the rightmost node of the tree, as the rightmost node is the only node that will have the highest value in the whole BST.
Step 4: Added the root's data to the sum variable, which was passed into the helper function.
Step 5: After adding the root's value to the sum variable, updated the current root's data with that sum.
Step 6: Called recursively on the left side of the tree by sending root. Left as the root node and the updated sum to the helper function.
If any character is a ‘?’ we can replace that character with any other character.
If a character is a * we can replace * with any sequence of characters including the empty sequence.
Let str = “abc?" and pat= “abcd”
We return true as ‘?’ can be replaced with ‘d’ and this makes ‘str’ and ‘pat’ same.
Create a frequency array, freq, to count the number of occurrences of each task. Sort the freq array in ascending order. Calculate the maximum frequency, maxFreq, of any task. Calculate the number of idle slots, idleSlots, required by the most frequent task, which is equal to (maxFreq - 1) * n. Iterate over the remaining tasks in descending order of frequency and subtract the minimum of maxFreq and the frequency of the task from idleSlots. If idleSlots is still positive, add it to the length of the input task list, tasks. Otherwise, return tasks.size().
1. Horizontally as 1x2 tile
2. Vertically as 2x1 tile
The number of ways might be large so output your answer modulo 10^9 + 7.
Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
How do you write a single-line comment in C++?