diff --git "a/leetcode3/\354\235\264\354\247\204\355\235\254/26. Remove Duplicates from Sorted Array.java" "b/leetcode3/\354\235\264\354\247\204\355\235\254/26. Remove Duplicates from Sorted Array.java" new file mode 100644 index 00000000..1fa85138 --- /dev/null +++ "b/leetcode3/\354\235\264\354\247\204\355\235\254/26. Remove Duplicates from Sorted Array.java" @@ -0,0 +1,26 @@ +/* + +1. 아이디어 : + 문자열에서 중복된 원소를 빼고 재배치, 고유한 원소 크기 반환 + +2. 시간복잡도 : O(N) + +3. 자료구조/알고리즘 : 완전탐색 + + */ + +class Solution { + public int removeDuplicates(int[] nums) { + int prev = -200; + int idx = 0; + + // 오름차순 + for(int i : nums) { + if(i == prev) continue; + nums[idx++] = i; + prev = i; + } + + return idx; + } +} \ No newline at end of file diff --git "a/leetcode3/\354\235\264\354\247\204\355\235\254/522. Longest Uncommon Subsequence II.java" "b/leetcode3/\354\235\264\354\247\204\355\235\254/522. Longest Uncommon Subsequence II.java" new file mode 100644 index 00000000..d305fba9 --- /dev/null +++ "b/leetcode3/\354\235\264\354\247\204\355\235\254/522. Longest Uncommon Subsequence II.java" @@ -0,0 +1,46 @@ +/* + +1. 아이디어 : 모든 주어진 문자열중 중복된 부분문자열이 아닌 문자열중 가장 긴 문자열의 길이와 개수를 구한다. + +2. 시간복잡도 : O(N^2*N) + +3. 자료구조/알고리즘 : 투포인터, 완전탐색 + + */ + +class Solution { + public int findLUSlength(String[] strs) { + // 안겹치는 가장 긴 문자열의 길이 (모든 문자열 중) + + int ans = -1; + + // aba cdc eae + // aa aaa aaa + + for(int i=0; i strs[j].length()) continue; + + if(isSubsequence(strs[i], strs[j])) check = false; + } + + if(check) ans = Math.max(ans, strs[i].length()); + } + + return ans; + } + + private boolean isSubsequence(String s1, String s2) { + int idx1 = 0; + int idx2 = 0; + + while(idx1