알고리즘 공부 썸네일형 리스트형 2071. Maximum Number of Tasks You Can Assign from typing import Listimport collectionsimport bisectclass Solution: def maxTaskAssign(self, tasks: List[int], workers: List[int], pills: int, strength: int) -> int: # Sort tasks and workers in ascending order tasks.sort() workers.sort() n, m = len(tasks), len(workers) # Check if we can assign k tasks def can_assign(k): # C.. 더보기 2845. Count of Interesting Subarrays class Solution: def countInterestingSubarrays(self, nums: List[int], modulo: int, k: int) -> int: count_map = defaultdict(int) print(count_map) count_map[0] = 1 # 시작점 prefix = 0 answer = 0 for num in nums: # 현재 원소가 interesting 조건 만족하는가? if num % modulo == k: prefix += 1 # prefix[i] % modulo .. 더보기 4SUM problem https://leetcode.com/problems/4sum/description/ class Solution: def fourSum(self, nums: List[int], target: int) -> List[List[int]]: nums.sort() # 결과 중복 제거를 위해 정렬 n = len(nums) answer = [] if n 0 and nums[i] == nums[i-1]: continue for j in range(i + 1, n - 2): # 중복된 두 번째 요소 건너뛰기 if j > i + 1 .. 더보기 14. Longest Common Prefix https://leetcode.com/problemset/ Write a function to find the longest common prefix string amongst an array of strings.If there is no common prefix, return an empty string "". Example 1:Input: strs = ["flower","flow","flight"]Output: "fl"Example 2:Input: strs = ["dog","racecar","car"]Output: ""Explanation: There is no common prefix among the input strings. Constraints:1 0 strs[i] consists of onl.. 더보기 LeetCode 75 - Merge Strings Alternately You are given two strings word1 and word2. Merge the strings by adding letters in alternating order, starting with word1. If a string is longer than the other, append the additional letters onto the end of the merged string.Return the merged string. Example 1:Input: word1 = "abc", word2 = "pqr"Output: "apbqcr"Explanation: The merged string will be merged as so:word1: a b cword2: p q .. 더보기 이전 1 다음