title: Finding common minimum value between two arrays in java
body: <p>I got a test on codility for a job interview yesterday. This is the second question and I still can't figure out the solution. You have to find the bug in the code without removing or adding lines. I added a while loop it compiled fine but didn't change much. Any solutions?  </p>
  
  <pre><code>import java.util.*;
  
  class minimum {
      int minimum(int[] A, int[] B) {
          int n = A.length;
          int m = B.length;;
          Arrays.sort(A);
          Arrays.sort(B);
          int i = 0;
          for (int k = 0; k &lt; n; k++) {
              if (i &lt; m - 1 &amp;&amp; B[i] &lt; A[k])
                  i += 1;
              if (A[k] == B[i])
                  return A[k];
          }
          return -1;
      }
  }
  </code></pre>