leetcode 27 Remove Element(移除数组中的与val相等的元素)
2017-03-31 16:53
489 查看
27. Remove Element
DescriptionGiven an array and a value, remove all instances of that value in place and return the new length.
Do not allocate extra space for another array, you must do this in place with constant memory.
The order of elements can be changed. It doesn't matter what you leave beyond the new length.
Example:
Given input array nums =
[3,2,2,3], val =
3
Your function should return length = 2, with the first two elements ofnums being 2.
这题有点像
leetcode26
int removeElement(int* nums, int numsSize, int val) { int i,iterator=0;; for(i=0;i<numsSize;i++){ if(nums[i]!=val){ nums[iterator++]=nums[i]; }else{ continue; } } return iterator; }
相关文章推荐
- Leetcode27:Remove Element(移除数组中指定的元素)
- 27. Remove Element(移除数组中与指定值相等的元素)
- 【LeetCode】27. Remove Element(移除元素)
- LeetCode 27. Remove Element(移除给定值元素)
- leetcode 27. Remove Element(C语言,快速排序思想,剔除数组中与目标值相等的数)20
- [C++]LeetCode 27: Remove Element(删除数组中指定元素)
- Leetcode刷题记—— Remove Duplicates from Sorted Array II(已排序数组移除重复元素2)
- leetCode26 Remove Duplicates from Sorted Array(移除多余的重复数组元素)
- LeetCode 27 Remove Element (移除数组中指定元素)
- leetcode 4. 移除有序数组中的重复元素 Remove Duplicates from Sorted Array
- LeetCode 27. Remove Element(删除元素)
- LeetCode 26 Remove Duplicates from Sorted Array(从已排序数组中移除重复元素)
- leetcode 27. Remove Element移出元素(双指针)
- LeetCode 26 Remove Duplicates from Sorted Array(从已排序数组中移除重复元素)
- LeetCode27——Remove Element(移除数组中指定的元素)
- java算法之简单的移除数组中的指定元素Remove Element
- LeetCode 80 Remove Duplicates from Sorted Array II(移除数组中出现两次以上的元素)
- leetCode 27.Remove Element (删除元素) 解题思路和方法
- LeetCode 26. Remove Duplicates from Sorted Array(移除有序数组的重复元素)
- leetCode 27.Remove Element (删除元素) 解题思路和方法