DE-Shaw intern question(2021).How to solve??
Anonymous User
755

An array of length n is given.Each element of array can be positive negative or 0.YOu can make a jump of length k each time.You have a score s initially.If you are on position i then u cn jump to position i+k if i+k<n and your score becomes score=score+arr[i+k].if score becomes lesser than or equal to 0 then u stop.Amongst all the elements of array u hv to chose a starting position of array from where u have to start jumping untill u reach end or score becomes 0.Find that starting position such that u obtain maximum score from that when u end.Ex arr=[1,2,-5,9,-4],k=2then my steps will be position 1 to position 3 then end of array score=2+9=11.

Comments (2)