注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
遇到了最近提到的新题,但是之前没有好好针对那个面经思考,结果写代码的过程中出现卡壳的状态,这道题写出来后有几个测试用例过不了,因为代码的粗心。
贴出来,希望帮的到其他的童鞋:
/**
You are reading a Build Your Own Story book. It is like a normal book except that choices on some pages affect the story, sending you to one of two options for your next page.
These choices are really stressing you out, so you decide that you'll either always pick the first option, or always pick the second option.
You start reading at page 1 and read forward one page at a time unless you reach a choice or an ending.
The choicces1, 2) => -1
findEnding(endings, choices2, 1) => 21
findEnding(endings, choices2, 2) => 30
findEnding(endings, choices3, 1) => 6
findEnding(endings, choices3, 2) => 6
findEnding(endings, choices4, 1) => -1
findEnding(endings, choices4, 2) => 15
//[4, 2]
1->2->3->4
**/
|