You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<videosrc='../video/15.三数之和.mp4'controls='controls'width='640'height='320'autoplay='autoplay'> Your browser does not support the video tag.</video></div>
<videosrc='../video/15.三数之和.mp4'controls='controls'width='640'height='320'autoplay='autoplay'> Your browser does not support the video tag.</video></div>
<videosrc='../video/26.删除排序数组中的重复项.mp4'controls='controls'width='640'height='320'autoplay='autoplay'> Your browser does not support the video tag.</video></div>
<videosrc='../video/27.移除元素-暴力解法.mp4'controls='controls'width='640'height='320'autoplay='autoplay'> Your browser does not support the video tag.</video></div>
<videosrc='../video/27.移除元素.mp4'controls='controls'width='640'height='320'autoplay='autoplay'> Your browser does not support the video tag.</video></div>
53
+
54
+
代码如下:
55
+
```
56
+
// 时间复杂度:O(n)
57
+
// 空间复杂度:O(1)
58
+
class Solution {
59
+
public:
60
+
int removeElement(vector<int>& nums, int val) {
61
+
int slowIndex = 0; // index为 慢指针
62
+
for (int fastIndex = 0; fastIndex < nums.size(); fastIndex++) { // i 为快指针
63
+
if (val != nums[fastIndex]) { //将快指针对应的数值赋值给慢指针对应的数值
0 commit comments