본문 바로가기

전체 글

[Leetcode/파이썬] 300. Longest Increasing Subsequence Longest Increasing SubsequenceGiven an integer array nums, return the length of the longest strictly increasing subsequence. Example 1:Input: nums = [10,9,2,5,3,7,101,18]Output: 4Explanation: The longest increasing subsequence is [2,3,7,101], therefore the length is 4.Example 2:Input: nums = [0,1,0,3,2,3]Output: 4Example 3:Input: nums = [7,7,7,7,7,7,7]Output: 1 Constraints:1 -104 4 Follow up: Ca.. 더보기
[Leetcode/파이썬] 34. Find First and Last Position of Element in Sorted Array Find First and Last Position of Element in Sorted ArrayGiven an array of integers nums sorted in non-decreasing order, find the starting and ending position of a given target value.If target is not found in the array, return [-1, -1].You must write an algorithm with O(log n) runtime complexity. Example 1:Input: nums = [5,7,7,8,8,10], target = 8Output: [3,4]Example 2:Input: nums = [5,7,7,8,8,10],.. 더보기
[Leetcode/파이썬] 383. Ransom Note Ransom NoteGiven two strings ransomNote and magazine, return true if ransomNote can be constructed by using the letters from magazine and false otherwise.Each letter in magazine can only be used once in ransomNote. Example 1:Input: ransomNote = "a", magazine = "b"Output: falseExample 2:Input: ransomNote = "aa", magazine = "ab"Output: falseExample 3:Input: ransomNote = "aa", magazine = "aab"Outpu.. 더보기
[Leetcode/파이썬] 128. Longest Consecutive Sequence Longest Consecutive SequenceGiven an unsorted array of integers nums, return the length of the longest consecutive elements sequence.You must write an algorithm that runs in O(n) time. Example 1:Input: nums = [100,4,200,1,3,2]Output: 4Explanation: The longest consecutive elements sequence is [1, 2, 3, 4]. Therefore its length is 4.Example 2:Input: nums = [0,3,7,2,5,8,4,6,0,1]Output: 9Example 3:I.. 더보기
[Leetcode/파이썬] 172. Factorial Trailing Zeroes Factorial Trailing ZeroesGiven an integer n, return the number of trailing zeroes in n!.Note that n! = n * (n - 1) * (n - 2) * ... * 3 * 2 * 1. Example 1:Input: n = 3Output: 0Explanation: 3! = 6, no trailing zero.Example 2:Input: n = 5Output: 1Explanation: 5! = 120, one trailing zero.Example 3:Input: n = 0Output: 0 Constraints:0 4 Follow up: Could you write a solution that works in logarithmic t.. 더보기
[Leetcode/파이썬] 66. Plus One Plus OneYou are given a large integer represented as an integer array digits, where each digits[i] is the ith digit of the integer. The digits are ordered from most significant to least significant in left-to-right order. The large integer does not contain any leading 0's.Increment the large integer by one and return the resulting array of digits. Example 1:Input: digits = [1,2,3]Output: [1,2,4].. 더보기
[Leetcode/파이썬] 17. Letter Combinations of a Phone Number Letter Combinations of a Phone NumberGiven a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. Return the answer in any order.A mapping of digits to letters (just like on the telephone buttons) is given below. Note that 1 does not map to any letters. Example 1:Input: digits = "23"Output: ["ad","ae","af","bd","be","bf","cd","ce",.. 더보기
[Leetcode/파이썬] 150. Evaluate Reverse Polish Notation Evaluate Reverse Polish NotationYou are given an array of strings tokens that represents an arithmetic expression in a Reverse Polish Notation.Evaluate the expression. Return an integer that represents the value of the expression.Note that:The valid operators are '+', '-', '*', and '/'.Each operand may be an integer or another expression.The division between two integers always truncates toward .. 더보기