본문 바로가기

Algorithm/코드 풀이

(183)
LeetCode: 92번 (Reverse Linked List II) [JAVA] 문제 링크 https://leetcode.com/problems/reverse-linked-list-ii/ Reverse Linked List II - LeetCode Can you solve this real interview question? Reverse Linked List II - Given the head of a singly linked list and two integers left and right where left
LeetCode: 91번 (Decode Ways) [JAVA] 문제 링크 https://leetcode.com/problems/decode-ways/ Decode Ways - LeetCode Can you solve this real interview question? Decode Ways - A message containing letters from A-Z can be encoded into numbers using the following mapping: 'A' -> "1" 'B' -> "2" ... 'Z' -> "26" To decode an encoded message, all the digits must be grouped then leetcode.com 풀이 전체적인 풀이 과정은 다음과 같다. 메모제이션을 위한, 주어진 문자열 s 길이만큼의 int 배열..
LeetCode: 90번 (Subsets II) [JAVA] 문제 링크 https://leetcode.com/problems/subsets-ii/ Subsets II - LeetCode Can you solve this real interview question? Subsets II - Given an integer array nums that may contain duplicates, return all possible subsets (the power set). The solution set must not contain duplicate subsets. Return the solution in any order. Example leetcode.com 풀이 전체적인 풀이 과정은 다음과 같다. 결과를 담을 List 리스트 생성 후, 초기 공집합 List 추가 주..
LeetCode: 89번 (Gray Code) [JAVA] 문제 링크 https://leetcode.com/problems/gray-code/ Gray Code - LeetCode Can you solve this real interview question? Gray Code - An n-bit gray code sequence is a sequence of 2n integers where: * Every integer is in the inclusive range [0, 2n - 1], * The first integer is 0, * An integer appears no more than once in the sequence, leetcode.com 풀이 전체적인 풀이 과정은 다음과 같다. 결과를 담을 List 생성 후, 초기값 0 추가 주어진 n번에 대해..
LeetCode: 87번 (Scramble String) [JAVA] 문제 링크 https://leetcode.com/problems/scramble-string/ Scramble String - LeetCode Can you solve this real interview question? Scramble String - We can scramble a string s to get a string t using the following algorithm: 1. If the length of the string is 1, stop. 2. If the length of the string is > 1, do the following: * Split the string leetcode.com 풀이 전체적인 풀이 과정은 다음과 같다. 주어진 문자열 a, b를 계속 분할하는 재귀함..
LeetCode: 86번 (Partition List) [JAVA] 문제 링크 https://leetcode.com/problems/partition-list/ Partition List - LeetCode Can you solve this real interview question? Partition List - Given the head of a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the original relative order of the no leetcode.com 풀이 전체적인 풀이 과정은 다음과 같다. 주어진 x보다 작은 노드 리스트를 위한 임시 헤더..
LeetCode: 84번 (Largest Rectangle in Histogram) [JAVA] 문제 링크 https://leetcode.com/problems/largest-rectangle-in-histogram/ Largest Rectangle in Histogram - LeetCode Can you solve this real interview question? Largest Rectangle in Histogram - Given an array of integers heights representing the histogram's bar height where the width of each bar is 1, return the area of the largest rectangle in the histogram. Example leetcode.com 풀이 전체적인 풀이 과정은 다음과 같다...
LeetCode: 82번 (Remove Duplicates from Sorted List II) [JAVA] 문제 링크 https://leetcode.com/problems/remove-duplicates-from-sorted-list/ Remove Duplicates from Sorted List - LeetCode Can you solve this real interview question? Remove Duplicates from Sorted List - Given the head of a sorted linked list, delete all duplicates such that each element appears only once. Return the linked list sorted as well. Example 1: [https://assets.le leetcode.com 풀이 전체적인 풀이 과정..