You are viewing a single comment's thread. Return to all comments →
Kotlin one-line answer:
fun twoArrays(k: Int, A: Array<Int>, B: Array<Int>): String { return if ((A.sum() + B.sum())/A.size >= k && A.min()!!+B.max()!! >= k && A.max()!!+B.min()!! >=k) "YES" else "NO" }
Java 8:
public static String twoArrays(int k, List<Integer> A, List<Integer> B) { return (((A.stream() .reduce(0, Integer::sum)) + (B.stream() .reduce(0, Integer::sum)))/A.size() >= k && Collections.min(A) + Collections.max(B) >=k && Collections.max(A) + Collections.min(B) >=k) ? "YES" : "NO"; }
Seems like cookies are disabled on this browser, please enable them to open this website
Permuting Two Arrays
You are viewing a single comment's thread. Return to all comments →
Kotlin one-line answer:
Java 8: