We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. Prepare
  2. Algorithms
  3. Greedy
  4. Permuting Two Arrays
  5. Discussions

Permuting Two Arrays

Problem
Submissions
Leaderboard
Discussions
Editorial
Topics

    You are viewing a single comment's thread. Return to all comments →

  • chammika
    4 years ago+ 1 comment

    Very simple solution:

    def twoArrays(k, A, B):
        A.sort()
        B.sort(reverse=True)
        if (any(a+b<k for a,b in zip(A,B))):
            return "NO"
        else:
            return "YES"
    
    8|
    Permalink
  • Contest Calendar
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature