Skip to content

Commit 188b76a

Browse files
authored
Update Jewels and Stones - Leetcode 771.py
1 parent 310dc1c commit 188b76a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Jewels and Stones - Leetcode 771/Jewels and Stones - Leetcode 771.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# Brute Force Solution
2+
class Solution:
3+
def numJewelsInStones (self, jewels: str, stones: str) -> int:
4+
count = 0
5+
for stone in stones:
6+
if stone in jewels:
7+
count += 1
8+
return count
9+
10+
# Time Complexity: O(n * m)
11+
# Space Complexity: O(1)
12+
13+
14+
# Optimal Solution
115
class Solution:
216
def numJewelsInStones (self, jewels: str, stones: str) -> int:
317
# O(n + m)

0 commit comments

Comments
 (0)