解法一:
int NumberOf1Between1AndN(unsigned int n)
{
int number = 0;
for (unsigned int i = 1; i
number += NumberOf1(i);
return number;
}
int NumberOf1(unsigned int n)
{
int number = 0;
w...
分类:
其他好文 时间:
2015-07-10 09:40:15
阅读次数:
177
题目:
Given a linked list, remove the nth node from the end of list and return its head.
For example,
Given linked list: 1->2->3->4->5, and n = 2.
After removing the second node from the...
分类:
编程语言 时间:
2015-07-10 09:36:10
阅读次数:
135
217 Contains Duplicate链接:https://leetcode.com/problems/contains-duplicate/
问题描述:
Given an array of integers, find if the array contains any duplicates. Your function should return true if any valu...
分类:
其他好文 时间:
2015-07-10 09:34:14
阅读次数:
118
题目:
Reverse digits of an integer.Example1: x = 123, return 321
Example2: x = -123, return -321Here are some good questions to ask before coding. Bonus points for you if you have already though...
分类:
其他好文 时间:
2015-07-10 09:30:30
阅读次数:
107
递归算法是不可取的。由于效率非常低,并且还有栈溢出的风险。应该使用例如以下的迭代解法:int Fibonacci(unsigned int n){ if(n #includelong long Fibonacci(unsigned int n){ if(n <= 0) { return 0; } ....
分类:
其他好文 时间:
2015-07-10 09:21:36
阅读次数:
98
#include #include const int INF=0x3f3f3f3f;const int MAXN=1e5+10;int parent[MAXN];int findset(int a){ return parent[a]!=a ? parent[a] = find(parent[a]...
分类:
其他好文 时间:
2015-07-10 09:16:09
阅读次数:
215
#include
#include
int lowbit(int x)
{
int z;
z = ~x;
z++;
return (x & z);
}
//测试
/*int main(void)
{
int n,t;
n = 50;
while(n)
{
t = lowbit(n);
printf("%d\n",t);
n -= t;
}
return 0;
}...
分类:
其他好文 时间:
2015-07-10 00:31:12
阅读次数:
103
//编写查找一个单链表特定元素的函数 递归PositionFindEle( ElementType X, List L ){ Position p; p = L->Next; if( p != NULL && p->Ele != X ) return FindEle(...
分类:
其他好文 时间:
2015-07-10 00:18:20
阅读次数:
144
Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two nu...
分类:
其他好文 时间:
2015-07-10 00:14:30
阅读次数:
116
昨天看到一个关于多态性的帖子,参考了回帖者的理解,加入了一些自己的看法,整理出来供大家参考,不一定完全正确,欢迎大家批评指正。(一)相关类classA...{publicStringshow(Dobj)...{return("AandD");}publicStringshow(Aobj)...{re...
分类:
编程语言 时间:
2015-07-10 00:12:37
阅读次数:
222