string
-
[string] valid palindromeAlgorithm/LeetCode 2025. 3. 8. 11:05
✅ Problemhttps://leetcode.com/problems/valid-palindrome/description/ ✅ Approach & Solution방식)더보기주어진 문자열만 사용해 비교Character 클래스의 isLetterOrDigit(), toLowerCase()String 클래스의 charAt()투 포인터 사용해 문자열의 앞, 뒤 비교 class Solution { public boolean isPalindrome(String s) { // 조건 // 대소문자 상관 X // 문자 or 숫자 // 앞에서 읽었을 때, 뒤에서 읽었을 때 동일 boolean result = true; int start = 0;..
-
[array] 3sumAlgorithm/LeetCode 2025. 2. 1. 15:01
✅ Problemhttps://leetcode.com/problems/3sum/description/ ✅ Approach & Solution방식) 정렬 후 투 포인터 사용더보기3개를 찾아야 할 때 : 1개는 고정해두고 나머지 2개를 찾자나머지 2개 찾을 때 투 포인터 사용정렬 필수 (배열의 인덱스 값 활용하지 않기 때문에 정렬 가능)class Solution { public List> threeSum(int[] nums) { int left, right, sum; List> results = new ArrayList(); Arrays.sort(nums); for (int i = 0; i 0 && nums[i] == nums[i-1]) { ..