Skip to content

Commit 9c85359

Browse files
committed
Time: 0 ms (100.00%) | Memory: 41.8 MB (45.93%) - LeetSync
1 parent 653d49c commit 9c85359

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed
Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
11
class Solution {
22
public int numJewelsInStones(String jewels, String stones) {
33

4-
Set<Character> set = new HashSet<>();
54
int count=0;
6-
for(char ch : jewels.toCharArray()){
7-
set.add(ch);
8-
}
9-
10-
for(char stone : stones.toCharArray()){
11-
if(set.contains(stone)){
12-
count++;
5+
for(char jewel : jewels.toCharArray()){
6+
for(char stone : stones.toCharArray()){
7+
if(jewel==stone){
8+
count++;
9+
}
1310
}
1411
}
15-
return count;
16-
12+
return count;
1713
}
18-
}
14+
}
15+
16+
// Set<Character> set = new HashSet<>();
17+
// int count=0;
18+
// for(char ch : jewels.toCharArray()){
19+
// set.add(ch);
20+
// }
21+
22+
// for(char stone : stones.toCharArray()){
23+
// if(set.contains(stone)){
24+
// count++;
25+
// }
26+
// }
27+
// return count;

0 commit comments

Comments
 (0)