注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
本帖最后由 匿名 于 2021-10-1 13:07 编辑
前面的问题地里都有:
- find random line
- analyze complexity of finding 7's in a number
- analyze comlexity of set intersection O(n+m) and O(nlogm)
编程题:
**Question**: You are given story book, and you start reading from Page 1. A page can be a normal page, or a special page. At a normal page, you have to go to the next page; At a special page, you will be given two options [x, y] which you can directly jump to x or y. You will also be given a list of ending pages where you stop. Note that each option can only be used once in the entire storyline. Find the page that appears the most often in all possible storylines, and output both the pa valid storyline. This makes the complexity of O(n).
**Lesson**:
- It takes me a while to figure out the time complexity of the algorithm. I need more practice in analyzing backtracking algorithms.
- Whenever the interview asked if you want to optimize, it must be the case that there is something you can optimize in the algorithm! This is a strong hint!
|