프로그래머스에서 풀때 어쩔수 없이 class를 썻던 기억이 있는데 실제로 id값을 줘서 푸네요.
public class Main {
public int solution(int[] arr, int k) {
Queue<Person> queue = new ArrayDeque<>();
for (int i = 0; i < arr.length; i++) queue.offer(i == k ? new Person(-1, arr[i]) : new Person(arr[i]));
int day = 1;
while (!queue.isEmpty()) {
Person p = queue.poll();
int emergency = Integer.parseInt(String.valueOf(queue.stream().filter(x -> x.number > p.number).count()));
if (emergency == 0 && p.id != -1) day++;
else if (emergency == 0 && p.id == -1) return day;
else queue.add(p);
}
return day;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int k = sc.nextInt();
int[] arr = new int[n];
for (int i = 0; i < n; i++) arr[i] = sc.nextInt();
System.out.println(new Main().solution(arr, k));
}
}