标签:art tar procedure node color ble single from ram
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
标签:art tar procedure node color ble single from ram
原文地址:http://www.cnblogs.com/EdwardLiu/p/6189007.html