GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — leetcode/code/lc26.java at master · mJackie/leetcode Expand file tree/ Copy pathlc26.javaMore file actions 28 lines (27 loc) · 674 Bytes / Copy pathlc26.javaFile metadata and controls28 lines (27 loc) · 674 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 package code; /* * 26. Remove Duplicates from Sorted Array * 题意:移除数组中重复元素 * 难度:Easy * 分类:Array, Two Pointers * lc27 */ public class lc26 { public static void main(String[] args) { int[] nums = {0,0,1,1,1,2,2,3,3,4}; int n = removeDuplicates(nums); for (int i = 0; i <n ; i++) { System.out.println(nums[i]); } } public static int removeDuplicates(int[] nums) { int n = 1; for (int i = 1; i < nums.length ; i++) { if(nums[i]!=nums[i-1]){ nums[n] = nums[i]; n++; } } return n; } } |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |