题解 | 草原牛群集合

草原牛群集合

https://www.nowcoder.com/practice/6fc74519ff9c44288dbcec5db7345ded

  1. 插入即可。

import java.util.*;


public class Solution {
    public int remove_cows (int[] nums, int val) {
        final int n = nums.length;
        int next = 0;
        for (int i = 0; i < n; ++i) {
            if (nums[i] != val) {
                nums[next] = nums[i];
                ++next;
            }
        }
        return next;
    }
}

全部评论

相关推荐

Java转测开第一人:这种就是饼 把应届当廉价劳动力用完然后丢掉
你觉得今年秋招难吗
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务