Shawn's Blog

  • Home
  • Tags
  • Categories
  • Archives
  • Search
  • Table of Contents
  • Overview

Shawn

若有恒,何必三更眠五更起;最无益,莫过一日曝十日寒。
392 posts
13 categories
114 tags

LeetCode 27. Remove Element

Posted on 2021-04-20 Edited on 2024-11-24 In LeetCode
1
2
3
4
5
6
7
8
9
10
11
12
class Solution {
public:
int removeElement(vector<int>& nums, int val) {
int i = 0, j = 0;
for (int num : nums) {
if (num != val)
nums[i++] = num;
++j;
}
return i;
}
};
# Array# Two Pointers
LeetCode 1829. Maximum XOR for Each Query
LeetCode 363. Max Sum of Rectangle No Larger Than K
© 2024 Shawn
Powered by Hexo & NexT.Mist
0%