classSolution{public:intmaxJump(vector<int>&stones){// Let's denote the forwarding path as F and the backwarding path as B.// "F1 B2 B1 F2" is no better than "F1 B2 F2 B1" since the distance between// F1 and F2 increase, resulting a larger `ans`.intans=stones[1]-stones[0];// If there're only two stones.for(inti=2;i<stones.size();++i)ans=max(ans,stones[i]-stones[i-2]);returnans;}};

1 2 3 4 5 6 7 8 91011

classSolution{publicintmaxJump(int[]stones){// Let's denote the forwarding path as F and the backwarding path as B.// "F1 B2 B1 F2" is no better than "F1 B2 F2 B1" since the distance between// F1 and F2 increase, resulting a larger `ans`.intans=stones[1]-stones[0];// If there're only two stones.for(inti=2;i<stones.length;++i)ans=Math.max(ans,stones[i]-stones[i-2]);returnans;}}

123456789

classSolution:defmaxJump(self,stones:List[int])->int:# Let's denote the forwarding path as F and the backwarding path as B.# 'F1 B2 B1 F2' is no better than 'F1 B2 F2 B1' since the distance between# F1 and F2 increase, resulting a larger `ans`.iflen(stones)==2:returnstones[1]-stones[0]returnmax(stones[i]-stones[i-2]foriinrange(2,len(stones)))