1. /**
  2. * Source : https://oj.leetcode.com/problems/remove-element/
  3. *
  4. * Created by lverpeng on 2017/7/12.
  5. *
  6. * Given an array and a value, remove all instances of that value in place and return the new length.
  7. *
  8. * The order of elements can be changed. It doesn't matter what you leave beyond the new length.
  9. */
  10. public class RemoveElement {
  11. /**
  12. * 判断不等于value的值个数
  13. * @param num
  14. * @param value
  15. * @return
  16. */
  17. public int remove (int[] num, int value) {
  18. int pos = 0;
  19. for (int i = 0; i < num.length; i++) {
  20. if (num[i] != value) {
  21. pos ++;
  22. }
  23. }
  24. return pos;
  25. }
  26. public static void main(String[] args) {
  27. RemoveElement removeElement = new RemoveElement();
  28. int[] num = new int[]{1,2,3,4,5,5,6};
  29. System.out.println(removeElement.remove(num, 5));
  30. }
  31. }

leetcode — remove-element的更多相关文章

  1. [LeetCode] Remove Element 分析

    Remove Element算是LeetCode的一道水题,不过这题也有多种做法,现就我所知的几种做一点讨论. 题目链接:https://leetcode.com/problems/remove-el ...

  2. [LeetCode] Remove Element题解

    Remove Element: Given an array and a value, remove all instances of that value in place and return t ...

  3. [LeetCode] Remove Element 移除元素

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

  4. LeetCode Remove Element

    原题链接在这里:https://leetcode.com/problems/remove-element/ 题目: Given an array and a value, remove all ins ...

  5. [LeetCode] Remove Element (三种解法)

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

  6. LeetCode——Remove Element

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

  7. [Leetcode] remove element 删除元素

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

  8. leetcode Remove Element python

    class Solution(object): def removeElement(self, nums, val): """ :type nums: List[int] ...

  9. LeetCode Remove Element删除元素

    class Solution { public: int removeElement(int A[], int n, int elem) { ]; int i,num=n; ;i<n;i++){ ...

  10. [Leetcode][Python]27: Remove Element

    # -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com' 27: Remove Elementhttps://oj.leetcode.c ...

随机推荐

  1. docker 支持ipv6 (核心要点是ndp需要把docker内的ip全部加入到ndplist中来)

    IPv6 with Docker Estimated reading time: 10 minutes The information in this section explains IPv6 wi ...

  2. maven 项目中没有src/test/java文件夹

    项目右键->buildPath configure Build Path->点击选项卡Libraries->选中JRE System Library->点击edit->选 ...

  3. Windows查看服务

    开始→运行(Windows+R快捷键也能调出运行)→输入:services.msc→确定

  4. 安装zookeeper(单机,伪集群)

    1.登陆zookeeper官网下载 https://zookeeper.apache.org/ zookeeper-3.4.8.tar.gz 解压:tar -zxvf zookeeper-3.4.8. ...

  5. Paper | 块分割信息 + 压缩视频质量增强

    目录 1. 亮点 2. 网络 3. Mask 及其融合 4. 结论 论文:Enhancing HEVC Compressed Videos with a Partition-Masked Convol ...

  6. Delphi调用SQL分页存储过程实例

    Delphi调用SQL分页存储过程实例 (-- ::)转载▼ 标签: it 分类: Delphi相关 //-----下面是一个支持任意表的 SQL SERVER2000分页存储过程 //----分页存 ...

  7. Presto + Superset 数据仓库及BI

    基于Presto和superset搭建数据分析平台. Presto可以作为数据仓库,能够连接多种数据库和NoSql,同时查询性能很高: Superset提供了Presto连接,方便数据可视化和dash ...

  8. pyg 图片服务器中使用的nginx 编译位置

    ./nginx 启动

  9. VMware Tools安装教程

    安装依赖: sudo yum install eject 步骤: 确保 Linux 虚拟机已打开电源. 如果正在运行 GUI 界面,请打开命令 shell. 注意:以 root 用户身份登录,或使用 ...

  10. Go语言数据类型

    目录 基本数据类型说明 整型 浮点型 字符 字符类型本质探讨 布尔型 字符串 指针 值类型与引用类型 基本数据类型默认值 基本数据类型相互转换 注意事项 其他基本类型转string类型 string类 ...