Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2db2f92

Browse files
committed
Merge branch 'master' of https://github.com/doocs/leetcode
2 parents a3aa429 + 01af732 commit 2db2f92

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

β€ŽSOLUTION_TREE.mdβ€Ž

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
21
## Solution Tree
3-
42
```
53
.
64
β”œβ”€β”€ 0001.Two Sum
@@ -349,6 +347,7 @@
349347
β”œβ”€β”€ 0083.Remove Duplicates from Sorted List
350348
β”‚ β”œβ”€β”€ README.md
351349
β”‚ β”œβ”€β”€ Solution.java
350+
β”‚ β”œβ”€β”€ Solution.js
352351
β”‚ └── Solution.py
353352
β”œβ”€β”€ 0084.Largest Rectangle in Histogram
354353
β”‚ β”œβ”€β”€ README.md
@@ -388,6 +387,12 @@
388387
β”‚ β”œβ”€β”€ README.md
389388
β”‚ β”œβ”€β”€ Solution.java
390389
β”‚ └── Solution.py
390+
β”œβ”€β”€ 0097.Interleaving String
391+
β”‚ └── Solution.java
392+
β”œβ”€β”€ 0098.Validate Binary Search Tree
393+
β”‚ └── Solution.java
394+
β”œβ”€β”€ 0099.Recover Binary Search Tree
395+
β”‚ └── Solution.java
391396
β”œβ”€β”€ 0102.Binary Tree Level Order Traversal
392397
β”‚ β”œβ”€β”€ README.md
393398
β”‚ β”œβ”€β”€ Solution.java
@@ -443,6 +448,7 @@
443448
β”œβ”€β”€ 0141.Linked List Cycle
444449
β”‚ β”œβ”€β”€ README.md
445450
β”‚ β”œβ”€β”€ Solution.java
451+
β”‚ β”œβ”€β”€ Solution.js
446452
β”‚ └── Solution.py
447453
β”œβ”€β”€ 0142.Linked List Cycle II
448454
β”‚ β”œβ”€β”€ README.md
@@ -524,6 +530,7 @@
524530
β”‚ β”œβ”€β”€ Solution.java
525531
β”‚ └── Solution.py
526532
β”œβ”€β”€ 0204.Count Primes
533+
β”‚ β”œβ”€β”€ Solution.cpp
527534
β”‚ └── Solution.js
528535
β”œβ”€β”€ 0206.Reverse Linked List
529536
β”‚ └── Solution.js
@@ -625,6 +632,8 @@
625632
β”‚ └── Solution.cpp
626633
β”œβ”€β”€ 0485. Max Consecutive Ones
627634
β”‚ └── Solution.js
635+
β”œβ”€β”€ 0509.Fibonacci
636+
β”‚ └── Solution.cpp
628637
β”œβ”€β”€ 0521.Longest Uncommon Subsequence I
629638
β”‚ β”œβ”€β”€ README.md
630639
β”‚ └── Solution.py
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
class Solution {
2+
public:
3+
4+
vector<int> primes;
5+
6+
int isPrime(int num){
7+
8+
int i = 1;
9+
while( i < primes.size() && sqrt(num) >= primes[i] ){
10+
if( num % primes[i] == 0 ) return 0;
11+
i++;
12+
}
13+
return 1;
14+
}
15+
16+
int countPrimes(int n) {
17+
18+
if( n <= 2 ) return 0;
19+
20+
primes.push_back(2);
21+
22+
for(int i = 3; i < n; i += 2){
23+
if( isPrime(i) )
24+
primes.push_back(i);
25+
}
26+
27+
return primes.size();
28+
}
29+
};

0 commit comments

Comments
(0)

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /