Java446 [LeetCode/Java] Find Pivot Index -Codeclass Solution { public int pivotIndex(int[] nums) { int numsLength = nums.length; int left = 0, right = 0; // 피벗이 0이므로 1부터 더하기 for (int i = 1; i 2025. 12. 31. [LeetCode/Java] Find the Highest Altitude -Codeclass Solution { public int largestAltitude(int[] gain) { int nowHeight = 0; int maxHegiht = 0; for (int height : gain) { nowHeight += height; maxHegiht = Math.max(maxHegiht, nowHeight); } return maxHegiht; }} 2025. 12. 31. [LeetCode/Java] Maximum Average Subarray I -Codeclass Solution { public double findMaxAverage(int[] nums, int k) { int numsLength = nums.length; double nowSum = 0; double answer = 0; for (int i = 0; i 2025. 12. 31. [LeetCode/Java] Is Subsequence -Codeclass Solution { public boolean isSubsequence(String s, String t) { int sLength = s.length(); int idx = 0; // t를 돌면서 비교 for (char ch : t.toCharArray()) { // s의 전체 길이가 현재 인덱스와 같으면 true if (sLength == idx) { return true; } if (s.charAt(idx) == ch) { idx++; } } // t.. 2025. 12. 31. [LeetCode/Java] Move Zeroes -Codeclass Solution { public void moveZeroes(int[] nums) { int length = nums.length; int left = 0, right = 0; // 투포인터로 변경 for (int i = 0; i 2025. 12. 31. [LeetCode/Java] Two Sum -Codeimport java.util.*;class Solution { public int[] twoSum(int[] nums, int target) { int length = nums.length; // 숫자와 그에 인덱스 저장 Map numAndIdx = new HashMap(); for (int i = 0; i 무차별 대입으로 풀었으나 map으로 할 수있을거 같이서 해봤습니다. 다만 같은 수가 존재할때 계산을 안해서 틀렸었습니다. 2025. 12. 31. 이전 1 ··· 26 27 28 29 30 31 32 ··· 75 다음