Given a word and a text, we need to return the occurrences of anagrams

后端 未结 5 2148
囚心锁ツ
囚心锁ツ 2020-12-17 20:58

Given a word and a text, return the count of the occurrences of anagrams of the word in the text. For eg. word is “for” and the text is “forxxorfxdofr”, anagrams of “for” wi

5条回答
  •  萌比男神i
    2020-12-17 21:44

    I have taken two string namely str and occ. Str is the original strin and occ is the sting for which we have to find out the count. Using strncpy function I have copied the length of occ i.e. n chars into a temp array and then checked whether it is a permutation of the occ string or not.

    #include  
    #include  
    #include
    
    int permutate(char str1[],char str2[]);  
    int permutate(char str1[],char str2[]) {  
        int c[256]={0},i,j;  
        for(i=0;i
                                                            
提交回复
热议问题