Given two arrays of equal size N and an integer K. The task is to check if after permuting both arrays, we get sum of their corresponding element greater than or equal to k i.e A_{i} + B_{i} >= K for all i (from 0 to N-1). Return true if possible, else false.
 
Example 1:
Input : 
a[] = {2, 1, 3}, 
b[] = { 7, 8, 9 }, 
k = 10. 
Output : 
True
Explanation:
Permutation  a[] = { 1, 2, 3 } 
and b[] = { 9, 8, 7 } 
satisfied the condition a[i] + b[i] >= K.
 
Example 2:
Input : 
a[] = {1, 2, 2, 1}, b[] = { 3, 3, 3, 4 }, k = 5.
Output : 
False
Explanation:
Since any permutation won't give the answer.
 
Your Task:  
You don't need to read input or print anything. Your task is to complete the function isPossible() which takes the array A[], B[], its size N and an integer K as inputs and returns the answer.
Expected Time Complexity: O(N. Log(N))
Expected Auxiliary Space: O(1)
 
Constraints:
1 ≤ N ≤ 10^{5}
1 ≤ K ≤ 10^{18 }
1 ≤ A_{i}, B_{i} ≤ 10^{17}

Difficulty: EASY
Tags: Sorting

Data structures
Skill types: Sorting

Data structures
Expected Time Complexity: O(N. Log(N))
Expected Auxiliary Space: O(1)

Starter code:
#User function Template for python3



class Solution:

    def isPossible(self,a, b, n, k):

    # Your code goes here



Solutions:
class Solution:

	def isPossible(self, a, b, n, k):
		a.sort()
		b.sort(reverse=True)
		for i in range(n):
			if a[i] + b[i] < k:
				return False
		return True


class Solution:

	def isPossible(self, a, b, n, k):
		yes = True
		for x in range(0, len(a)):
			if a[x] + b[x] >= k:
				return yes
		return False


class Solution:

	def isPossible(self, a, b, n, k):
		if max(a) + max(b) >= k:
			return True
		return False


class Solution:

	def isPossible(self, a, b, n, k):
		aa = sorted(a)
		bb = sorted(b, reverse=True)
		for i in range(len(aa)):
			if aa[i] + bb[i] < k:
				return False
		return True


class Solution:

	def isPossible(self, a, b, n, k):
		a.sort()
		b.sort(reverse=True)
		p = 0
		for i in range(len(a)):
			if a[i] + b[i] >= k:
				continue
			else:
				p = 1
				return False
		if p == 0:
			return True


class Solution:

	def isPossible(self, a, b, n, k):
		a.sort()
		b.sort()
		for l in range(n - 1):
			if a[l] + b[l] >= k:
				return True
		return False


class Solution:

	def isPossible(self, a, b, n, k):
		a.sort()
		b.sort()
		b = b[::-1]
		if a[0] + b[0] >= k:
			return True
		else:
			return False
		return False


class Solution:

	def isPossible(self, a, b, n, k):
		a.sort()
		b.sort(reverse=True)
		i = 0
		while i < n:
			if not a[i] + b[i] >= k:
				return False
			i += 1
		return True


class Solution:

	def isPossible(self, a, b, n, k):
		(maxA, maxB) = (-1, -1)
		for i in range(n):
			if a[i] >= maxA:
				maxA = a[i]
			if b[i] >= maxB:
				maxB = b[i]
			if maxA + maxB >= k:
				return True
		return False


class Solution:

	def isPossible(self, a, b, n, k):
		return max(a) + max(b) >= k


class Solution:

	def isPossible(self, a, b, n, k):
		for (a, b) in zip(sorted(a), sorted(b, reverse=True)):
			if a + b < k:
				return False
		return True


class Solution:

	def isPossible(self, a, b, n, k):
		if int((sum(a) + sum(b)) / n) >= k:
			return True
		return False


class Solution:

	def isPossible(self, a, b, n, k):
		for i in range(len(a)):
			x = a[i]
			y = b[i]
			if x + y >= k:
				z = 1
			else:
				z = 0
		return z


class Solution:

	def isPossible(self, a, b, n, k):
		count = 0
		if len(a) != len(b):
			return False
		for i in range(len(a)):
			if a[i] + b[i] >= k:
				count = count + 1
		return count


class Solution:

	def isPossible(self, a, b, n, k):
		a.sort()
		b.sort(key=lambda x: -x)
		for i in range(n):
			if a[i] + b[i] < k:
				return False
		return True


class Solution:

	def isPossible(self, a, b, n, k):
		c = 0
		a = sorted(a)
		b = sorted(b)[::-1]
		for i in range(n):
			if a[i] + b[i] >= k:
				c += 1
		if c == n:
			return True
		return False


class Solution:

	def isPossible(self, a, b, n, k):
		ans = []
		a = sorted(a, reverse=True)
		b = sorted(b)
		for i in range(len(a)):
			ans.append(a[i] + b[i])
		ans.sort()
		if ans[0] >= k:
			return True
		return False


class Solution:

	def isPossible(self, a, b, n, k):
		a = sorted(a)
		b = sorted(b, reverse=True)
		return all([a[i] + b[i] >= k for i in range(n)])


class Solution:

	def isPossible(self, a, b, n, k):
		for i in range(0, len(a)):
			for j in range(0, len(b)):
				if a[i] + b[j] >= k:
					return True


class Solution:

	def isPossible(self, a, b, n, k):
		for i in range(0, n, 1):
			if a[i] + b[i] >= k:
				flag = True
			else:
				flag = False
		return flag


class Solution:

	def isPossible(self, a, b, n, k):
		c = max(a)
		d = max(b)
		ans = c + d
		return ans > k


class Solution:

	def isPossible(self, a, b, n, k):
		if min(a) + max(b) < k or min(b) + max(a) < k:
			return 0
		return 1


class Solution:

	def isPossible(self, a, b, n, k):
		if min(a) + max(b) < k and min(b) + max(a) < k:
			return 0
		elif min(a) + min(b) >= k:
			return 1
		else:
			a.sort()
			b.sort()
			b.reverse()
			for i in range(0, n):
				if a[i] + b[i] >= k:
					continue
				else:
					return 0
			return 1


class Solution:

	def isPossible(self, a, b, n, k):
		for i in range(min(len(a), len(b))):
			if a[i] + b[i] >= k:
				return True
		return False


class Solution:

	def isPossible(self, a, b, n, k):
		sorted_a = sorted(a)
		sorted_b = sorted(b, reverse=True)
		for i in range(n):
			if sorted_a[i] + sorted_b[i] < k:
				return False
		return True