上一页 1 ··· 19 20 21 22 23 24 25 26 27 ··· 30 下一页
摘要: Description:You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint... 阅读全文
posted @ 2015-06-25 11:16 Rosanne 阅读(183) 评论(0) 推荐(0) 编辑
摘要: 变换一个整数的符号,即正数变负数,负数变正数。1 int reverseSign(int n) {2 return ~n+1;3 } 阅读全文
posted @ 2015-06-25 09:53 Rosanne 阅读(337) 评论(0) 推荐(0) 编辑
摘要: 给出一个16位的无符号整数。称这个二进制数的前8位为“高位”,后8位为“低位”。现在写一程序将它的高低位交换。例如,数34520用二进制表示为:1000011011011000将它的高低位进行交换,我们得到了一个新的二进制数:1101100010000110它即是十进制的55430。这个问题用位操作... 阅读全文
posted @ 2015-06-25 09:25 Rosanne 阅读(7017) 评论(0) 推荐(1) 编辑
摘要: Description:Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as000000101001010000011110100111... 阅读全文
posted @ 2015-06-25 09:11 Rosanne 阅读(270) 评论(0) 推荐(0) 编辑
摘要: 一个整数为2的幂说明该整数的二进制中只有一个1. bool isSquareOf2 (int n){ return (n&(n-1))==0?true:false;} 阅读全文
posted @ 2015-06-24 22:52 Rosanne 阅读(255) 评论(0) 推荐(0) 编辑
摘要: Description:Implement the following operations of a stack using queues.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the... 阅读全文
posted @ 2015-06-24 22:41 Rosanne 阅读(129) 评论(0) 推荐(0) 编辑
摘要: Description:Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any posi... 阅读全文
posted @ 2015-06-24 22:37 Rosanne 阅读(212) 评论(0) 推荐(0) 编辑
摘要: Description:Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as theHamming weight).For example, t... 阅读全文
posted @ 2015-06-24 22:26 Rosanne 阅读(142) 评论(0) 推荐(0) 编辑
摘要: Description: Rotate an array of n elements to the right by k steps. For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7, 阅读全文
posted @ 2015-06-24 22:21 Rosanne 阅读(127) 评论(0) 推荐(0) 编辑
摘要: Description:Given a list of non negative integers, arrange them such that they form the largest number.For example, given[3, 30, 34, 5, 9], the larges... 阅读全文
posted @ 2015-06-23 10:58 Rosanne 阅读(266) 评论(0) 推荐(0) 编辑
上一页 1 ··· 19 20 21 22 23 24 25 26 27 ··· 30 下一页