Leetcode 771 Jewels and Stones

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/polanwind/article/details/87891175
class Solution {
public:
    int numJewelsInStones(string J, string S) {
        int ans = 0;
	    int len1 = J.length();
	    int len2 = S.length();
	    for (int i = 0;i < len1;++i) {
		    for (int j = 0;j < len2;++j) {
			    if (J[i] == S[j]) {
				    ans++;
			    }
		    }
        }
        return ans;
    }
};

猜你喜欢

转载自blog.csdn.net/polanwind/article/details/87891175