Welcome to LeetCode Discuss.  Please read the FAQ to help yourself making the best use of Discuss.
Ask a Question
Back to Problem

Welcome to LeetCode Discuss.

This is a place to ask questions related to only OJ problems.

Please read the FAQ to help yourself making the best use of Discuss.

Format of OJ binary trees?

0 votes
31 views

I know there was a specification how trees used for OJ input data are represented as an array, but I can't seem to find it anywhere. Is there a link? If I have a tree

        5
      /   \
    4     7
  /       /
 3      6

would an array representation be {5, 4, 7, 3, #, 6, #}?

Is there perhaps an already made java parser for that? :)

asked 4 days ago in Path Sum by princessmaja (450 points)

2 Answers

0 votes
 
Best answer

Here it is.

answered 3 days ago by Shangrila (4,330 points)
selected 3 days ago by princessmaja
0 votes

No. the array should be {5, 4, 7, 3,#, 6,#}. The result is traverse the tree by level.

answered 4 days ago by chentao169 (1,190 points)
edited 3 days ago by chentao169

No, your answer is wrong.

I made a mistake. I have updated my answer.

That is the same thing I wrote :)

Oh, my mind was not clear then....sorry


...