there n friend play game the friend sit circle number 1 n clockwise order more formally move clockwise ith friend bring i1th friend 1 n move clockwise nth friend bring 1st friendthe rule game followsStart 1st friendCount k friend clockwise direction include friend start the counting wrap circle count friend oncethe friend count leave circle lose gameIf friend circle step 2 start friend immediately clockwise friend lose repeatElse friend circle win gamegiven number friend n integer k return winner game Example 1input n 5 k 2output 3explanation here step game1 start friend 12 Count 2 friend clockwise friend 1 23 friend 2 leave circle Next start friend 34 Count 2 friend clockwise friend 3 45 Friend 4 leave circle Next start friend 56 Count 2 friend clockwise friend 5 17 friend 1 leave circle Next start friend 38 Count 2 friend clockwise friend 3 59 friend 5 leave circle only friend 3 leave winnerexample 2input n 6 k 5output 1explanation the friend leave order 5 4 6 2 3 the winner friend 1 Constraints1 k n 500 Follow upcould solve problem linear time constant space