title: Find duplicate in Array with single loop
body: <p>The question is there is and unsorted array and the maximum value should be smaller than the length. I have to find the duplicate record in the array. The condition is to use a loop only once. This is what i have achieved so far. I wanted to know if there was any other approach through which i can achieve this.</p>
  
  <pre><code>int[] Arr = { 9, 5, 6, 3, 8, 2, 5, 1, 7, 4 };
  int[] Arr2 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
  for (int i = 0; i &lt; Arr.Length; i++)
  {
      if (Arr2[Arr[i]] == 0)
      {
          Arr2[Arr[i]] = Arr[i];
      }
      else
      {
          Console.WriteLine("duclicate found");
      }       
  }
  </code></pre>