Selaa lähdekoodia

100 problems done! Yay!

master
Lachlan Jacob 5 vuotta sitten
vanhempi
commit
081417abd4
3 muutettua tiedostoa jossa 35 lisäystä ja 0 poistoa
  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 Näytä tiedosto

@@ -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 Näytä tiedosto

@@ -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 Näytä tiedosto

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

python3 main.py

Loading…
Peruuta
Tallenna