码迷,mamicode.com
首页 > 其他好文 > 详细

Problem Single Number

时间:2014-07-07 16:04:12      阅读:178      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   color   strong   for   

Problem Description:

Given an array of integers, every element appears twice except for one. Find that single one.

Solution:

 1 public int singleNumber(int[] A) {
 2         Arrays.sort(A);
 3         for (int i = 1; i < A.length; i += 2) {
 4             if (A[i-1] != A[i]) {
 5                 return A[i-1];
 6             }
 7         }
 8 
 9         return A[A.length - 1];
10     }

 

Problem Single Number,布布扣,bubuko.com

Problem Single Number

标签:des   style   blog   color   strong   for   

原文地址:http://www.cnblogs.com/liew/p/3815083.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!