题目描述
链接地址
解法
算法解释题目描述Given an array of integers, the majority number is the number that occurs more than half of the size of the array. Find it..ExampleGiven [1, 1, 1, 1, 2, 2, 2], return 1ChallengeO(n...
分类:
其他好文 时间:
2015-07-21 01:36:33
阅读次数:
186
题目描述首先定义"special number":
如果对于一个数字B,存在一个数字A(0<A<=B),并同时满足 B%A=0 和 gcd(A,B) != 1 ,那么我们就说A是B的"special number"。
再定义一个函数f(x)表示x的"special number"的数量。并且如果f(x)%2=1时,我们就称x为"real number"。
现在给你两个数字x和...
分类:
其他好文 时间:
2015-07-20 23:47:33
阅读次数:
205
本来判断回文串是一件很容易的事情,只需要反转字符串后在与原字符串相比较即可。这道题目明确说明不能使用额外的空间,那么使用将其分解连接成字符串的方法便不是可行的。只好采用数学的方式: 每次取最高位和最低位相比较,总的位数可以用一个while先处理出来,循环直至取余和除数相等。
具体见代码:
class Solution {
public:
bool isPalindrome(int x)...
分类:
其他好文 时间:
2015-07-20 23:42:24
阅读次数:
258
题目描述
链接地址
解法
算法解释题目描述Given 2*n + 2 numbers, every numbers occurs twice except two, find them.ExampleGiven [1,2,2,3,4,4,5,3] return 1 and 5ChallengeO(n) time, O(1) extra space.
.链接地址http://www.lintcode...
分类:
其他好文 时间:
2015-07-20 23:32:36
阅读次数:
137
A colored stripe is represented by a horizontal row ofnsquare cells, each cell is pained one ofkcolors. Your task is to repaint the minimum number of ...
分类:
其他好文 时间:
2015-07-20 23:14:30
阅读次数:
148
Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest le...
分类:
其他好文 时间:
2015-07-20 23:00:05
阅读次数:
85
1、验证是否为浮点数2、验证整数functionisInteger(obj) {returntypeofobj ==='number'&& obj%1 === 0 } functionisInteger(obj) {returnMath.floor(obj) === obj } function.....
分类:
编程语言 时间:
2015-07-20 22:55:08
阅读次数:
149
一、指令基础指令1、ng-disabled使用ng-disabled可以把disabled属性绑定到以下表单输入字段上: ( text、 checkbox、 radio、 number、 url , email 、 submit); ; Best City: {{ city.name }...
分类:
其他好文 时间:
2015-07-20 21:29:09
阅读次数:
160
ZigZag Conversion :
The string “PAYPALISHIRING” is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A...
分类:
其他好文 时间:
2015-07-20 19:41:58
阅读次数:
116
1、某一进程所有的线程个数、启动时间ps max -o lstart,lwp,pid,nlwp,cmdlstart: STARTED time the command started.nlwp: NLWP number of lwps (threads) in the process...
分类:
编程语言 时间:
2015-07-20 19:06:47
阅读次数:
125