Ad
  • Custom User Avatar

    Thank you cosmoskey, you can even join the map and joinToString together

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    I guess the type of n should be changed to long to fulfill 1  ≤  n  ≤  10000000000. Since int can only hold values up to 2147483647.
    Also method names starting with an uppercase letter is unusual. I propose to change it to the following for Java

    public class Line {
        public static String whoIsNext(String[] names, long n) {
            // Your code is here...
        }
    }
    

    Another point is that you actually access static methods in Java without an instance of Line. You would also have to change the type of n if you apply my suggestion from above.

    ...
    public class ListTests {
        @Test
        public void test1() {
            String[] names = new String[] { "Sheldon", "Leonard", "Penny", "Rajesh", "Howard" };
            long n = 1L;  
            assertEquals("Sheldon", Line.whoIsNext(names, n));
        }
    ...