Sfoglia il codice sorgente

100 problems done! Yay!

master
Lachlan Jacob 5 anni fa
parent
commit
081417abd4
3 ha cambiato i file con 35 aggiunte e 0 eliminazioni
  1. 13
    0
      problems/771/main.py
  2. 19
    0
      problems/771/problem.txt
  3. 3
    0
      problems/771/run.sh

+ 13
- 0
problems/771/main.py Vedi File

@@ -0,0 +1,13 @@
class Solution:
def numJewelsInStones(self, J: str, S: str) -> int:
total = 0
for jewel in J:
for stone in S:
if stone == jewel:
total += 1
return total

s = Solution()
print("Expected: 3")
print("Got:", s.numJewelsInStones("abcD", "DaaFz"))

+ 19
- 0
problems/771/problem.txt Vedi File

@@ -0,0 +1,19 @@
You're given strings J representing the types of stones that are jewels, and S representing the stones you have. Each character in S is a type of stone you have. You want to know how many of the stones you have are also jewels.

The letters in J are guaranteed distinct, and all characters in J and S are letters. Letters are case sensitive, so "a" is considered a different type of stone from "A".

Example 1:

Input: J = "aA", S = "aAAbbbb"
Output: 3

Example 2:

Input: J = "z", S = "ZZ"
Output: 0

Note:

S and J will consist of letters and have length at most 50.
The characters in J are distinct.


+ 3
- 0
problems/771/run.sh Vedi File

@@ -0,0 +1,3 @@
#!/bin/bash

python3 main.py

Loading…
Annulla
Salva