The two countries of A and B are at war against each other. Both countries have N number of soldiers. The power of these soldiers are given by A[i]...A[N] and B[i]....B[N].
These soldiers have a peculiarity. They can only attack their counterpart enemies, like A[i] can attack only B[i] and not anyone else. A soldier with higher power can kill the enemy soldier. If both soldiers have the same power, they both die. You need to find the winner country.
Example 1:
Ã¢â¬â¹Input : a[ ] = {2, 2}, b[ ] = {5, 5}
Output : B
Explanation:
Both countries have 2 soldiers.
B[0] kills A[0], B[1] kills A[1]. 
A has 0 soldiers alive at the end. 
B has both soldiers alive at the end.
Return "B" as a winner.
Ã¢â¬â¹Example 2:
Input : a[ ] = {9}, b[ ] = {8}  
Output :  A
Your Task:
This is a function problem. The input is already taken care of by the driver code. You only need to complete the function Country_at_war() that takes an array (a), another array (b), sizeOfArray (n), and return the string "A" if A is the winner, "B" if B is the winner and "DRAW" if it draws. The driver code takes care of the printing.
Expected Time Complexity: O(N).
Expected Auxiliary Space: O(1).
 
Constraints:
1 ≤ N ≤ 10^{5}
0 ≤ A_{i} ≤ 10^{7}
0 ≤ B_{i} ≤ 10^{7}

Source: geeksforgeeks | Difficulty: EASY
Tags: Data structures

Starter code: #User function Template for python3



def Country_at_war (arr, brr, n) : 

    #Complete the function



Solutions:
def Country_at_war(arr, brr, n):
	(a, b) = (0, 0)
	for i in range(n):
		if arr[i] > brr[i]:
			a += 1
		if arr[i] < brr[i]:
			b += 1
	if a > b:
		return 'A'
	elif a < b:
		return 'B'
	else:
		return 'DRAW'


def Country_at_war(arr, brr, n):
	ac = 0
	bc = 0
	for i in range(n):
		if arr[i] > brr[i]:
			ac += 1
		elif arr[i] < brr[i]:
			bc += 1
	if ac > bc:
		return 'A'
	elif bc > ac:
		return 'B'
	return 'DRAW'


def Country_at_war(arr, brr, n):
	a_win = 0
	b_win = 0
	for i in range(n):
		if arr[i] < brr[i]:
			b_win += 1
		elif arr[i] == brr[i]:
			continue
		else:
			a_win += 1
	if a_win > b_win:
		return 'A'
	elif a_win == b_win:
		return 'DRAW'
	else:
		return 'B'


def Country_at_war(arr, brr, n):
	a = n
	b = n
	for index in range(n):
		if arr[index] > brr[index]:
			b -= 1
		elif arr[index] < brr[index]:
			a -= 1
		else:
			a -= 1
			b -= 1
	if a > b:
		result = 'A'
	elif a < b:
		result = 'B'
	else:
		result = 'DRAW'
	return result


def Country_at_war(arr, brr, n):
	count_a = count_b = 0
	for i in range(n):
		if arr[i] > brr[i]:
			count_a += 1
		elif arr[i] < brr[i]:
			count_b += 1
	if count_a > count_b:
		return 'A'
	elif count_a == count_b:
		return 'DRAW'
	else:
		return 'B'


def Country_at_war(arr, brr, n):
	cnt1 = 0
	cnt2 = 0
	for i in range(n):
		if arr[i] > brr[i]:
			cnt1 = cnt1 + 1
		elif brr[i] > arr[i]:
			cnt2 = cnt2 + 1
	if cnt1 > cnt2:
		return 'A'
	elif cnt2 > cnt1:
		return 'B'
	return 'DRAW'


def Country_at_war(arr, brr, n):
	count = 0
	for i in range(n):
		count += arr[i] > brr[i]
		count -= brr[i] > arr[i]
	return 'A' if count > 0 else 'B' if count < 0 else 'DRAW'


def Country_at_war(arr, brr, n):
	A_cnt = 0
	B_cnt = 0
	for i in range(n):
		if arr[i] > brr[i]:
			A_cnt += 1
		elif arr[i] < brr[i]:
			B_cnt += 1
		else:
			A_cnt -= 1
			B_cnt -= 1
	if A_cnt > B_cnt:
		return 'A'
	elif A_cnt < B_cnt:
		return 'B'
	else:
		return 'DRAW'


def Country_at_war(arr, brr, n):
	a_c = 0
	b_c = 0
	for i in range(n):
		if arr[i] > brr[i]:
			a_c += 1
		elif arr[i] < brr[i]:
			b_c += 1
	if a_c > b_c:
		return 'A'
	elif b_c > a_c:
		return 'B'
	else:
		return 'DRAW'


def Country_at_war(arr, brr, n):
	Apoint = 0
	Bpoint = 0
	Dpoint = 0
	for i in range(n):
		if arr[i] > brr[i]:
			Apoint += 1
		elif arr[i] < brr[i]:
			Bpoint += 1
	if Apoint > Bpoint:
		return 'A'
	elif Apoint < Bpoint:
		return 'B'
	elif Apoint == Bpoint:
		return 'DRAW'


def Country_at_war(arr, brr, n):
	sum1 = 0
	sum2 = 0
	for i in range(n):
		if arr[i] > brr[i]:
			sum1 = sum1 + 1
		if brr[i] > arr[i]:
			sum2 = sum2 + 1
	if sum1 > sum2:
		return 'A'
	if sum1 < sum2:
		return 'B'
	else:
		return 'DRAW'


