careercup / CtCI-6th-Edition

Cracking the Coding Interview 6th Ed. Solutions
11.33k stars 4.41k forks source link

Q4_10_Check_Subtree serializing mistake #226

Open navimakarov opened 2 years ago

navimakarov commented 2 years ago

https://github.com/careercup/CtCI-6th-Edition/blob/59018cfcb90292209275db1c4b3ed306d4b07d7f/Java/Ch%2004.%20Trees%20and%20Graphs/Q4_10_Check_Subtree/QuestionA.java#L23

There should be a delimiter, because 11 1 2 1 2

AND 1 11 2 1 2

Are serialized exactly the same way -> "1111XXX2X2XX" But adding a delimiter will serialize them as

  1. "11 1 1 XXX2 X2 XX"
  2. "1 11 1 XXX2 X2 XX"