nikunjsoni

1823

Apr 12th, 2021
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.19 KB | None | 0 0
  1. class Solution {
  2. public:
  3.     int findTheWinner(int n, int k) {
  4.         int res = 0;
  5.         for (int i = 1; i <= n; ++i)
  6.             res = (res + k) % i;
  7.         return res + 1;
  8.     }
  9. };
Advertisement
Add Comment
Please, Sign In to add comment