You are viewing a single comment's thread. Return to all comments →
Python 3 solutions:
import functools import typing def twoArrays(k: int, A: list[int], B: list[int]) -> typing.Literal["NO", "YES"]: A.sort() B.sort(reverse=True) return "NO" if any(a + b < k for a, b in zip(A, B, strict=True)) else "YES" def twoArrays(k: int, A: list[int], B: list[int]) -> typing.Literal["NO", "YES"]: @functools.lru_cache def cached_helper(ab: tuple[int, int]) -> bool: return sum(ab) < k A.sort() B.sort(reverse=True) return "NO" if any(map(cached_helper, zip(A, B, strict=True))) else "YES" # 88 s=sorted;twoArrays=lambda k,A,B:["YES","NO"][any(a+b<k for a,b in zip(s(A),s(B)[::-1]))]
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 →
Python 3 solutions: