image.png

解题思路-单向双指针

image.png

  • 对于某一L,R停留在Sum(L,R)>=S的最左届,当L向右走时,R只可能向右走。

类似地有该题,只是具体细节需要改变。
image.png

image.png