C Hash Table


  • 0
    O

    /**

    • Return an array of size *returnSize.

    • Note: The returned array must be malloced, assume caller calls free().
      /
      char
      * findWords(char** words, int wordsSize, int* returnSize)
      {
      // A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z
      int Line1[26]={2,3,3,2,1,2,2,2,1,2,2,2,3,3,1,1,1,1,2,1,1,3,1,3,1,3};

      char cpRe;
      int iReCount;
      char cpTmp;
      char ctmp;
      int iFirstLine;
      cpRe=(char
      )malloc(sizeof(char
      )*50);

      int ireturnSize ;

    ireturnSize=0;
    for(int i=0;i<wordsSize;i++)
    {
        cpTmp = words[i];
        ctmp=*cpTmp;
        if(ctmp>90)
           ctmp-=97; 
        else
           ctmp-=65;
           
        iFirstLine = Line1[ctmp];
        
        cpTmp+=1;
        ctmp=*cpTmp;
        if(ctmp=='\0')
        {
            cpRe[ireturnSize]=words[i];
                ireturnSize+=1;     
        }
                
        while(ctmp!='\0')
        {
            if(ctmp>90)
                ctmp-=97; 
            else
                ctmp-=65;
            
            if(Line1[ctmp]!=iFirstLine)
            {
                break;
            }
            cpTmp+=1;
            ctmp=*cpTmp;
            if(ctmp=='\0')
            {
                if(cpTmp!=NULL)   
                {
                cpRe[ireturnSize]=words[i];
                ireturnSize+=1; 
                }
            }
            
        }
        
    }
    
    
    
    
    
    
    
    
    
    
    
    *returnSize=ireturnSize;
    return cpRe;
    

    }


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.