일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
- python Leetcode
- leetcode풀기
- 파이썬릿코드
- 파이썬알고리즘풀기
- 릿코드 파이썬
- 파이썬 릿코드
- 파이썬알고리즘
- 파이썬 알고리즘 풀기
- 파이썬 프로그래머스
- python priority queue
- 릿코드풀기
- python 알고리즘
- 알고리즘풀이
- python sorted
- 릿코드풀이
- python xor
- 릿코드
- python 릿코드
- 파이썬릿코드풀기
- 파이썬 알고리즘
- 코틀린기초
- 알고리즘풀기
- binary search
- 상가수익률계산기
- leetcode 풀기
- 잇츠디모
- LeetCode
- 릿코드 풀기
- python zip_longest
- leetcode풀이
- Today
- Total
목록릿코드풀이 (5)
소프트웨어에 대한 모든 것

1704. Determine if String Halves Are Alike https://leetcode.com/problems/determine-if-string-halves-are-alike/ Determine if String Halves Are Alike - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문제) 솔루션1) class Solution: def halvesAreAlike(self, s: str) -> bool: vowels = ('a', '..

1302. Deepest Leaves Sum https://leetcode.com/problems/deepest-leaves-sum/ Deepest Leaves Sum - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문제) 솔루션1) hashtable을 사용해서 각 depth의 노드에 해당하는 모든 val 값들을 list 형태로 저장한다. hashtable에서 최대 depth에 O(1)로 접근해서 모든 values의 sum을 구하면 그것이 deepest lea..

1684. Count the Number of Consistent Strings 문제) 솔루션1) allowed 단어에 words가 있는지 탐색 O(n2) class Solution: def countConsistentStrings(self, allowed: str, words: List[str]) -> int: # Brute-Force count = 0 for word in words: count += 1 for i in range(len(word)): if word[i] not in allowed: count -= 1 break return count 솔루션2) class Solution: def countConsistentStrings(self, allowed: str, words: List[str..

1588. Sum of All Odd Length Subarrays 문제) 솔루션1) class Solution: def sumOddLengthSubarrays(self, arr: List[int]) -> int: res = 0 n = len(arr) for j in range(1, len(arr)+1, 2): for i in range(n - j + 1): res += sum(arr[i:i+j]) return res

2006. Count Number of Pairs With Absolute Difference K 문제) 솔루션1) Brute-force class Solution: def countKDifference(self, nums: List[int], k: int) -> int: count = 0 for i in range(len(nums)): for j in range(i, len(nums)): if i != j and abs(nums[i] - nums[j]) == k: count += 1 return count 솔루션2) 조합 사용 class Solution: def countKDifference(self, nums: List[int], k: int) -> int: count = 0 for i, j in c..