My LeetCode grinding. Trying to do a problem a day.
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

main.py 338B

12345678910111213
  1. class Solution:
  2. def numJewelsInStones(self, J: str, S: str) -> int:
  3. total = 0
  4. for jewel in J:
  5. for stone in S:
  6. if stone == jewel:
  7. total += 1
  8. return total
  9. s = Solution()
  10. print("Expected: 3")
  11. print("Got:", s.numJewelsInStones("abcD", "DaaFz"))