博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
26. Remove Duplicates from Sorted Array java solutions
阅读量:4349 次
发布时间:2019-06-07

本文共 711 字,大约阅读时间需要 2 分钟。

Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.

Do not allocate extra space for another array, you must do this in place with constant memory.

For example,

Given input array nums = [1,1,2],

Your function should return length = 2, with the first two elements of nums being 1 and 2 respectively. It doesn't matter what you leave beyond the new length.

to see which companies asked this question

 
1 public class Solution { 2     public int removeDuplicates(int[] nums) { 3         if(nums.length == 0 || nums.length == 1) return nums.length; 4         int len = 1; 5         for(int i = 1;i

 

转载于:https://www.cnblogs.com/guoguolan/p/5453234.html

你可能感兴趣的文章
JQuery 实现返回顶部效果
查看>>
辛苦挣钱买房,结果房产证一直办不下来
查看>>
Which kind of aspects of OIL PRESS MACHINERY would you like best
查看>>
[转载] 晓说——第17期:揭秘战争秘闻 朝鲜战争62年祭(下)
查看>>
java集合系列之ArrayList源码分析
查看>>
nyoj 518取球游戏(博弈)
查看>>
实验5
查看>>
luogu P1252 马拉松接力赛 P1803 凌乱的yyy / 线段覆盖
查看>>
11. 鼠标移到物体上高亮显示轮廓
查看>>
VS C++ DLL速度问题
查看>>
JavaScript弹出式日历控件 无jquery
查看>>
HTML5方向键控制会奔跑的马里奥大叔
查看>>
上周热点回顾(4.28-5.4)
查看>>
上周热点回顾(1.29-2.4)
查看>>
找到问题的真正原因:20121021服务器故障处理经历
查看>>
work of weekend 12/12/2015~12/14/2015
查看>>
命令行jarsigner签字和解决找不到证书链错误
查看>>
在学习ASP.NET中,GridView 控件的RowDataBound事件的使用详解
查看>>
Python实现与LeetCode--栈
查看>>
Duplicate files copied in APK META-INF/LICENSE.txt
查看>>