Josephus Survivor Time : Space : 123456789#include <bits/stdc++.h>using namespace std;int josephusSurvivor(int n, int k) { int res = 0; for(int i = 1; i <= n; i++) { res = (res + k) % i; } return res + 1;}