[문제풀기] 주식 가격
초 단위로 기록된 주식가격이 담긴 배열 prices가 매개변수로 주어질 때, 가격이 떨어지지 않은 기간은 몇 초인지를 return 하도록 solution 함수를 완성하세요. 제한사항 prices의 각 가격은 1 이상 10,000 이하인 자연수입니다. prices의 길이는 2 이상 100,000 이하입니다. 입력 예제 price return [1, 2, 3, 2, 3] [4, 3, 1, 1, 0] class Solution { public int[] solution(int[] prices) { int[] answer = new int[prices.length]; for(int i=0; i
공부
2021. 4. 23. 17:39
큐 구현하기
환형 큐 구현해보기 QueueInterface.java public interface QueueInterface { E put(E item); // 요소 추가 E get(); // 요소 삭제 } Queue.java import java.util.EmptyStackException; public class Queue implements QueueInterface { // 환형 큐 static final int defaultLength = 10; private Object[] array;// 요소를 담을 배열 private int front; // front private int rear; // rear Queue() { this.array = new Object[defaultLength]; this.fro..
공부
2021. 4. 22. 23:03
