From a2e0ac984fb8c73be64b2ec48cdb25ecbf8a2e9f Mon Sep 17 00:00:00 2001 From: LiiNi-coder <97495437+LiiNi-coder@users.noreply.github.com> Date: Thu, 13 Nov 2025 23:54:20 +0900 Subject: [PATCH] =?UTF-8?q?[20251113]=20PGM=20/=20LV2=20/=20=EC=A3=BC?= =?UTF-8?q?=EC=8B=9D=EA=B0=80=EA=B2=A9=20/=20=EC=9D=B4=EC=9D=B8=ED=9D=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...74\354\213\235\352\260\200\352\262\251.md" | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 "LiiNi-coder/202511/13 PGM \354\243\274\354\213\235\352\260\200\352\262\251.md" diff --git "a/LiiNi-coder/202511/13 PGM \354\243\274\354\213\235\352\260\200\352\262\251.md" "b/LiiNi-coder/202511/13 PGM \354\243\274\354\213\235\352\260\200\352\262\251.md" new file mode 100644 index 00000000..16b9a526 --- /dev/null +++ "b/LiiNi-coder/202511/13 PGM \354\243\274\354\213\235\352\260\200\352\262\251.md" @@ -0,0 +1,31 @@ +```java +import java.util.*; + +class Solution { + public int[] solution(int[] prices) { + int n = prices.length; + int[] answer = new int[n]; + ArrayDeque stack = new ArrayDeque<>(); + + for(int i= 0; i < n; i++){ + while(!stack.isEmpty()){ + if(prices[stack.peekLast()] > prices[i]){ + int index = stack.pollLast(); + answer[index] = i - index; + }else{ + break; + } + } + stack.offerLast(i); + } + + + while(!stack.isEmpty()){ + int idx = stack.pollLast(); + answer[idx] = n - 1 - idx; + } + return answer; + } +} + +```