title: Find the duplicate elements in a two-dimensional array
body: <p>I need to find the duplicate elements in a two dimensional array.</p>
  
  <pre><code>route_ptr-&gt;route[0][1] = 24;
  route_ptr-&gt;route[0][2] = 18;
  route_ptr-&gt;route[1][1] = 25;
  route_ptr-&gt;route[2][1] = 18;
  route_ptr-&gt;route[3][1] = 26;
  route_ptr-&gt;route[3][2] = 19;
  route_ptr-&gt;route[4][1] = 25;
  route_ptr-&gt;route[4][2] = 84;
  </code></pre>
  
  <p>Those are my data; the duplicate entries of route[2][1] (duplicate of route[0][2]) and route[4][1] (duplicate of route[1][1]) has to be found.</p>
  
  <p>The solution is the duplicate 'i' value of route[i][j] which is 2 &amp; 4 from this example.</p>
  
  <p>please guide me.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  struct route{
      int route[6][6];
      int no_routes_found;
      int count_each_route[6];
  };
  
  int main() {
      struct route *route_ptr, route_store;  
      route_ptr=&amp;route_store;
  
      int i,j,k;
  
      // the data
      route_ptr-&gt;route[0][1] = 24;
      route_ptr-&gt;route[0][2] = 18;
      route_ptr-&gt;route[1][1] = 25;
      route_ptr-&gt;route[2][1] = 18;
      route_ptr-&gt;route[3][1] = 26;
      route_ptr-&gt;route[3][2] = 19;
      route_ptr-&gt;route[4][1] = 25;
      route_ptr-&gt;route[4][2] = 84;
      route_ptr-&gt;count_each_route[0]=3;
      route_ptr-&gt;count_each_route[1]=2;
      route_ptr-&gt;count_each_route[2]=2;
      route_ptr-&gt;count_each_route[3]=3;
      route_ptr-&gt;count_each_route[4]=3;
      route_ptr-&gt;no_routes_found=5;
  
      ////  process
      for (i = 0; i &lt;(route_ptr-&gt;no_routes_found) ; i++)
      {
          for (j = 1; j &lt; route_ptr-&gt;count_each_route[i]; j++)
          {
              printf("\nroute[%d][%d] = ", i, j);
              printf("%d",route_ptr-&gt;route[i][j]);
          }
      }
  }
  </code></pre>
  
  <p>The solution expected is:</p>
  
  <pre><code>route[0][1] is compared by route [0][2] i.e [24 !=18]
  route[0][1] and route [0][2] is compared by route[1][1] i.e [24 &amp;&amp; 18 !=25]
  route[0][1] and route[0][2] and route[1][1] is compared by route[2][1] i.e [ 24&amp;&amp;18&amp;&amp;25 is compared by 18, there is a matching element,
     save the newcomer 'i' value which matches to the existence and drop it for next checking]
     break the 'i' loop
  route[0][1], route[0][2], route[1][1] is now compared route[3][1]
  route[0][1], route[0][2], route[1][1] ,[3][1] is now compared route[3][2]
  route[0][1], route[0][2], route[1][1] ,[3][1] ,[3][2] is now compared to route [4][1] i.e [ now there is a match to route[1][1], so save the newcomer 'i' value and  break the 'i' loop
  </code></pre>
  
  <p>So i values [2 and 4] are duplicate, and that is my expected result of my code.</p>