Given a binary tree, count the number of occurrences where there are two nodes with the same horizontal distance. To make it clearer, if we assume each node in a cell of a matrix, then count the number of occurrences when there is a collision of two nodes in the same cell. Here the count is 1 because 5 and 6 occupy the same cell in the matrix

AnswerBot
2y
Count occurrences of two nodes with same horizontal distance in a binary tree
Traverse the tree using BFS or DFS and keep track of horizontal distance of each node
Store nodes with same horizontal dista...read more
Help your peers!
Add answer anonymously...
Amazon Sdet-I interview questions & answers
A Sdet-I was asked Q. Given a number, find the nearest perfect square using a modified binary search a...read more
A Sdet-I was asked Q. Write some test methods for stress testing of the Furniture class.
A Sdet-I was asked Q. What factors would you consider from both a developer's and user's perspective w...read more
Popular interview questions of Sdet-I
A Sdet-I was asked Q1. Given a number, find the nearest perfect square using a modified binary search a...read more
A Sdet-I was asked Q2. Write some test methods for stress testing of the Furniture class.
A Sdet-I was asked Q3. What factors would you consider from both a developer's and user's perspective w...read more
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

