fork(1) download
  1. import java.util.Arrays;
  2. import java.util.stream.IntStream;
  3.  
  4. class Ideone {
  5.  
  6. public static void main (String[] args) {
  7. int[] A = {1, 1, 5, 3};
  8. int[] B = {7, 5, 2, 3};
  9. boolean result = isGreater(A,B);
  10. System.out.println(result); // should be true
  11. }
  12.  
  13. public static boolean isGreater(int[] a, int[] b) {
  14. if (b.length < a.length) {
  15. return false;
  16. }
  17. final int[] sortedA = Arrays.stream(a).sorted().toArray();
  18. final int[] sortedB = Arrays.stream(b).sorted().toArray();
  19. return IntStream.range(0, a.length).allMatch(i -> sortedA[i] < sortedB[i]);
  20. }
  21. }
  22.  
Success #stdin #stdout 0.21s 33736KB
stdin
Standard input is empty
stdout
true