Guest User

Untitled

a guest
Jul 18th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. public int solution(int[] A, int[] B) {
  2. int n = A.length;
  3. int m = B.length;
  4. Arrays.sort(A);
  5. Arrays.sort(B);
  6. int i = 0;
  7. for (int k = 0; k < n; k++) {
  8. if (i < m - 1 && B[i] < A[k])
  9. i += 1;
  10. if (A[k] == B[i])
  11. return A[k];
  12. }
  13. return -1;
  14. }
Add Comment
Please, Sign In to add comment