I have leetcode question
Input: jewels = "aA", stones = "aAAbbbb" Output: 3
and capital letters a and A are different types.
Input: jewels = "z", stones = "ZZ" Output: 0
So how would count in python. I think zip is not a good choice because it pairs index by index.
CodePudding user response:
Not sure if I understood the problem correctly but if you are trying to see how many common characters the two strings have and also how many occurrences of each you could do it like so:
len([i for i in stones if i in jewels])