摘要: Reverse digits of an integer. Returns 0 when the reversed integer overflows (signed 32-bit integer). Example Given x = 123, return 321 Given x = -123, 阅读全文
posted @ 2017-09-12 21:41 jasminemzy 阅读(90) 评论(0) 推荐(0) 编辑
摘要: Given 2*n + 2 numbers, every numbers occurs twice except two, find them. Given [1,2,2,3,4,4,5,3] return 1 and 5 全异或剩两数temp=a^b,temp &= -temp, 用if(temp 阅读全文
posted @ 2017-09-12 15:42 jasminemzy 阅读(114) 评论(0) 推荐(0) 编辑
摘要: Given 3*n + 1 numbers, every numbers occurs triple times except one, find it. Given [1,1,2,3,3,3,2,2,4,1] return 4 法1:加和掩码提取位,模三,加到结果里。int 数据共有32位,针对其 阅读全文
posted @ 2017-09-12 13:54 jasminemzy 阅读(128) 评论(0) 推荐(0) 编辑
摘要: 给出2*n + 1 个的数字,除其中一个数字之外其他每个数字均出现两次,找到这个数字。一次遍历,O(1)空间 利用异或运算的两个特性——1.自己与自己异或结果为0,2.异或满足交换律。 把所有数字异或起来就是答案。 public class Solution { /* * @param A: An 阅读全文
posted @ 2017-09-12 13:33 jasminemzy 阅读(99) 评论(0) 推荐(0) 编辑