LeeCode 删除数组中某一特定值的元素,并返回新的数组长度

LeeCode 删除数组中某一特定值的元素,并返回新的数组长度

分类:C语言

题目:

Given an array and a value, remove all instances of that value in place and return the new length.

The order of elements can be changed. It doesn’t matter what you leave beyond the new length.

C代码:

int removeElement(int* nums, int numsSize, int val) {int count = 0;for(int i = 0; i<numsSize ; i++){if(nums[i] != val){nums[count++] = nums[i];}}return count;}

上一篇LeeCode 连接两个有序单链表下一篇华为笔试&程序员面试宝典——选秀节目打分

顶0踩0

,欲望以提升热忱,毅力以磨平高山。

LeeCode 删除数组中某一特定值的元素,并返回新的数组长度

相关文章:

你感兴趣的文章:

标签云: