Description:Count the number of prime numbers less than a non-negative number, n.思路分析:这题是一道数学题,求小于n的所有质数。容易想到的思路是定义个isPrime的判定函数,对小于n的数一个一个判定,但是时间复杂度O(N^2)。有没有更快的算法呢?有,这是一个经典的找质数的算法,Sieve of Eratosthe...
分类:
其他好文 时间:
2015-05-25 16:47:52
阅读次数:
128
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single ...
分类:
其他好文 时间:
2015-05-25 14:20:09
阅读次数:
97
第二道题
Add Two Numbers
如下:
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a singl...
分类:
编程语言 时间:
2015-05-23 08:50:29
阅读次数:
190
Problem 2111 Min Number
Accept: 586 Submit: 1139
Time Limit: 1000 mSec Memory Limit : 32768 KB
Problem Description
Now you are given one non-negative integer n in 10-base notation, ...
分类:
其他好文 时间:
2015-05-23 00:04:53
阅读次数:
149
Jump GameTotal Accepted:43051Total Submissions:158263My SubmissionsQuestionSolutionGiven an array of non-negative integers, you are initially position...
分类:
编程语言 时间:
2015-05-22 22:24:07
阅读次数:
263
题目:
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.
Note: You can only move either down or...
分类:
编程语言 时间:
2015-05-22 17:12:06
阅读次数:
221
1 Jump Game
Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Determ...
分类:
编程语言 时间:
2015-05-21 12:48:33
阅读次数:
144
Count the number of prime numbers less than a non-negative number,n思路:数质数的个数开始写了个蛮力的,存储已有质数,判断新数字是否可以整除已有质数。然后妥妥的超时了(⊙v⊙)。看提示,发现有个Eratosthenes算法找质数的,说...
分类:
其他好文 时间:
2015-05-21 10:47:58
阅读次数:
110
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.
Note: You can only move either down or right at...
分类:
其他好文 时间:
2015-05-20 18:34:22
阅读次数:
138
leetcode 2 – Add Two Numbers
题目:
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add t...
分类:
其他好文 时间:
2015-05-20 16:22:34
阅读次数:
110