Skip to content

Commit 76ce972

Browse files
committed
[W4]
missing number solution
1 parent 5740518 commit 76ce972

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

missing-number/sun912.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
"""
2+
TC: O(n)
3+
SC: O(n)
4+
"""
5+
6+
class Solution:
7+
def missingNumber(self, nums: List[int]) -> int:
8+
nums_set = set(nums)
9+
for i in range(len(nums)):
10+
if i not in nums_set:
11+
return i
12+
return len(nums)

valid-palindrome/sun912.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
"""
2+
TC: O(n)
3+
SC: O(n)
4+
"""
15
class Solution:
26
def isPalindrome(self, s: str) -> bool:
37
str = list(s.lower())

0 commit comments

Comments
 (0)