Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Day 225 #465

Closed
vaskoz opened this issue Apr 4, 2019 · 1 comment
Closed

Day 225 #465

vaskoz opened this issue Apr 4, 2019 · 1 comment
Assignees

Comments

@vaskoz
Copy link
Owner

vaskoz commented Apr 4, 2019

Good morning! Here's your coding interview problem for today.

This problem was asked by Bloomberg.

There are N prisoners standing in a circle, waiting to be executed. The executions are carried out starting with the kth person, and removing every successive kth person going clockwise until there is no one left.

Given N and k, write an algorithm to determine where a prisoner should stand in order to be the last survivor.

For example, if N = 5 and k = 2, the order of executions would be [2, 4, 1, 5, 3], so you should return 3.

Bonus: Find an O(log N) solution if k = 2.

@vaskoz vaskoz self-assigned this Apr 4, 2019
@vaskoz
Copy link
Owner Author

vaskoz commented Apr 4, 2019

@vaskoz vaskoz mentioned this issue Apr 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant