This probably is one the shortest solutions I’ve ever written to a problem in LC.
class Solution {
fun numJewelsInStones(J: String, S: String): Int = S.filter { it in J }.length
}
Runtime: 148 ms, faster than 81.10% of Kotlin online submissions for Jewels and Stones.
Memory Usage: 33.1 MB, less than 100.00% of Kotlin online submissions for Jewels and Stones.