Tech IndustryJan 4, 2019
OracleNUkX62

Reality check : leetcode 173

I’m aiming google/fb london/zurich. The problem is to create an iterator for binary search tree. To solve this problem I’ve implemented morris traversal but it’s a bit tricky algo so took a lot of time to debug and make all testcases pass. Am i so far behind the hiring bar?

Facebook pipirupiru Jan 4, 2019

So many runtime errors, so sloppy...

Amazon jefe_bezos Jan 4, 2019

Wut

PayPal Jama Jan 4, 2019

Yes

Microsoft zDz Jan 4, 2019

Keep practicing. This is a fairly easy problem.

IBM stupig Jan 4, 2019

There are so many Asian kids who can solve this problem just if you give the problem number.

Oracle NUkX62 OP Jan 4, 2019

I’m an asian kid too 😂😂

Facebook exFOB Jan 4, 2019

Not Asian enough. Insert unimpressed Asian dad meme here.

Amazon jefe_bezos Jan 4, 2019

Creating an iterator vs simply iterating have different considerations. If you’re trying to do the former and are using traditional Morris traversal (without cloning the tree), you’re doing it wrong. Your tree is temporarily destroyed and unusable until you release the iterator. Did you create an iterator but now want to serialize your untouched tree? Nope, good luck with that. This is the difference between theory and practical application. Do it the normal way and use a stack like a real person.

Oracle NUkX62 OP Jan 4, 2019

Yeah. Makes sense. Thanks

New
cnFv14 Jan 4, 2019

Binary search tree iterator was amazon easiest interview question. I doubt even google ask this. Are you experienced?

Oracle NUkX62 OP Jan 4, 2019

3 year. Just lost touch with the things. Didn’t do any competitive coding after college

New
cnFv14 Jan 4, 2019

This may be your kickstart. I would suggest to start with leetcode topics learning first. Search, array, binary tree search etc.

Google omaewamou Jan 4, 2019

It should pass the test cases in the first try

Microsoft Tier 1 Jan 4, 2019

Really? Are you coding and compiling the thing locally before submitting?

Google omaewamou Jan 4, 2019

Wut? You should be able to write the correct solution without any help from the compiler/interviewer or you won't pass the interview

Apple fu manchu Jan 4, 2019

It’s quite literally just the next Inorder traversal problem wrapped in an API. Easy as cake.

eBay martinw Jan 4, 2019

Are you allowed to use stack or not? In that case it will also need a reference to parent.

Apple fu manchu Jan 4, 2019

Of course you use a stack. The simples solution is really just about 7 lines of code.

New
DvVM00 Jan 4, 2019

this isn’t out of practice, this is not at fang level. or degree level frankly. this is extremely basic stuff. it’s not a trick that depends on some trivial knowledge you wouldn’t normally have. it’s basic stuff.