본문 바로가기

전체 글

[Leetcode/파이썬] 97. Interleaving String Interleaving StringGiven strings s1, s2, and s3, find whether s3 is formed by an interleaving of s1 and s2.An interleaving of two strings s and t is a configuration where s and t are divided into n and m substrings respectively, such that:s = s1 + s2 + ... + snt = t1 + t2 + ... + tm|n - m| The interleaving is s1 + t1 + s2 + t2 + s3 + t3 + ... or t1 + s1 + t2 + s2 + t3 + s3 + ...Note: a + b is th.. 더보기
[Leetcode/파이썬] 209. Minimum Size Subarray Sum Minimum Size Subarray SumGiven an array of positive integers nums and a positive integer target, return the minimal length of a subarray whose sum is greater than or equal to target. If there is no such subarray, return 0 instead. Example 1:Input: target = 7, nums = [2,3,1,2,4,3]Output: 2Explanation: The subarray [4,3] has the minimal length under the problem constraint.Example 2:Input: target =.. 더보기
[Leetcode/파이썬] 200. Number of Islands Number of IslandsGiven an m x n 2D binary grid grid which represents a map of '1's (land) and '0's (water), return the number of islands.An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water. Example 1:Input: grid = [ ["1","1","1","1","0"], ["1","1","0","1","0"], ["1","1","0.. 더보기
[Leetcode/파이썬] 12. Integer to Roman Integer to RomanSeven different symbols represent Roman numerals with the following values:SymbolValueI1V5X10L50C100D500M1000Roman numerals are formed by appending the conversions of decimal place values from highest to lowest. Converting a decimal place value into a Roman numeral has the following rules:If the value does not start with 4 or 9, select the symbol of the maximal value that can be .. 더보기
[Leetcode/파이썬] 57. Insert Interval Insert IntervalYou are given an array of non-overlapping intervals intervals where intervals[i] = [starti, endi] represent the start and the end of the ith interval and intervals is sorted in ascending order by starti. You are also given an interval newInterval = [start, end] that represents the start and end of another interval.Insert newInterval into intervals such that intervals is still sort.. 더보기
[Leetcode/파이썬] 125. Valid Palindrome Valid PalindromeA phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. Alphanumeric characters include letters and numbers.Given a string s, return true if it is a palindrome, or false otherwise. Example 1:Input: s = "A man, a plan, a canal: Panama"Output: trueExplanation: "a.. 더보기
[Leetcode/파이썬] 242. Valid Anagram Valid AnagramGiven two strings s and t, return true if t is an anagram of s, and false otherwise. Example 1:Input: s = "anagram", t = "nagaram"Output: trueExample 2:Input: s = "rat", t = "car"Output: false Constraints:1 4s and t consist of lowercase English letters. Follow up: What if the inputs contain Unicode characters? How would you adapt your solution to such a case? class Solution: def .. 더보기
[Leetcode/파이썬] 1. Two Sum Two SumGiven an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.You may assume that each input would have exactly one solution, and you may not use the same element twice.You can return the answer in any order. Example 1:Input: nums = [2,7,11,15], target = 9Output: [0,1]Explanation: Because nums[0] + nums[1] == 9, we return [0, 1].E.. 더보기