Reality check : leetcode 173

Oracle / Eng NUkX62
Jan 4 27 Comments

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?

Reality check : leetcode 173

comments

Want to comment? LOG IN or SIGN UP
TOP 27 Comments
  • IBM stupig
    There are so many Asian kids who can solve this problem just if you give the problem number.
    Jan 4 4
    • Oracle / Eng NUkX62
      OP
      I’m an asian kid too 😂😂
      Jan 4
    • Facebook exFOB
      Not Asian enough. Insert unimpressed Asian dad meme here.
      Jan 4
    • IBM stupig
      You don't deserve to be Asian.
      Jan 4
    • Intel UGeJ58
      If you take a 23&me, you will find the reason for your failures.
      Jan 4
  • Facebook pipirupiru
    So many runtime errors, so sloppy...
    Jan 4 0
  • Amazon / PR jefe_bezos
    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.
    Jan 4 1
    • Oracle / Eng NUkX62
      OP
      Yeah. Makes sense. Thanks
      Jan 4
  • Google / Eng chupanibre
    wtf is morris traversal?
    Jan 4 2
    • Oracle / Eng NUkX62
      OP
      It’s a way to iterate over trees that temporarily changes the tree structure and restores it back.
      Jan 4
    • Google / Eng chupanibre
      Sounds like some kind of bad hack and not thread safe, iteration should not need to mutate the data structure. I wouldn't want such a thing anywhere in prod
      Jan 4
  • Google / Eng omaewamou
    It should pass the test cases in the first try
    Jan 4 4
    • Microsoft / Eng Tier 1
      Really? Are you coding and compiling the thing locally before submitting?
      Jan 4
    • Google / Eng omaewamou
      Wut? You should be able to write the correct solution without any help from the compiler/interviewer or you won't pass the interview
      Jan 4
    • Google FcSg75
      At google 12 years. And most of the code I write won't compile the first time. Done over 500 interviews. And lot of the code won't compile - but people still pass the interview.
      Jan 4
    • Google / Eng omaewamou
      I'm not debating whether it is useful to have such expectations from the candidates when there is a huge difference between the work and the interviews.

      I have to disagree on most code won't compile part. I'm guessing your main language is Java or Cpp, that is fine for those languages. However, there shouldn't be any bugs in the code to get a good rating.

      You can get away with a bad interview if others were strong though
      Jan 4
  • Amazon / PR jefe_bezos
    Wut
    Jan 4 0
  • New cnFv14
    Binary search tree iterator was amazon easiest interview question.

    I doubt even google ask this. Are you experienced?
    Jan 4 3
    • Oracle / Eng NUkX62
      OP
      3 year. Just lost touch with the things. Didn’t do any competitive coding after college
      Jan 4
    • New cnFv14
      This may be your kickstart. I would suggest to start with leetcode topics learning first.

      Search, array, binary tree search etc.
      Jan 4
    • Oracle / Eng NUkX62
      OP
      Thanks. Will look into it
      Jan 4
  • Apple fu manchu
    It’s quite literally just the next Inorder traversal problem wrapped in an API. Easy as cake.
    Jan 4 2
    • eBay martinw
      Are you allowed to use stack or not? In that case it will also need a reference to parent.
      Jan 4
    • Apple fu manchu
      Of course you use a stack. The simples solution is really just about 7 lines of code.
      Jan 4
  • New DvVM00
    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.
    Jan 4 0
  • Microsoft / Eng zDz
    Keep practicing. This is a fairly easy problem.
    Jan 4 0
  • PayPal Jama
    Yes
    Jan 4 0

Salary
Comparison

    Real time salary information from verified employees