Skip to content

Instantly share code, notes, and snippets.

@bugrym
Created February 20, 2020 15:55
Show Gist options
  • Save bugrym/cc17fb049cf013056c9d9b9e3e5a30a0 to your computer and use it in GitHub Desktop.
Save bugrym/cc17fb049cf013056c9d9b9e3e5a30a0 to your computer and use it in GitHub Desktop.
771. Jewels and Stones
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