Hello LeetCoders!
I had Google Onsite interviews yesterday for L3 SWE Seattle.
Could you please help me solve this problem:
Given a perfect binary tree where the values are sorted from top to bottom and left to right and a target value, write function to check if value exists in the perfect binary tree.
e.g.:
1
/ |
2 3
/ \ / |
4 10 20 30
target = 5
return false
Interviewer wanted a better approach than O(N). I assume we can use binary search to achieve O(logN) but could not figure out how it would work.
Please comment your approach/ solutions/ link to problem statement if you've seen it on LC or other platform.
Thanks