引用http://anjun.cc/post/651.html private byte[] intToByteArray(final int integer) throws IOException {// ByteArrayOutputStream bos = new ByteArrayOu...
分类:
编程语言 时间:
2015-07-19 17:50:09
阅读次数:
140
Power of TwoTotal Accepted:11027Total Submissions:36750My SubmissionsQuestionSolutionGiven an integer, write a function to determine if it is a power ...
分类:
其他好文 时间:
2015-07-19 17:42:22
阅读次数:
99
Given an integer, write a function to determine if it is a power of two.My initial code: 1 class Solution: 2 # @param {integer} n 3 # @return ...
分类:
其他好文 时间:
2015-07-19 16:24:03
阅读次数:
112
题意将一个含数字的字符串转换成int型思路实现并不困难,主要考虑各种情况。1.字符串是不是空字符串;2.字符串带空格或其他字符怎么办;3.带正负号的处理;4.字符串中的数超过int型的范围怎么办(int 范围:-2147483648~2147483647 0x80000000~0x7fffffff)...
分类:
其他好文 时间:
2015-07-19 14:49:58
阅读次数:
95
题目如下:
The task is simple: given any positive integer N, you are supposed to count the total number of 1's in the decimal form of the integers from 1 to N. For example, given N being 12, there a...
分类:
其他好文 时间:
2015-07-19 13:28:24
阅读次数:
131
Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.
Note:
You may assume that nums1 has enough space (size that is greater or equal to m + n) to hold additio...
分类:
其他好文 时间:
2015-07-19 13:25:42
阅读次数:
162
题目Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n.For example:
Given n = 13,
Return 6, because digit 1 occurred in the following n...
分类:
其他好文 时间:
2015-07-19 11:54:24
阅读次数:
102
Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as theHamming weight).For example, the 32-bit in...
分类:
其他好文 时间:
2015-07-19 11:39:41
阅读次数:
116
Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as00000010100101000001111010011100), return ...
分类:
其他好文 时间:
2015-07-19 11:38:34
阅读次数:
122
Power of Two : https://leetcode.com/problems/power-of-two/
Given an integer, write a function to determine if it is a power of two.判断一个数是否是2的幂?
当无从下手时,可以根据例子找出规律。对于1,2,4,8,16它们的二进制表示分别是:
1: (1)
2:...
分类:
其他好文 时间:
2015-07-19 10:22:13
阅读次数:
210