def Country_at_war(arr, brr, n):
	Asc = Bsc = 0
	for i in range(n):
		if arr[i] == brr[i]:
			continue
		if arr[i] > brr[i]:
			Asc += 1
		else:
			Bsc += 1
	if Asc == Bsc:
		return 'DRAW'
	elif Asc > Bsc:
		return 'A'
	else:
		return 'B'


def Country_at_war(arr, brr, n):
	x = 0
	y = 0
	for i in range(n):
		if arr[i] > brr[i]:
			x = x + 1
		if arr[i] < brr[i]:
			y = y + 1
	if x > y:
		return 'A'
	if x < y:
		return 'B'
	else:
		return 'DRAW'


def Country_at_war(arr, brr, n):
	(c1, c2) = (0, 0)
	for i in range(n):
		if arr[i] > brr[i]:
			c1 += 1
		if arr[i] < brr[i]:
			c2 += 1
	if c1 == c2:
		return 'DRAW'
	elif c1 > c2:
		return 'A'
	else:
		return 'B'


def Country_at_war(arr, brr, n):
	a = len(arr)
	b = len(brr)
	for i in range(n):
		if arr[i] > brr[i]:
			b -= 1
		if brr[i] > arr[i]:
			a -= 1
	if a == b:
		return 'DRAW'
	if a > b:
		return 'A'
	if b > a:
		return 'B'


def Country_at_war(arr, brr, n):
	Awin = 0
	Bwin = 0
	for x in range(n):
		if arr[x] > brr[x]:
			Awin += 1
		elif arr[x] < brr[x]:
			Bwin += 1
	if Awin > Bwin:
		return 'A'
	elif Awin < Bwin:
		return 'B'
	else:
		return 'DRAW'


def Country_at_war(arr, brr, n):
	e = 0
	o = 0
	for i in range(n):
		if arr[i] > brr[i]:
			e += 1
		elif brr[i] > arr[i]:
			o += 1
	if e > o:
		return 'A'
	elif o > e:
		return 'B'
	return 'DRAW'
for _ in range(0, int(input())):
	n = int(input())
	arr = list(map(int, input().strip().split()))
	brr = list(map(int, input().strip().split()))
	ans = Country_at_war(arr, brr, n)
	print(ans)


def Country_at_war(arr, brr, n):
	ac = 0
	bc = 0
	for i in range(n):
		if arr[i] > brr[i]:
			ac += 1
		if arr[i] < brr[i]:
			bc += 1
	if ac > bc:
		return 'A'
	if ac < bc:
		return 'B'
	return 'DRAW'
for _ in range(0, int(input())):
	n = int(input())
	arr = list(map(int, input().strip().split()))
	brr = list(map(int, input().strip().split()))
	ans = Country_at_war(arr, brr, n)
	print(ans)


def Country_at_war(a, b, n):
	a = 0
	b = 0
	for i in range(n):
		if arr[i] > brr[i]:
			a = a + 1
		if arr[i] < brr[i]:
			b = b + 1
	if a > b:
		return 'A'
	if a < b:
		return 'B'
	else:
		return 'DRAW'
for _ in range(0, int(input())):
	n = int(input())
	arr = list(map(int, input().strip().split()))
	brr = list(map(int, input().strip().split()))
	ans = Country_at_war(arr, brr, n)
	print(ans)


def Country_at_war(arr, brr, n):
	count1 = 0
	count2 = 0
	for itr in range(n):
		if arr[itr] > brr[itr]:
			count1 += 1
		elif arr[itr] < brr[itr]:
			count2 += 1
	if count1 > count2:
		return 'A'
	elif count1 < count2:
		return 'B'
	else:
		return 'DRAW'
for _ in range(0, int(input())):
	n = int(input())
	arr = list(map(int, input().strip().split()))
	brr = list(map(int, input().strip().split()))
	ans = Country_at_war(arr, brr, n)
	print(ans)


def Country_at_war(arr, brr, n):
	a_sum = 0
	b_sum = 0
	for (i, j) in zip(arr, brr):
		if i > j:
			a_sum += 1
		elif j > i:
			b_sum += 1
		elif j == i:
			a_sum -= 1
			b_sum -= 1
	if a_sum > b_sum:
		return 'A'
	elif b_sum > a_sum:
		return 'B'
	else:
		return 'DRAW'
for _ in range(0, int(input())):
	n = int(input())
	arr = list(map(int, input().strip().split()))
	brr = list(map(int, input().strip().split()))
	ans = Country_at_war(arr, brr, n)
	print(ans)


def Country_at_war(arr, brr, n):
	li = [0] * n
	pos = 0
	neg = 0
	for i in range(n):
		li[i] = arr[i] - brr[i]
	for i in li:
		if i > 0:
			pos += 1
		elif i < 0:
			neg += 1
	if pos > neg:
		return 'A'
	elif neg > pos:
		return 'B'
	else:
		return 'DRAW'


def Country_at_war(arr, brr, n):
	ca = 0
	cb = 0
	for i in range(n):
		if arr[i] > brr[i]:
			ca += 1
		elif arr[i] < brr[i]:
			cb += 1
	if ca == cb:
		return 'DRAW'
	elif ca > cb:
		return 'A'
	else:
		return 'B'


def Country_at_war(arr, brr, n):
	awin = 0
	bwin = 0
	for i in range(0, n):
		if arr[i] > brr[i]:
			awin += 1
		elif arr[i] < brr[i]:
			bwin += 1
	if awin > bwin:
		return 'A'
	elif awin < bwin:
		return 'B'
	else:
		return 'DRAW'