My issue
I need python code for this solution can anyone help me with this
Problem Link: Box Game Practice Coding Problem - CodeChef
I need python code for this solution can anyone help me with this
Problem Link: Box Game Practice Coding Problem - CodeChef
@sudarshana_rao
plzz refer the following code
# cook your dish here
t = int(input())
for _ in range(t):
temp = input().split()
n, k, p = int(temp[0]), int(temp[1]), int(temp[2])
arr = list(map(int,input().split()))
if not p:
maxim = max(arr)
mini_arr = arr[1]
for i in range(1,n-1):
current = min(arr[i-1],arr[i+1])
mini_arr = max(mini_arr,current)
mini_arr = max(mini_arr, arr[n-2])
if k % 2 == 0:
print(mini_arr)
else:
print(maxim)
else:
maxim = min(arr)
mini_arr = arr[1]
for i in range(1,n-1):
current = max(arr[i-1],arr[i+1])
mini_arr = min(mini_arr,current)
mini_arr = min(mini_arr, arr[n-2])
if k % 2 == 0:
print(mini_arr)
else:
print(maxim)