摘要: power of two http://www.cnblogs.com/-1307/p/6907811.html Add Digits https://leetcode.com/problems/add-digits/#/solutions 各位数相加 0 1 2 3 4 5 6 7 8 9 10 阅读全文
posted @ 2017-06-03 17:18 D-Dong 阅读(197) 评论(0) 推荐(0) 编辑
摘要: Details Basics At the heart of bit manipulation are the bit-wise operators & (and), | (or), ~ (not) and ^ (exclusive-or, xor) and shift operators a << 阅读全文
posted @ 2017-06-02 20:46 D-Dong 阅读(458) 评论(0) 推荐(0) 编辑
摘要: Given a word, you need to judge whether the usage of capitals in it is right or not. We define the usage of capitals in a word to be right when one of 阅读全文
posted @ 2017-06-02 10:22 D-Dong 阅读(245) 评论(0) 推荐(0) 编辑
摘要: https://leetcode.com/problems/next-greater-element-i/#/description You are given two arrays (without duplicates) nums1 and nums2 where nums1’s element 阅读全文
posted @ 2017-06-01 20:16 D-Dong 阅读(210) 评论(0) 推荐(0) 编辑
摘要: In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new one with different size but keep its original data. 阅读全文
posted @ 2017-05-27 11:00 D-Dong 阅读(301) 评论(0) 推荐(0) 编辑
摘要: Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation. Note: Example 1: Exa 阅读全文
posted @ 2017-05-27 10:41 D-Dong 阅读(262) 评论(0) 推荐(0) 编辑
摘要: 判断一个整数是不是2的幂。 关键是弄明白2的幂的二进制形式只有一个1。 相似题:判断一个数是不是3的幂。 方法一:循环 方法二:转3进制 10进制,1(100)、10(101)、100(102)……; 2进制,1(20)、10(21)、100(22)……; 3进制,1(30)、10(31)、100( 阅读全文
posted @ 2017-05-26 11:53 D-Dong 阅读(309) 评论(0) 推荐(0) 编辑
摘要: Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. 阅读全文
posted @ 2017-05-25 21:13 D-Dong 阅读(270) 评论(0) 推荐(0) 编辑
摘要: Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array. For example,Given nums = [0, 1, 阅读全文
posted @ 2017-05-25 15:52 D-Dong 阅读(230) 评论(0) 推荐(0) 编辑
摘要: 翻转32位无符号二进制整数 Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in binary as 00000010100101000001111010 阅读全文
posted @ 2017-05-25 15:18 D-Dong 阅读(364) 评论(0) 推荐(0) 编辑