title: Finding repeated / missing number in range 1 to n in cpp
body: <p>I have tried to solve by hashing and return via dynamic array.<br />
  but facing error in test case:</p>
  <pre><code>14  
  12 7 5 1 13 1 10 8 11 9 2 4 3 6  
  </code></pre>
  <p>Correct output is:</p>
  <pre><code>1 14  
  </code></pre>
  <p>And my code's output is:</p>
  <pre><code>1 0
  </code></pre>
  <p>else all outputs are correct by far. Here is my code:</p>
  <pre><code>int *findTwoElement(int *arr, int n) {
  
      int *res=new int(2);
      int hsh[n]={0};
      int mini;
      for(int i=1;i&lt;=n;i++)
          {
              hsh[arr[i-1]]++;
          }
       for(int i=1;i&lt;=n;i++)
       {
          if(hsh[i]&gt;1)
                {
                    mini=min(mini,i);
                    res[0]=mini;
                }
          if(hsh[i]==0)
                {
                    res[1]=i;
                }
              
       }
     return res;
  }
  </code></pre>