石头和珠宝

LeetCode 刷题问题描述


解决代码:

   public static int numJewelsInStones(String J, String S) {
  int K = 0,m = 0;int l=0;int ln = 0;
  int num = 0;
  int result =0;
  int jlenth = J.length();
  int slenth = S.length();
  while(jlenth>l) {
    char c =   J.charAt(K);
    while(slenth>ln) {
    char s  = S.charAt(m);
    if(c-s==0) {
    num++;
        result = num;
     
    }
    m++;
    ln++;
    }
    K++;
    l++;
    ln = 0;
    m = 0;
  }
        return result;   
    }

猜你喜欢

转载自blog.csdn.net/goforitaaa/article/details/80946747