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

代码如下:

 public class Solution {
public int singleNumber(int[] nums) {
if(nums.length==1||nums.length==2)
return nums[0];
Arrays.sort(nums);
for(int i=0;i<nums.length-2;)
{
if(nums[i]==nums[i+1]&&nums[i]==nums[i+2])
i=i+3;
else return nums[i];
}
return nums[nums.length-1];
}
}

最新文章

  1. Java学习笔记1
  2. Set up Github Pages with Hexo, migrating from Jekyll
  3. 错误 1 “System.Data.DataRow.DataRow(System.Data.DataRowBuilder)”不可访问,因为它受保护级别限制
  4. MySQL遇到check the manual that corresponds to your MySQL server version for the right syntax错误
  5. poj题目必做
  6. MapReduce 重要组件——Recordreader组件
  7. ZOJ Problem Set - 3329 One Person Game
  8. Case swapping
  9. Python核心编程2第六章课后练习
  10. 自定义配置文件的使用(web.config/app.config)
  11. Enum基础
  12. UVA 11427 - Expect the Expected(概率递归预期)
  13. [Usaco2008 Nov]Buying Hay 购买干草[背包]
  14. 20155324王鸣宇 《网络对抗技术》Web基础
  15. Git——如何将本地项目提交至远程仓库(第一次)
  16. 搭建redis-sentinel(哨兵机制)集群
  17. iOS逆向开发(2):获取APP的类声明 | class-dump | dumpdecrypted
  18. ASP.NET Identity详解
  19. EZ1105
  20. 以快板之名说Android 应用程序电源管理

热门文章

  1. bzoj 1934: [Shoi2007]Vote 善意的投票
  2. load image
  3. 企业需要k2来解放孤岛危机
  4. JAVA学习1
  5. [网络技术][转]PPTP协议解析
  6. DataNode,NameNode,JobTracker,TaskTracker用jps查看无法启动解决办法
  7. C语言:typedef 跟 define 的区别
  8. 转载--Ubuntu设置环境变量
  9. mahout中kmeans算法和Canopy算法实现原理
  10. 多动手试试,其实List类型的变量在页面上取到的值可以直接赋值给一个js的Array数组变量