zhedahht / CodingInterviewChinese2

《剑指Offer:名企面试官精讲典型编程面试题》第二版源代码
Other
5.32k stars 2.17k forks source link

Changes for question 07. #24

Open OOCZC opened 6 years ago

OOCZC commented 6 years ago
while(rootInorder <= endInorder && *rootInorder != rootValue)
    ++ rootInorder;

if(rootInorder == endInorder && *rootInorder != rootValue)
    throw std::exception("Invalid input.");

rootInorder == endInorder && *rootInorder != rootValue时会继续++ rootInorder;,此时应该为无效输入,缺不能符合rootInorder == endInorder的判断条件。

则修改为: while(rootInorder < endInorder && *rootInorder != rootValue) ++ rootInorder;