My issue
Sample test case is passed but still Status is : Time Limit Exceeded
This is the code :
t=int(input())
for s in range(t):
n=int(input())
x=list(map(int,input().split()))
y =
i=0
res=
while i<n:
a=x[-1]
y.append(a)
y.extend(x)
y.pop()
res.append(y[0]+y[-1])
x=y
y=
i+=1
print(max(res))
Sample Input
3
2
5 8
3
5 10 15
4
4 4 4 4
Your Output
13
25
8
My code
t=int(input())
for s in range(t):
n=int(input())
x=list(map(int,input().split()))
y = []
i=0
res=[]
while i<n:
a=x[-1]
y.append(a)
y.extend(x)
y.pop()
res.append(y[0]+y[-1])
x=y
y=[]
i+=1
print(max(res))
Learning course: Solve Programming problems using Python
Problem Link: Debug this code - First and Last Practice Problem in Solve Programming problems using Python - CodeChef