添加0027.移除元素.md JavaScript版本。

This commit is contained in:
露从今夜白 2021-05-12 13:15:11 +08:00 committed by GitHub
parent 4cbdfc079e
commit 74ba60e18a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 1 deletions

View File

@ -131,7 +131,20 @@ Python
Go
JavaScript:
```
//时间复杂度O(n)
//空间复杂度O(1)
var removeElement = (nums, val) => {
let k = 0;
for(let i = 0;i < nums.length;i++){
if(nums[i] != val){
nums[k++] = nums[i]
}
}
return k;
};
```
-----------------------
* 作者微信:[程序员Carl](https://mp.weixin.qq.com/s/b66DFkOp8OOxdZC_xLZxfw)