给定字符串 和 ,计算字符串 中同时存在于字符串 的字符数量。 需要注意的是,字符区分大小写, 与 视为不同的字符。 函数参数: 字符串 ,满足 ,表示不重复的宝石类型; 字符串 ,满足 ,表示手中石头序列。 返回值为一个整数,表示字符串 中同时存在于字符串 的字符数量。
示例1
输入
"wangzai","awsl"
输出
2
加载中...
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param jewels string字符串 * @param stones string字符串 * @return int整型 */ public int numJewelsInStones (String jewels, String stones) { // write code here } }
class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param jewels string字符串 * @param stones string字符串 * @return int整型 */ int numJewelsInStones(string jewels, string stones) { // write code here } };
#coding:utf-8 # # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param jewels string字符串 # @param stones string字符串 # @return int整型 # class Solution: def numJewelsInStones(self , jewels , stones ): # write code here
using System; using System.Collections.Generic; class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param jewels string字符串 * @param stones string字符串 * @return int整型 */ public int numJewelsInStones (string jewels, string stones) { // write code here } }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param jewels string字符串 * @param stones string字符串 * @return int整型 */ function numJewelsInStones( jewels , stones ) { // write code here } module.exports = { numJewelsInStones : numJewelsInStones };
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param jewels string字符串 # @param stones string字符串 # @return int整型 # class Solution: def numJewelsInStones(self , jewels: str, stones: str) -> int: # write code here
package main import "fmt" /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param jewels string字符串 * @param stones string字符串 * @return int整型 */ func numJewelsInStones( jewels string , stones string ) int { // write code here }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param jewels string字符串 * @param stones string字符串 * @return int整型 */ int numJewelsInStones(char* jewels, char* stones ) { // write code here }
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param jewels string字符串 # @param stones string字符串 # @return int整型 # class Solution def numJewelsInStones(jewels, stones) # write code here end end
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param jewels string字符串 * @param stones string字符串 * @return int整型 */ def numJewelsInStones(jewels: String,stones: String): Int = { // write code here } }
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param jewels string字符串 * @param stones string字符串 * @return int整型 */ fun numJewelsInStones(jewels: String,stones: String): Int { // write code here } }
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param jewels string字符串 * @param stones string字符串 * @return int整型 */ public int numJewelsInStones (String jewels, String stones) { // write code here } }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param jewels string字符串 * @param stones string字符串 * @return int整型 */ export function numJewelsInStones(jewels: string, stones: string): number { // write code here }
public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param jewels string字符串 * @param stones string字符串 * @return int整型 */ func numJewelsInStones ( _ jewels: String, _ stones: String) -> Int { // write code here } }
struct Solution{ } impl Solution { fn new() -> Self { Solution{} } /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param jewels string字符串 * @param stones string字符串 * @return int整型 */ pub fn numJewelsInStones(&self, jewels: String, stones: String) -> i32 { // write code here } }
"wangzai","awsl"
2