Algorithm/LeetCode (13) 썸네일형 리스트형 LeetCode 5. Longest Palindromic Substring 문제 링크: leetcode.com/problems/longest-palindromic-substring/ Longest Palindromic Substring - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문제 요약: 가장 긴 Palindromic(앞뒤로 읽어도 같은문자)를 반환하시오. 문제 접근: 단순히 루프를 돌면서 앞뒤 char를 뽑아서 비교했다. class Solution { public String longestPalindrome(String s).. LeetCode 83. Remove Duplicates from Sorted List 문제 링크: leetcode.com/problems/remove-duplicates-from-sorted-list/ Remove Duplicates from Sorted List - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문제 요약: 정렬된 순서로 링크드리스트가 주어질때, 중복된 원소를 뺀 링크드리스트를 반환 하시오. 문제 접근: 정렬되있기 때문에, 바로 직전값이랑만 비교하면 된다. 생각은 쉽지만 코드를 처음 작성할때는 잘 안됬었다. /** * Defin.. LeetCode 67. Add Binary 문제 링크: leetcode.com/problems/add-binary/ Add Binary - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문제 요약: 두개의 이진수가 문자열 형태(String)으로 주어질 때, 두 수를 더한 값을 출력하시오. (문자열 형태, 이진수형태) 문제 접근: 두 수를 더하는 문제는 보통 overflow만 조심하면 쉽다. 이진수이기 때문에, 맨 끝부터 하나씩 더하면 된다. class Solution { public String addB.. LeetCode 38. Count And Say 문제링크: leetcode.com/problems/count-and-say/ Count and Say - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문제 요약: 숫자가 주어질때, 숫자에 대한 String 을 출력. (아래 예제 참고) 예: 1 => "1" (default) 2 => 이전값을 세고, 읽는다. (1을 호출, 한개의 1 => "11") 3 => 이전값(2)을 세고, 읽는다. (2를 호출("11") => 2개의 1 => "21") 4 => 이전값(3.. LeetCode 278. First Bad Version 문제 링크: leetcode.com/problems/first-bad-version/ First Bad Version - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문제 요약: n 이 주어질때, 최초로 불량이 나는 n을 찾아라. isBadVersion(int n)이라는 메소드는 주어진다. 만약 3이 불량(false)이면 3부터 n까지는 모드 불량, 즉 1~n 중에서 최초로 isBadVersion(n)이 false인 수를 찾는문제. 문제 접근: for문으로 1.. LeetCode 35. Search Insert Position 문제링크: leetcode.com/problems/search-insert-position/ Search Insert Position - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문제 요약: 정렬된 숫자배열(nums)와 숫자값(target)이 주어졌을때, target이 들어갈 index 위치를 구하시오. 문제 접근: 단순한 정렬문제이다. 시간복잡도 O(n)으로 풀었는데, 조건 잘 맞춰서 루프한번 돌면 끝낼 수 있다. 좀 더 효율적으로는, 배열이 정렬되어있기.. LeetCode 28. Implement strStr() 문제링크: leetcode.com/problems/implement-strstr/ Implement strStr() - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문제요약: 문자열이 2개 주어진다. (haystack, needle) haystack문자열 중에서 needle과 일치하는 첫번째 index를 반환하시오. 없다면 -1 반환. 예: haystack: hello, needle: ll -> 2 문제 접근: haystack을 루프 돌면서 needle갯수만큼.. LeetCode 26. Remove Duplicates from Sorted Array 문제링크: leetcode.com/problems/remove-duplicates-from-sorted-array/ 문제 요약: (문제 이해하는게 제일 오래걸렸다.) 정렬된 배열이 주어졌을때, 주어진 배열을 바꾸고(중복을 다 제거하고), 중복아닌 원소 갯수 반환. * 부연설명: 주어진 배열이 [1,1,2,2,3] 이면 중복을빼면 [1,2,3] 인데, 주어진 배열 자체를 [1,2,3,2,3] 뒷인덱스는 신경안쓴다고함. 이런식으로 바꾸고 중복아닌 원소 갯수를 return; 예: [1,1,2] -> [1,2] (내가푼 방식되로 한다면, 원래 배열은 [1,2,2] 이렇게 되있음) 예: [0,0,1,1,1,2,2,3,3,4] -> [0,1,2,3,4] (마찬가지로 원래 배열은 [0,1,2,3,4,2,2,3,3,4.. 이전 1 2 다음 목록 더보기