updated README

This commit is contained in:
harshraj22 2019-08-20 10:53:25 +05:30
parent d45ffafcf5
commit 93cb21ea99
2 changed files with 20 additions and 0 deletions

View File

@ -17,5 +17,6 @@ LeetCode
|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|
|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|
|917|[Reverse Only Letters](https://leetcode.com/problems/reverse-only-letters/) | [C](./src/917.c)|Easy|

19
leetcode/src/771.c Normal file
View 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;
}