标签:style blog http color os art
1 public class Solution { 2 public int firstMissingPositive(int[] A) { 3 HashSet<Integer> hash=new HashSet<Integer>(); 4 int count=0; 5 int sum=0; 6 7 for(int i:A) 8 { 9 if(i>0) 10 { 11 hash.add(i); 12 } 13 } 14 15 int beg=1; 16 while(hash.contains(beg)) 17 { 18 beg++; 19 20 21 } 22 23 return beg; 24 25 26 27 } 28 }
1 public class Solution { 2 public int firstMissingPositive(int[] A) { 3 HashSet<Integer> hash=new HashSet<Integer>(); 4 int count=0; 5 int sum=0; 6 7 for(int i:A) 8 { 9 if(i>0) 10 { 11 hash.add(i); 12 } 13 } 14 15 int beg=1; 16 while(hash.contains(beg)) 17 { 18 beg++; 19 20 21 } 22 23 return beg; 24 25 26 27 } 28 }
w Code
leetcode First Missing Positive hashset简单应用,布布扣,bubuko.com
leetcode First Missing Positive hashset简单应用
标签:style blog http color os art
原文地址:http://www.cnblogs.com/hansongjiang/p/3841566.html