Prerequisites for solving this particular question:
String Immutability & count method | Python | Castor Classes
https://www.youtube.com/watch?v=Am1vX...
Iterate over a list & string | List in Python | Part 4 | Castor Classes
https://www.youtube.com/watch?v=4Zrfk...
You can get the problem statement here:
https://leetcode.com/problems/jewels-...
Python for beginners:
https://www.youtube.com/watch?v=egq7Z...
Code:
class Solution:
def numJewelsInStones(self, J: str, S: str) -> int:
c=0;
for i in J:
c+=S.count(i);
return c;
0 Comments:
Post a Comment