package org.kyhslam; import java.util.Arrays; public class stack03 { public static int[] solution(int[] prices) { int[] answer = new int[prices.length]; for(int i=0; i prices[j]){ break; } } } System.out.println(Arrays.toString(answer)); return answer; } public static void main(String[] args) { int[] p =..
📚 Stack 클래스 Stack클래스는 List컬렉션 클래스의 Vector클래스를 상속받아, 전형적인 스택 메모리 구조의 클래스를 제공한다. 스택메모리 구조는 선형 메모리 공간에 데이터를 저장하면서 후입선출(LIFO)을 따르는 자료구조 이다. 가장 나중에 저장된(PUSH) 데이터가 가장 먼저 인출(POP)되는 구조이다. 메서드 설 명 boolean empty( ) Stack 이 비어있는지 알려줌 Object peek( ) Stack 의 맨 위에 저장된 객체를 반환 pop( ) 과 달리 Stack 에서 객체를 꺼내지 않음(비었을 때는 EmptyStackException 발생) Object pop( ) Stack 의 맨 위에 저장된 객체를 꺼냄(비었을 때는 EmptyStackException 발생) Obje..