Created
February 20, 2020 15:55
-
-
Save bugrym/cc17fb049cf013056c9d9b9e3e5a30a0 to your computer and use it in GitHub Desktop.
771. Jewels and Stones
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func numJewelsInStones(_ J: String, _ S: String) -> Int { | |
var counter = 0 | |
let stones = Array(S) | |
let jewels = Array(J) | |
for i in 0..<stones.count { | |
for j in 0..<jewels.count { | |
let lhs = stones[i] | |
let rhs = jewels[j] | |
if lhs == rhs { | |
counter += 1 | |
} | |
} | |
} | |
return counter | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment