Sde Interview Questions

16,590 sde interview questions shared by candidates

Two nodes in a binary search tree are swapped. We are supposed to find those two nodes, without any extra space (not even recursion) and O(N) TC. I was not able to come up with an approach without extra space. After around half hour of trying, he asked me to provide a solution which can use extra space. I gave it and he asked me to explain the whole working of the algorithm, step by step.
avatar

SDE-1

Interviewed at Amazon

3.5
Jan 2, 2020

Two nodes in a binary search tree are swapped. We are supposed to find those two nodes, without any extra space (not even recursion) and O(N) TC. I was not able to come up with an approach without extra space. After around half hour of trying, he asked me to provide a solution which can use extra space. I gave it and he asked me to explain the whole working of the algorithm, step by step.

Viewing 231 - 240 interview questions

Glassdoor has 16,590 interview questions and reports from Sde interviews. Prepare for your interview. Get hired. Love your job.