✔ 내 답 -> 정답
stack
queue
import java.util.*;
public class Main{
public static int solution(int n, int k){
Queue<Integer> q = new LinkedList<>();
for(int i=1;i<=n;i++){
q.add(i);
}
int u=0;
while(q.size() > 1){
int v=q.poll();
u++;
if(u!=k) q.add(v);
else u=0;
}
int answer = q.poll();
return answer;
}
public static void main(String[] args){
Scanner kb = new Scanner(System.in);
int n=kb.nextInt();
int k = kb.nextInt();
System.out.println(solution(n,k));
}
}