Question: PYTHON You are using a browser to visit web pages. e.g. page1 -> page2 -> page3 -> page4 -> page5 (single thread page view) This

PYTHON

You are using a browser to visit web pages. e.g. page1 -> page2 -> page3 -> page4 -> page5 (single thread page view) This gives a list like so: [ [page1, page2], [page2, page3], [page3, page4], [page4, page5], ] Now we shuffle the list: [ [page2, page3], [page1, page2], [page4, page5], [page3, page4], ] Return a pair of strings indicating the first and last page you visited: ["page1", "page2"] FOLLOW UP: There are some cases where you cannot determine what page you started with: page1 -> page2 -> page3 -> page4 -> page5 -> page1 You could start at any of the pages But there are also cases where you can determine where you started page1 -> page2 -> page3 -> page4 -> page5 -> page1 -> page5 (single thread page view) Input: [ [page3, page4], [page4, page5], [page1, page2], [page2, page3], [page5, page1], [page1, page5], ] The only possible answer is ["page1", "page5"] (because the indegree of page 1 < outdegree of page1) (and the indegree of page 2 >= outdegree of page 2) Handle this case as well

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!