leetcode40 [LeetCode/Java] Daily Temperatures -Codeclass Solution { public int[] dailyTemperatures(int[] temperatures) { int length = temperatures.length; int[] answer = new int[length]; Stack stack = new Stack(); for (int i = 0; i 2025. 11. 27. [LeetCode/Java] Final Prices With a Special Discount in a Shop -Codeclass Solution { public int[] finalPrices(int[] prices) { int pricesLength = prices.length; for (int i = 0; i = prices[j]) { prices[i] = prices[i] - prices[j]; break; } } } return prices; }} 2025. 11. 27. [LeetCode/Java] Exclusive Time of Functions -Codeclass Solution { public int[] exclusiveTime(int n, List logs) { Stack stack = new Stack(); int[] answer = new int[n]; int prev = 0; for (String log : logs) { // 로그를 :를 기준으로 나눔 String[] el = log.split(":"); int func = Integer.parseInt(el[0]); String type = el[1]; int timeStamp = Integer.parseInt(el[2]); .. 2025. 11. 27. [LeetCode/Java] Evaluate Reverse Polish Notation -Codeclass Solution { public int evalRPN(String[] tokens) { Stack stack = new Stack(); List operators = List.of("+", "-", "*", "/"); for (String token : tokens) { // 토큰이 연산자인 경우 if (operators.contains(token)) { int useNum = stack.pop(); int nowNum = stack.pop(); stack.push(calc(token, nowNum, useNum)); .. 2025. 11. 26. [LeetCode/Java] Build an Array With Stack Operations -Codeclass Solution { public List buildArray(int[] target, int n) { List answer = new ArrayList(); int targetLength = target.length; int targetIndex = 0; for (int now = 1; now = targetLength) { break; } // 일단 리스트에 들어감 answer.add("Push"); // 타겟 인덱스랑 다르면 Pop하고 다음 숫자 찾기 if (target[targetIndex] != no.. 2025. 11. 26. [LeetCode/Java] Find All Numbers Disappeared in an Array class Solution { public List findDisappearedNumbers(int[] nums) { int numsLength = nums.length; boolean[] numsCheck = new boolean[numsLength + 1]; List answer = new ArrayList(); for (int num : nums) { numsCheck[num] = true; } for (int i = 1; i 2025. 11. 24. 이전 1 2 3 4 ··· 7 다음