is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.
CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.
Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.
Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.
If we can modify each node in BST, it is easy; but I am not sure about this since the size of BST is huge (more than 0.1 million).
- bruceyhkim February 21, 2016Step 1. For each node, we add (min:minimum of subtree where root is this node, max:maximum of subtree where root is this node, count:# of all nodes in the subtree)
Step 2. Do breadth-first search from root to find a node (i.e., sub-tree) where x <= min and max <= y, and return this node's count.
For step 1, the data structure looks like this
E.g., Node (min, max, count)
2 (1, 3, 2)
1 (1, 1, 1) 3 (3,3,1)
and recursively update min, max, count by in-order traverse
For step 2, BFS will work for finding the largest subtree that satisfies the condition (i.e., all sub nodes should be between x and y).