c语言sscanf函数的用法是什么
268
2022-08-29
LeetCode-771. Jewels and Stones
You're given strings J representing the types of stones that are jewels, and S representing the stones you have. Each character in S is a type of stone you have. You want to know how many of the stones you have are also jewels.
The letters in J are guaranteed distinct, and all characters in J and S are letters. Letters are case sensitive, so "a" is considered a different type of stone from "A".
Example 1:
Input: J = "aA", S = "aAAbbbb"Output: 3
Example 2:
Input: J = "z", S = "ZZ"Output: 0
Note:
S andJ will consist of letters and have length at most 50.The characters inJ are distinct.
题解:
class Solution {public: int numJewelsInStones(string J, string S) { if (J.length() == 0 || S.length() == 0) { return 0; } int res = 0; unordered_set
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~