[C++ 算法] 9.四数之和的双_指针图
最编程
2024-10-05 06:58:38
...
nums=[1,0,-1,0,-2,2]
target=0
n=6,i=0,j=1,left=2,right=5,aim=-1
left<right,sum=-1+2=1>aim,right--
left<right,sum=-1-2=-3<aim,left++
-
left<right,sum=0-2=-2<aim,left++
-
不满足循环条件,跳出
while
循环,进入去重2
,j++
-
n=6,i=0,j=2,left=3,right=5,aim=0
-
后面的步骤类似,就不多赘述了。
下一篇: 关于通过存储卡更新 S7-1200 程序