From 8a05f86e74a1927298336fea23f9676d97c3b422 Mon Sep 17 00:00:00 2001 From: tejasvicsr1 Date: Mon, 18 Oct 2021 20:24:38 +0530 Subject: [PATCH 1/4] Solves issue #1077. Solution to the problem Count Primes(204) in Python. --- Python/204_Count_Primes.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Python/204_Count_Primes.py diff --git a/Python/204_Count_Primes.py b/Python/204_Count_Primes.py new file mode 100644 index 00000000..d0cf1d19 --- /dev/null +++ b/Python/204_Count_Primes.py @@ -0,0 +1,15 @@ +class Solution: + def countPrimes(self, n: int) -> int: + prime = [True for i in range(n+1)] + p = 2 + while (p * p <= n): + if (prime[p] == True): + for i in range(p * p, n+1, p): + prime[i] = False + p += 1 + sol = 0 + for p in range(2, n): + if prime[p]: + sol += 1 + return sol + \ No newline at end of file From 759e63ce7250798f578ea8eb45bfbceb4fad5a48 Mon Sep 17 00:00:00 2001 From: tejasvicsr1 Date: Mon, 18 Oct 2021 20:30:01 +0530 Subject: [PATCH 2/4] Solves issue #1077. Solution to the problem Count Primes(204) in Python. --- Python/{204_Count_Primes.py => Count_Primes.py} | 2 ++ 1 file changed, 2 insertions(+) rename Python/{204_Count_Primes.py => Count_Primes.py} (89%) diff --git a/Python/204_Count_Primes.py b/Python/Count_Primes.py similarity index 89% rename from Python/204_Count_Primes.py rename to Python/Count_Primes.py index d0cf1d19..133ac1d9 100644 --- a/Python/204_Count_Primes.py +++ b/Python/Count_Primes.py @@ -1,3 +1,5 @@ +# https://leetcode.com/problems/count-primes/ + class Solution: def countPrimes(self, n: int) -> int: prime = [True for i in range(n+1)] From 645618db4dcf4a2ce06ed2722836ebeb6ae54455 Mon Sep 17 00:00:00 2001 From: tejasvicsr1 Date: Mon, 18 Oct 2021 21:08:58 +0530 Subject: [PATCH 3/4] Solves issue #1080. Python solution to the problem 1447 Simplified Fractions. --- Python/Simplified_Fractions.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 Python/Simplified_Fractions.py diff --git a/Python/Simplified_Fractions.py b/Python/Simplified_Fractions.py new file mode 100644 index 00000000..8c1e835b --- /dev/null +++ b/Python/Simplified_Fractions.py @@ -0,0 +1,17 @@ +# https://leetcode.com/problems/simplified-fractions/submissions/ + +class Solution: + def simplifiedFractions(self, n: int): + def gcd(a, b): + if b == 0: + return a + return gcd(b, a % b) + sol = [] + for i in range(1, n + 1): + for j in range(1, i + 1): + if gcd(i, j) == 1: + if i == 1 and j == 1: + continue + ans = str(j) + '/' + str(i) + sol.append(ans) + return sol \ No newline at end of file From 490610bbf49cb80065865435aab7d64e02e0e706 Mon Sep 17 00:00:00 2001 From: tejasvicsr1 Date: Mon, 18 Oct 2021 21:10:45 +0530 Subject: [PATCH 4/4] Solves issue #1080. Python solution to the problem 1447 Simplified Fractions. --- Python/Simplified_Fractions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Python/Simplified_Fractions.py b/Python/Simplified_Fractions.py index 8c1e835b..c34f8c5d 100644 --- a/Python/Simplified_Fractions.py +++ b/Python/Simplified_Fractions.py @@ -1,4 +1,4 @@ -# https://leetcode.com/problems/simplified-fractions/submissions/ +# Link: https://leetcode.com/problems/simplified-fractions/submissions/ class Solution: def simplifiedFractions(self, n: int):