id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

tmhscs@gmail.com josephus > list_josephusSolver
prev  |  next  |  chance

Given a List of people (integers) numbered starting with 1, and a skip number "s", return the final spot that will be surviving if they play the Josephus elimination game. This time, your solution needs to call list.remove(#) to remove eliminated players from the game. Once the list is size 1, you can return list.get(0) which should have the spot number of the final survivor!


list_josephusSolver([1, 2], 2) → 1
list_josephusSolver([1, 2, 3], 2) → 3
list_josephusSolver([1, 2, 3, 4], 2) → 1

...Save, Compile, Run (ctrl-enter)

public int list_josephusSolver(List<Integer> list, int s) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Post-solution available

Copyright Nick Parlante 2017 - privacy