jayati

Jewels and Stones

Mar 30th, 2023
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.34 KB | None | 0 0
  1. class Solution {
  2. public:
  3.     int numJewelsInStones(string jewels, string stones) {
  4.         int ans=0;
  5.         for(int i=0;i<stones.length();i++)
  6.         {
  7.             if(jewels.find(stones[i])>=0 && jewels.find(stones[i])<jewels.length())
  8.             {
  9.                 ans++;
  10.             }
  11.         }
  12.         return ans;
  13.        
  14.     }
  15. };
Advertisement
Add Comment
Please, Sign In to add comment