title: Efficient search algorithm to find duplicate strings
body: <p>Below is the algorithm to find a duplicate string pattern. All the strings already have been added in a linked list, now the job is to find a duplicate pattern.</p>
  
  <p>String length can be 8-20 characters and the number of string elements in the linked list is between 100 and 200. The current approach seems to have complexity and efficiency issues. Can anybody suggest most efficient approach for this?</p>
  
  <pre><code>typedef struct Map
  {
          int8_t *string;
          struct Map  *next;
  }map_t;
  
  //Algorithm to find the duplicate string pattern in link list.  
  
  int16_t findDuplicateOids(map_t *head)
  {
    map_t *ptr1, *ptr2;
    ptr1 = head;
    /* Pick elements one by one */
    while(ptr1 != NULL &amp;&amp; ptr1-&gt;next != NULL)
    {
       ptr2 = ptr1;
       /* Compare the picked element with rest of the elements */
       while(ptr2-&gt;next != NULL)
       {
         /* If pattern is similar than return return error */
         if(!strcmp(ptr1-&gt;string , ptr2-&gt;next-&gt;string))
         {  printf("match happened");
            return RESULT_ERROR;
         }
         else 
         {
            ptr2 = ptr2-&gt;next;
         }
       }
       ptr1 = ptr1-&gt;next;
    }
    return RESULT_SUCCESS;
  }
  </code></pre>