Open yokostan opened 5 years ago
Just store every start index for each value and at end index plus one minus it
for example it will look like:
[1 , 3 , 2] , [2, 3, 3] (length = 5)
res[ 0, 2, ,0, 0 -2 ]
res[ 0 ,2, 3, 0, -5]
sum 0, 2, 5, 5, 0
res[0, 2, 5, 5, 0]
Brute Force, beats 27%: