HELP! March Lunchtime Problem Div 2 HELP NEEDED IN PRACTICE QUESTION

Can someone please tell me why this solution doesn’t work for POGOSTCK problem

def getMax(arr):
s = 0
for i in range(len(arr)):
    sm = sum(arr[i::1])
    s = max(sm , s)

return s

for _ in range(int(input())):
n ,k = map(int, input().split())
a = list(map(int, input().split()))
maxi = 0
if k >= n:
print(max(a))
else:
s = 0
for i in range(k):
sm = getMax(a[i::k])
s = max(s , sm)
print(s)

Thanks for Your time and sorry if it was a stupid question :slight_smile:
And please ignore the indentation errors in here

Its always better to provide a link to your submission than posting the whole code.
For this problem you need to use the concept of suffix array.
I think you are taking max of k elements which cannot be done read the question twice.

1 Like

Can somebody provide a test case wherein it shouldnt work ??

Please tell me . I know the correct ans is using a suffix array and iterating over but I cant get why my solution is not coming out to be right
Maybe a test case where it proves false might help.
Thanks
And yeah I’ll put up the solution link (my ans )in a while aswell

Got the answer Thanks for your support though.
The main problem was simple i did not consider negative cases
i.e I compared max(sm , 0) instead of max(sm , -999999)
Silly !! xd But finally got the answer