Example 1:Input: nums = 2,7,11,15, target = 9Output: 0,1Output: Because nums0 + nums1 == 9, we return 0, 1.Example 2:Input: nums = 3,2,4, target = 6Ou
Input:1,2,3Output:3Explanation:Only three moves are needed (remember each move increments two elements):1,2,3 => 2,3,3 => 3,4,3 => 4,4,41 <=
Input: "aba"Output: TrueInput: "abca"Output: TrueExplanation: You could delete the character 'c'.The string will only contain lowercase characters a-z
Input: version1 = "1.01", version2 = "1.001"Output: 0Explanation: Ignoring leading zeroes, both "01" and "001" represent the same integer "1".Input: v
Input: strs = "flower","flow","flight"Output: "fl"Input: strs = "dog","racecar","car"Output: ""Explanation: There is no common prefix among the input
n = 15,Return: "1", "2", "Fizz", "4", "Buzz", "Fizz", "7", "8", "Fizz", "Buzz", "11", "Fizz", "13", "14",
Input: "A man, a plan, a canal: Panama"Output: trueInput: "race a car"Output: falses consists only of printable ASCII characters.즐건 주말 ~.~
Input: "9001 discuss.leetcode.com"Output: "9001 discuss.leetcode.com", "9001 leetcode.com", "9001 com"Explanation: We only have one website domain: "d
Input: 1->2Output: falseInput: 1->2->2->1Output: true~.~
Example 1:Input: nums = -2,1,-3,4,-1,2,1,-5,4Output: 6Explanation: 4,-1,2,1 has the largest sum = 6.Example 2:Input: nums = 1Output: 1Example 3:Input:
Input: logs = "dig1 8 1 5 1","let1 art can","dig2 3 6","let2 own kit dig","let3 art zero"Output: "let1 art can","let3 art zero","let2 own kit dig","di
Example 1:Input: 1->2->3->4->5->NULLOutput: 5->4->3->2->1->NULLExample 2:Input: words = "word","world","row", order = "worldabcefghijkmnpqstuvxyz"Outp
Input: 1->2->3->4->5->NULLOutput: 5->4->3->2->1->NULLclass를 사용하여 node 객체를 표현변수에 object를 할당하면 값이 아니라 주소를 참조^~^
Example 1:Input: s = "()"Output: trueExample 2:Input: s = "()\[]{}"Output: trueExample 3:Input: s = "(]"Output: falseExample 4:Input: s = "()"Output:
Example 1:Input: prices = 7,1,5,3,6,4Output: 5Explanation: Buy on day 2 (price = 1) and sell on day 5 (price = 6), profit = 6-1 = 5.The answer is not
Example 1:Input: x = 123Output: 321Example 2:Input: x = -123Output: -321Example 3:Input: x = 120Output: 21Example 4:Input: x = 0Output: 0int형 자료구조 내에서
Input: n = 2Output: 1Explanation: F(2) = F(1) + F(0) = 1 + 0 = 1.Input: n = 3Output: 2Explanation: F(3) = F(2) + F(1) = 1 + 1 = 2.Input: n = 4Output:
Input: 0,1,0,3,12Output: 1,3,12,0,0You must do this in-place without making a copy of the array.Minimize the total number of operations.0을 카운트하는 로직을 처
Symbol ValueI : 1V : 5X : 10L : 50C : 100D : 500M : 1000Input: s =
Input: a = "11", b = "1"Output: "100"Input: a = "1010", b = "1011"Output: "10101"1 <= a.length, b.length <= 104a and b consist only of '0' or '1
Input: n = 19Output: trueExplanation:12 + 92 = 8282 + 22 = 6862 + 82 = 10012 + 02 + 02 = 1Input: n = 2Output: false1 <= n <= 231 - 1~.~
s = "leetcode"return 0.s = "loveleetcode"return 2.~.~
'A' -> "1"'B' -> "2"...'Z' -> "26""AAJF" with the grouping (1 1 10 6)"KJF" with the grouping (11 10 6)Input: s = "12"Output: 2Explanation: "12" could
Input: grid = \[ "1","1","1","1","0", "1","1","0","1","0", "1","1","0","0","0", "0","0","0","0","0"]Output: 1Input: grid = \[ "1","1","0","0","0"
Input: grid = \[ "1","1","1","1","0", "1","1","0","1","0", "1","1","0","0","0", "0","0","0","0","0"]Output: 1Input: grid = \[ "1","1","0","0","0"
Input: intervals = \[1,3,2,6,8,10,15,18]Output: \[1,6,8,10,15,18]Explanation: Since intervals 1,3 and 2,6 overlaps, merge them into 1,6.Input: interva
Input: l1 = 2,4,3, l2 = 5,6,4Output: 7,0,8Explanation: 342 + 465 = 807.Input: l1 = 0, l2 = 0Output: 0Input: l1 = 9,9,9,9,9,9,9, l2 = 9,9,9,9Output: 8,
Input: 1,2,3,4Output: 24,12,8,6null reference를 주의하자.
Input: s = "babad"Output: "bab"Note: "aba" is also a valid answer.Input: s = "a"Output: "a"Input: s = "ac"Output: "a"첫번째방법 index를 순환하며 해당 index를 기준으로
Input: matrix = \["1","0","1","0","0","1","0","1","1","1","1","1","1","1","1","1","0","0","1","0"]Output: 4Input: matrix = \["0","1","1","0"]Output: 1
Input: nums = 1,2,3,4Output: 1,3,6,10Explanation: Running sum is obtained as follows: 1, 1+2, 1+2+3, 1+2+3+4.Input: nums = 1,1,1,1,1Output: 1,2,3,4,5E
Given the root of a binary tree, return the length of the diameter of the tree.The diameter of a binary tree is the length of the longest path between
Example 1:Input: n = 2Output: 2Explanation: There are two ways to climb to the top.1\. 1 step + 1 step2\. 2 stepsExample 2:Input: n = 3Output: 3Explan
Example 1:Input: s = "anagram", t = "nagaram"Output: trueExample 2:Input: s = "rat", t = "car"Output: false
Example 1:Input: items = \[1,91,1,92,2,93,2,97,1,60,2,77,1,65,1,87,1,100,2,100,2,76]Output: \[1,87,2,88]Explanation: The student with ID = 1 got score
Example 1:Input: x = 121Output: trueExample 2:Input: x = -121Output: falseExplanation: From left to right, it reads -121. From right to left, it becom
Example 1:Input: prices = 7,1,5,3,6,4Output: 7Explanation: Buy on day 2 (price = 1) and sell on day 3 (price = 5), profit = 5-1 = 4.Then buy on day 4
Example 1:Input"Logger", "shouldPrintMessage", "shouldPrintMessage", "shouldPrintMessage", "shouldPrintMessage", "shouldPrintMessage", "shouldPrintMes
Example 1:Input: nums = 3,2,3Output: 3Example 2:Input: nums = 2,2,1,1,1,2,2Output: 2방법1 정렬후 순차탐색하며 maxCount의 원소 찾기방법2 해쉬맵을 이용하여 각 원소별 횟수 카운팅방법3 Boyer-
Example 1:Input: head = 1,2,6,3,4,5,6, val = 6Output: 1,2,3,4,5Example 2:Input: head = \[], val = 1Output: \[]
Example 1:전략 재귀적으로 left child 노드와 right child 노드를 치환한다.
Example 1:Input: nums = 1,7,3,6,5,6Output: 3Explanation:The pivot index is 3.Left sum = nums0 + nums1 + nums2 = 1 + 7 + 3 = 11Right sum = nums4 + nums
Example 1:Input"TweetCounts","recordTweet","recordTweet","recordTweet","getTweetCountsPerFrequency","getTweetCountsPerFrequency","recordTweet","getTwe
Example 1:Input: s = "leetcode", wordDict = "leet","code"Output: trueExplanation: Return true because "leetcode" can be segmented as "leet code".전략1\.
You start with 0 points. Return the maximum number of points you can earn by applying such operations.Example 1:Input: nums = 3,4,2Output: 6Explanatio
Example 1:Input: nums = 1,2,3,1Output: 4Explanation: Rob house 1 (money = 1) and then rob house 3 (money = 3).Total amount you can rob = 1 + 3 = 4.Exa
Example 1:Input: coins = 1,2,5, amount = 11Output: 3Explanation: 11 = 5 + 5 + 1Example 2:Input: coins = 2, amount = 3Output: -1Example 3:Input: coins
Example 1:Input: nums = 23,2,4,6,7, k = 6Output: trueExplanation: 2, 4 is a continuous subarray of size 2 whose elements sum up to 6.Example 2:Input:
Example 1:Input: nums1 = 1,2,3,2,1, nums2 = 3,2,1,4,7Output: 3Explanation: The repeated subarray with maximum length is 3,2,1.Example 2:Input: nums1 =
Example 1:Input: s = "abc"Output: 3Explanation: Three palindromic strings: "a", "b", "c".Example 2:Input: s = "aaa"Output: 6Explanation: Six palindrom
Example 1:Input: nums = 2,3,-2,4Output: 6Explanation: 2,3 has the largest product 6.Example 2:Input: nums = -2,0,-1Output: 0Explanation: The result ca
Example 1:Input: cardPoints = 1,2,3,4,5,6,1, k = 3Output: 12Explanation: After the first step, your score will always be 1. However, choosing the righ
Example 1:Input: n = 1Output: 10Explanation: We need to dial a number of length 1, so placing the knight over any numeric cell of the 10 cells is suff
Example 1:Input: intervals = \[0,30,5,10,15,20]Output: 2Example 2:Input: intervals = \[7,10,2,4]Output: 1전략1\. 2차원 input array의 시작시간과 끝나는 시간을 각각 배열에 저
Example 1:Input: s = "aab"Output: "aba"Example 2:Input: s = "aaab"Output: ""전략 1\. 각 알파벳의 frequency를 hashmap에 저장2\. 각 알파벳의 frequency가 높은 우선순위로 우선순위 큐를
Example 1:Input: height = 1,8,6,2,5,4,8,3,7Output: 49Explanation: The above vertical lines are represented by array 1,8,6,2,5,4,8,3,7. In this case, t
Example 1:Input: gas = 1,2,3,4,5, cost = 3,4,5,1,2Output: 3Explanation:Start at station 3 (index 3) and fill up with 4 unit of gas. Your tank = 0 + 4
Example 1:Input: graph = \[1,1,0,0,1,0,1,1,1]Output: 1Explanation: There are three persons labeled with 0, 1 and 2. graphi = 1 means person i knows pe
Example 1:Input: s = "abaac", cost = 1,2,3,4,5Output: 3Explanation: Delete the letter "a" with cost 3 to get "abac" (String without two identical lett
Example 1:Input: h = 5, w = 4, horizontalCuts = 1,2,4, verticalCuts = 1,3Output: 4 Explanation: The figure above represents the given rectangular cake
Example 1:Input: nums = 1,2,2Output: 1Explanation: After 1 move, the array could be 1, 2, 3.Example 2:Input: nums = 3,2,1,2,1,7Output: 6Explanation: A
Example 1:Input: costs = \[10,20,30,200,400,50,30,20]Output: 110Explanation: The first person goes to city A for a cost of 10.The second person goes t
Example 1:Input: sticks = 2,4,3Output: 14Explanation: You start with sticks = 2,4,3.1\. Combine sticks 2 and 3 for a cost of 2 + 3 = 5. Now you have s
Example 1:Input: palindrome = "abccba"Output: "aaccba"Explanation: There are many ways to make "abccba" not a palindrome, such as "zbccba", "aaccba",
Example 1:Input: s = "bcabc"Output: "abc"Example 2:Input: s = "cbacdcbc"Output: "acdb"전략 1\. 알파벳별 마지막 index를 HashMap으로 관리2\. 각 알파벳을 순회하면서, 2.1스택이 비지
A cinema has n rows of seats, numbered from 1 to n and there are ten seats in each row, labelled from 1 to 10 as shown in the figure above.Given the a
Given an array nums, you are allowed to choose one element of nums and change it by any value in one move.Return the minimum difference between the la
Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endp
Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. Return the answer in any
Example 1:Input: board = \["A","B","C","E","S","F","C","S","A","D","E","E"], word = "ABCCED"Output: trueExample 2:Input: board = \["A","B","C","E","S"
Example 1:Input: numCourses = 2, prerequisites = \[1,0]Output: 0,1Explanation: There are a total of 2 courses to take. To take course 1 you should hav
Example 1:Input: s = "lee(t(c)o)de)"Output: "lee(t(c)o)de"Explanation: "lee(t(co)de)" , "lee(t(c)ode)" would also be accepted.Example 2:Input: s = "a)
Example 1:Input: words = "a","b","ba","bca","bda","bdca"Output: 4Explanation: One of the longest word chains is "a","ba","bda","bdca".Example 2:Input: