mirror of
https://github.com/TheAlgorithms/C
synced 2024-11-26 07:19:55 +03:00
updated README
This commit is contained in:
parent
d45ffafcf5
commit
93cb21ea99
@ -17,5 +17,6 @@ LeetCode
|
|||||||
|561|[Array Partition I](https://leetcode.com/problems/array-partition-i/) | [C](./src/561.c)|Easy|
|
|561|[Array Partition I](https://leetcode.com/problems/array-partition-i/) | [C](./src/561.c)|Easy|
|
||||||
|704|[Binary Search](https://leetcode.com/problems/binary-search/) | [C](./src/704.c)|Easy|
|
|704|[Binary Search](https://leetcode.com/problems/binary-search/) | [C](./src/704.c)|Easy|
|
||||||
|709|[To Lower Case](https://leetcode.com/problems/to-lower-case/) | [C](./src/709.c)|Easy|
|
|709|[To Lower Case](https://leetcode.com/problems/to-lower-case/) | [C](./src/709.c)|Easy|
|
||||||
|
|771|[Jewels and Stones](https://leetcode.com/problems/jewels-and-stones/) | [C](./src/771.c)|Easy|
|
||||||
|905|[Sort Array By Parity](https://leetcode.com/problems/sort-array-by-parity/) | [C](./src/905.c)|Easy|
|
|905|[Sort Array By Parity](https://leetcode.com/problems/sort-array-by-parity/) | [C](./src/905.c)|Easy|
|
||||||
|917|[Reverse Only Letters](https://leetcode.com/problems/reverse-only-letters/) | [C](./src/917.c)|Easy|
|
|917|[Reverse Only Letters](https://leetcode.com/problems/reverse-only-letters/) | [C](./src/917.c)|Easy|
|
||||||
|
19
leetcode/src/771.c
Normal file
19
leetcode/src/771.c
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// for strlen( )
|
||||||
|
#include<string.h>
|
||||||
|
|
||||||
|
int numJewelsInStones(char * j, char * s){
|
||||||
|
// as strlen is O(n), store it once rather than using it in for loop
|
||||||
|
int cnt[500],lens=strlen(s),lenj=strlen(j),sol=0;
|
||||||
|
memset(cnt,0,sizeof(cnt));
|
||||||
|
|
||||||
|
// lookup to know which character occurs in j
|
||||||
|
for(int i=0;i<lenj;i++)
|
||||||
|
cnt[j[i]]++;
|
||||||
|
|
||||||
|
// count the characters in s
|
||||||
|
for(int i=0;i<lens;i++)
|
||||||
|
sol+=cnt[s[i]];
|
||||||
|
|
||||||
|
return sol;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user