Skip to content
Merged
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
19 changes: 19 additions & 0 deletions combination-sum/mandel-17.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from typing import List

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

def dfs(csum, index, path):
if csum < 0:
return
if csum == 0:
result.append(path)
return

for i in range(index, len(candidates)):
dfs(csum - candidates[i], i, path + [candidates[i]])

dfs(target, 0, [])
return result

10 changes: 10 additions & 0 deletions number-of-1-bits/mandel-17.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import collections

class Solution:
def hammingWeight(self, n: int) -> int:
two_digit = []
while n >= 1:
two_digit.append(n % 2)
n = n // 2
cnt_dict = collections.Counter(two_digit)
return cnt_dict[1]
4 changes: 4 additions & 0 deletions valid-palindrome/mandel-17.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Solution:
def isPalindrome(self, s: str) -> bool:
ch = [c.lower() for c in s if c.isalnum()]
return ch == ch[::-1]