diff --git a/solutions/lc1160.py b/solutions/lc1160.py new file mode 100644 index 0000000..4d097d9 --- /dev/null +++ b/solutions/lc1160.py @@ -0,0 +1,22 @@ +class Solution: + def countCharacters(self, words: List[str], chars: str) -> int: + answer = 0 + char_count = {} + for c in chars: + char_count[c] = char_count.get(c, 0) + 1 + + for word in words: + word_count = {} + is_valid = True + + for ch in word: + word_count[ch] = word_count.get(ch, 0) + 1 + + if word_count[ch] > char_count.get(ch, 0): + is_valid = False + break + + if is_valid: + answer += len(word) + + return answer diff --git a/solutions/lc119.py b/solutions/lc119.py new file mode 100644 index 0000000..41e78c0 --- /dev/null +++ b/solutions/lc119.py @@ -0,0 +1,12 @@ +class Solution: + def getRow(self, rowIndex: int) -> List[int]: + row = [1] + + for _ in range(rowIndex): + new_row = [1] + new_row.extend([row[i]+row[i+1] for i in range(len(row)-1)]) + new_row.append(1) + + row = new_row + + return row diff --git a/solutions/lc2259.py b/solutions/lc2259.py new file mode 100644 index 0000000..56a0737 --- /dev/null +++ b/solutions/lc2259.py @@ -0,0 +1,10 @@ +class Solution: + def removeDigit(self, number: str, digit: str) -> str: + n = "0" + + for i in range(len(number)): + if number[i] == digit: + cur = number[0:i]+number[i+1:] + n = cur if cur > n else n + + return n