We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
给定字符串J 代表石头中宝石的类型,和字符串 S 代表你拥有的石头。 S 中每个字符代表了一种你拥有的石头的类型,你想知道你拥有的石头中有多少是宝石。
J
S
J 中的字母不重复,J 和 S 中的所有字符都是字母。字母区分大小写,因此"a"和"A"是不同类型的石头。
"a"
"A"
Input: J = "aA", S = "aAAbbbb" Output: 3
Input: J = "z", S = "ZZ" Output: 0
The text was updated successfully, but these errors were encountered:
/** * @param {string} J * @param {string} S * @return {number} */ var numJewelsInStones = function(J, S) { const jewels = new Set(); let result = 0; for (let i = 0; i < J.length; i++) { jewels.add(J[i]); } for (let i = 0; i < S.length; i++) { if (jewels.has(S[i])) { result++; } } return result; };
Sorry, something went wrong.
No branches or pull requests
771. Jewels and Stones
给定字符串
J
代表石头中宝石的类型,和字符串S
代表你拥有的石头。S
中每个字符代表了一种你拥有的石头的类型,你想知道你拥有的石头中有多少是宝石。J
中的字母不重复,J
和S
中的所有字符都是字母。字母区分大小写,因此"a"
和"A"
是不同类型的石头。Example 1
Example 2
Note
S
和J
最多含有50个字母。J
中的字符不重复。The text was updated successfully, but these errors were encountered: