Why answer for [1,null,1] is 1?


  • 2
    S

    Why answer for [1,null,1] is 1?

    The tree is:

    1
      \
       1
    

    The last row has no left element. The question said return the left most element in the last row. The root node is not in the last row.


  • 0
    X

    I think leftmost means the first node visited (using BFS) in this level. It doesn't have to be a left node. But I agree it's a bit confusing.


  • 0
    S

    My original implementation was to return the left most node in the deepest level (not necessarily the last row). Then I re-read the question and it says last row and I changed my implementation. And also I wasn't sure what to return if there is no left nodes in the last row. I just wasted my time on this question. It sucks that I cannot ask question during the contest (I can't, right?).


  • 0

    @shellcodeloaded said in Why answer for [1,null,1] is 1?:

    It sucks that I cannot ask question during the contest (I can't, right?).

    You mean that you don't know how to ask, or that you're not allowed to?


  • 0
    S

    I had the same issue. not clear question description


  • 0
    S

    @StefanPochmann Hi, I assume I can't because I thought we are not allowed to post to the discussion forum during the contest. But I just re-read the FAQ and saw that we are not allowed to post solution to the discussion forum so I guess this means we can post question to clarify the problems?

    Also do you know how to bring up the tree visualizer? I don't know what I did but out of the blue I saw the tree visualizer. In the beginning I didn't know what the tree would look like based on array input. Then I saw the tree visualizer and it helped me to understand the array input. But I don't really know how to bring that up again whenever I need it.

    Argh, I just saw that we were given extra 10 minutes because of the compile error.

    Another question, I don't know how to find the contest problems again. Are we not allowed to access them after the contest? I am not familiar with this website. Thanks.


  • 0

    @shellcodeloaded I'd say clarification questions are ok. Just don't expect an answer if your lack of understanding is deemed to be your own fault for not reading or thinking properly :-) And of course the question shouldn't include your code or algorithm ideas or so, stuff that shouldn't be posted during the contest.

    The tree visualizer I think should pop up when you click into the test case field (so your cursor is there and you can edit the test case).

    I think you should be able to see the contest problems by going through the "Contest" menu item in the top menu (not the "Problems" menu item, where the problems appear with some delay).

    in the deepest level (not necessarily the last row)

    I don't see the difference. Deepest level and last row are the same, no?


  • 0
    A

    I also think this question is slightly ambiguous. leftmost must be clarified by additional examples especially when the title is Find Bottom Left Tree Value


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.