Questions › Technical PM › Top-Interview
Find the sum of all elements in a binary tree that fall within the range [low, high], where 'low' and 'high' are integers.
- Technical PM
- Top-Interview
- Easy
- 10 min
Focus on implementing a depth-first search (DFS) or breadth-first search (BFS) algorithm to traverse the binary tree. As you traverse, check if each node's value falls within the specified range [low, high]. If it does, add it to a cumulative sum. Be prepared to discuss edge cases, such as an empty tree or all nodes falling outside the range, and how your solution handles them. Additionally, consider the time complexity of your approach and how it can be optimized.
What this question tests
- Technical PM
- Structured problem solving
- Communication
- Trade-off reasoning
Practise this question under interview conditions. Answer it out loud against a timer with an AI interviewer that asks follow-ups, then review the scored report.
Related Technical PM questions
- Tree Node.Top-Interview · Technical PM · Easy
- Is this a valid palindrome?Top-Interview · Technical PM · Easy
- Find the first missing positive number in an array.Top-Interview · Technical PM · Easy
- Find the number of users who called three or more people in the last week.Top-Interview · Technical PM · Easy
- What percentage of users who were active on Messenger yesterday made a video call yesterday?Top-Interview · Technical PM · Easy
- Design a web service for asynchronous communication.Top-Interview · Technical PM · Easy
All Technical PM questions · Product manager interview questions by skill area