✔나의 답->맞음
import java.util.*;
public class p2_2 {
public static int solution(int n, int[] arr) {
int cnt =0;
int max = 0;
for(int i=0;i<n;i++){
if(arr[i]>max) {
cnt++;
max=arr[i];
}
}
return cnt;
}
public static void main(String[] args){
Scanner kb = new Scanner(System.in);
int n = kb.nextInt();
int[] arr = new int[n];
for(int i=0;i<n;i++){
int index = kb. nextInt();
arr[i]=index;
}
System.out.println(solution(n,arr));
}
}
✔️ 강의와 답이 같음