1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | import java.util.*; class Solution { public int solution(int[] A, int[] B) { int answer = 0; int pos = 0; Arrays.sort(A); Arrays.sort(B); for(int i=0;i<A.length;i++) { for(int j=pos;j<B.length;j++) { if(A[i] < B[j]) { answer++; pos = j + 1; break; } } } return answer; } } | cs |
Programmers/Level3