题目: 解答: 类似题26,注意下删除后的元素的移动方式即可 代码: class Solution {public:int removeElement(vector<int>& nums, int val) {if(nums.empty()) return 0;int len = nums.size();int lenafter = 0, head = 0;for(int i
题目1 : Lost in the City 时间限制: 10000ms 单点时限: 1000ms 内存限制: 256MB 描述 Little Hi gets lost in the city. He does not know where he is. He does not know which direction is north. Fortunately
int removeElement(vector<int>& nums, int val) {int n=nums.size();if(n==0)return 0;for(int i=0;i<n-1;){if(nums[i]==val){for(int j=i+1;j<n;j++)nums[j-1]=nums[j];n--;}if(nums[i]!=val)i++;}if(nums[nums.