Bloomberg面经准备: Josephus problem
Posted neverlandly
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Bloomberg面经准备: Josephus problem相关的知识,希望对你有一定的参考价值。
Given a circular single linked list.Write a program that deletes every kth node until only one node is left. After kth node is deleted, start the procedure from (k+1)th node. e.g.list is 1->2->3->4->5->1 k=3 1. You are at 1, delete 3. List is: 1->2->4->5->1 2. You are at 4, delete 1 List is: 2->4->5->2 3. You are at 2,delete 5 List is: 2->4->2 4. You are at 2, delete 2 List is: 4 Return 4. How efficient you can do it?
以上是关于Bloomberg面经准备: Josephus problem的主要内容,如果未能解决你的问题,请参考以下文章