스택이란?
📔 문제 설명
https://www.acmicpc.net/problem/17608
📝 문제 풀이
💡 내 코드
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;
public class Main {
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());
Stack<Integer> stack = new Stack<>();
int result=0;
int max=0;
int count=0;
for (int i = 0; i < N; i++) {
stack.push(Integer.parseInt(br.readLine())) ;
}
for (int i = 0; i < N; i++) {
max = stack.pop();
if(max>result) {
result = max;
count++;
}
}
System.out.println(count);
}
}
✍느낀점