classSolution{public:// Similar to 3205. Maximum Array Hopping Score IlonglongfindMaximumScore(vector<int>&nums){// The optimal jump is the nearest index j > i s.t. nums[j] > nums[i].longans=0;intmx=0;for(constintnum:nums){ans+=mx;mx=max(mx,num);}returnans;}};
1 2 3 4 5 6 7 8 9101112131415
classSolution{// Similar to 3205. Maximum Array Hopping Score IpubliclongfindMaximumScore(List<Integer>nums){// The optimal jump is the nearest index j > i s.t. nums[j] > nums[i].longans=0;intmx=0;for(finalintnum:nums){ans+=mx;mx=Math.max(mx,num);}returnans;}}
1234
classSolution:# Similar to 3205. Maximum Array Hopping Score IdeffindMaximumScore(self,nums:list[int])->int:returnsum(itertools.accumulate(nums[:-1],max))