Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions combination-sum/mrlee7.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from typing import List


class Solution:
def combinationSum(self, candidates: List[int], target: int) -> List[List[int]]:
result, nums = list(), list()

def dfs(start_position, total_sum):
if total_sum > target:
return
if total_sum == target:
result.append(nums[:])
for idx in range(start_position, len(candidates)):
num = candidates[idx]
nums.append(num)
dfs(idx, total_sum + num)
nums.pop()

dfs(0, 0)
return result
8 changes: 8 additions & 0 deletions number-of-1-bits/mrlee7.py
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

비트 문제를 수학적으로 푸신 게 인상깊네요!

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class Solution:
def hammingWeight(self, n: int) -> int:
result = 0

while n > 0:
result += n % 2
n //= 2
return result
7 changes: 7 additions & 0 deletions valid-palindrome/mrlee7.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import re


class Solution:
def isPalindrome(self, s: str) -> bool:
result = re.sub(r'[^a-zA-Z0-9]', '', s).lower()
return result == result[::-1]
Loading