Asked inAmazon,Sdet-I

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!
Select
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
Amazon Sdet-I Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
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

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits