분류 전체보기(256)
-
[리트코드] 131. Palindrome Partitioning 회문
131. Palindrome Partitioning문제https://leetcode.com/problems/palindrome-partitioning/description/더보기Example 1:Input: s = "aab"Output: [["a","a","b"],["aa","b"]] Example 2:Input: s = "a"Output: [["a"]] Constraints:1 s contains only lowercase English letters. 접근 방법 ➡️ 백트래킹1. 현재 탐색 중인 문자열의 인덱스가 문자열의 길이와 동일한 경우 결과에 담는다.2. 두 개의 포인터인 start와 end를 사용하여 중간으로 이동하면서 문자열이 회문인지 확인한다. 코드 구현실패 코드class Solution ..
2024.07.26 -
[리트코드] 704. Binary Search - 반복분, 재귀 풀이
704. Binary Search문제https://leetcode.com/problems/binary-search/description/더보기Example 1:Input: nums = [-1,0,3,5,9,12], target = 9Output: 4Explanation: 9 exists in nums and its index is 4 Example 2:Input: nums = [-1,0,3,5,9,12], target = 2Output: -1Explanation: 2 does not exist in nums so return -1 Constraints:1 -104 All the integers in nums are unique.nums is sorted in ascending order. 문제 분석• n..
2024.07.26 -
[리트코드] 79. Word Search
79. Word Search문제https://leetcode.com/problems/word-search/description/ 더보기Example 1:Input: board = [["A","B","C","E"],["S","F","C","S"],["A","D","E","E"]], word = "ABCCED"Output: true Example 2:Input: board = [["A","B","C","E"],["S","F","C","S"],["A","D","E","E"]], word = "SEE"Output: true Example 3:Input: board = [["A","B","C","E"],["S","F","C","S"],["A","D","E","E"]], word = "ABCB"Output: f..
2024.07.25 -
[리트코드] 46. Permutations 순열, 77. Combinations 조합, 78. Subsets 부분집합
46. Permutations 순열문제https://leetcode.com/problems/permutations/description/더보기Example 1:Input: nums = [1,2,3]Output: [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]] Example 2:Input: nums = [0,1]Output: [[0,1],[1,0]] Example 3:Input: nums = [1]Output: [[1]] Constraints:1 -10 All the integers of nums are unique. 접근 방법주의사항• 순서가 다르면 다른 것으로 인식한다 • 예를 들어, {1,2}와 {2,1}은 다른 것으로 간주하며, 둘 다 선택 가능하다. • ..
2024.07.19 -
[리트코드] 1. Two Sum
문제https://leetcode.com/problems/two-sum/더보기Example 1:Input: nums = [2,7,11,15], target = 9Output: [0,1] Explanation: Because nums[0] + nums[1] == 9, we return [0, 1]. Example 2:Input: nums = [3,2,4], target = 6Output: [1,2] Example 3:Input: nums = [3,3], target = 6Output: [0,1] Constraints:2 -109 -109 Only one valid answer exists.접근 방법아이디어문제에서 오직 1가지 답만 존재한다고 했기에 중복 정답은 존재하지 않는다. 모든 경우를 조사해야 하므로..
2024.07.17 -
[데브툰] 리팩토링: 쿠키 결제 로직 4단계로 개선하기 (feat. 원시값 포장)
이번 포스팅에서는 결제 로직을 4단계에 걸쳐 점차적으로 개선하는 과정을 소개할 예정입니다. 해당 글을 마지막으로 데브툰 프로젝트를 1차적으로 마무리할 계획인데요. 왜냐하면 이력서와 포트폴리오 작업이 밀렸기 때문입니다.(미-소) 어느 정도 정리가 되면 팀원과의 회의를 통해 2차 작업(프론트 작업, 배포 및 운영, 조회 성능 최적화)을 이어서 진행할 예정입니다. 앞으로의 글은 가독성을 위해 말을 편하게 할 예정입니다. 양해 부탁드립니다. 🍎🍎🍎목차문제 상황문제 코드리팩토링 후보군 분석 후보1: 원시값으로 포장 → Price 클래스 후보2: 다양한 숫자 형식을 처리하기 위한 몇 가지 인터페이스 및 클래스 분석 → 적용 해결: (원시)값 타입 클래스 도입 코드 변화 4단계 및 관련 PR회고 만족한 ..
2024.05.20