Tip 1 : Graph should be on your tips.
Tip 2 : While explaining the solution to the interviewer, don't just hop onto the most optimal solution. Start with the brute force one, give the cons of brute force solution, and then go step by step till you reach the optimal solution.
Tip 3 : Improve on your communication skills as well.
Tip 1 : Mention only what is required for your profile, for e.g. do not stress too much on your co curricular stuff. Rather, try explaining more of your technical stuff that is relevant for your job.
Tip 2 : Keep it limited to 1 page. And make sure its a pdf and not an image.
• 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.
It is guaranteed that a BST can be always constructed from the given preorder traversal. Hence, the answer will always exist.
From PREORDER = [20, 10, 5, 15, 13, 35, 30, 42] , the following BST can be constructed:
You have been given an array/list 'PREORDER' representing the preorder traversal of a BST with 'N' nodes. All the elements in the given array have distinct values.
Your task is to construct a binary search tree that matches the given preorder traversal.
A binary search tree (BST) is a binary tree data structure that 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.
Step 1 : First I converted the number into string and checked if each character is 0 or 1
Step 2 : The interviewer asked me if there is any other approach to solve this problem
Step 3 : I picked the approach of picking up the digit of integer from last and then checking whether that it is 0 or 1
Step 4 : If we get a digit other than 0/1 we will break the loop. The interviewer was happy with this approach.
Input: NUM[] = {1,1,1,2,2,2}
Output: {1,2,1,2,1,2}
Note: {2,1,2,1,2,1} is also valid because there are no two adjacent which are the same.
Tip 1 : I looked through the array and used a map to count frequency of each digit
Tip 1 : Practice preorder, postorder and inorder traversal questions of a tree
Tip 2 : Understand merge sort
Tip 3 : Have complete understanding of Radix sort
Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
One of the following is a selection statement, Which is it?