Skip to content

Commit

Permalink
Create Permuting Two Arrays.py
Browse files Browse the repository at this point in the history
  • Loading branch information
GJAnsah authored Sep 14, 2021
1 parent 92d5d2f commit 485181d
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions Permuting Two Arrays.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
'''
https://www.hackerrank.com/challenges/two-arrays/problem?isFullScreen=true&utm_campaign=challenge-recommendation&utm_medium=email&utm_source=24-hour-campaign
'''
#!/bin/python3

import math
import os
import random
import re
import sys

#
# The function is expected to return a STRING.
# The function accepts following parameters:
# 1. INTEGER k
# 2. INTEGER_ARRAY A
# 3. INTEGER_ARRAY B

def twoArrays(k, A, B):
A.sort(reverse=True)
B.sort()

sums=[x+y for x,y in zip(A,B)]

if all(ele >=k for ele in sums):
return ('YES')
else:
return ('NO')



q = int(input().strip())

for q_itr in range(q):
first_multiple_input = input().rstrip().split()

n = int(first_multiple_input[0])

k = int(first_multiple_input[1])

A = list(map(int, input().rstrip().split()))

B = list(map(int, input().rstrip().split()))

print(twoArrays(k, A, B))

0 comments on commit 485181d

Please sign in to comment.