int trie[1000010][26];    
int num[1000010]={0};    
int pos = 1;
void Insert(char *s)    
{
    int i;
    int c = 0;
for(i=0;i<strlen(s);i++)
{
       int n = s[i]-'a';
       if(trie[c][n]==0)   
           trie[c][n] = pos++;
       c = trie[c][n];
       num[c]++;
   }
}


int Find(char *s)    
{
    int i,c = 0;
    for(i=0;i<strlen(s);i++)
{
        int n = s[i]-'a';
        if(trie[c][n]==0)
            return 0;
        c = trie[c][n];
    }
    return num[c];

相关文章:

  • 2022-12-23
  • 2021-08-17
  • 2021-09-15
  • 2021-08-12
  • 2021-12-18
  • 2022-12-23
  • 2021-11-13
  • 2022-03-07
猜你喜欢
  • 2021-12-29
  • 2022-01-07
  • 2022-01-06
  • 2022-02-06
相关资源
相似解决方案