From 499e9c30b5ecfcbe6fecf8ead2201bf192fb26b8 Mon Sep 17 00:00:00 2001 From: Pragya Patel <146708925+Pragya1001@users.noreply.github.com> Date: Sun, 8 Oct 2023 11:07:35 +0530 Subject: [PATCH] 204 Count Primes.cpp --- C++/204 Count Primes.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 C++/204 Count Primes.cpp diff --git a/C++/204 Count Primes.cpp b/C++/204 Count Primes.cpp new file mode 100644 index 0000000..041cfed --- /dev/null +++ b/C++/204 Count Primes.cpp @@ -0,0 +1,21 @@ +class Solution { +public: + int countPrimes(int n) { + int count=0; + if(n<=1) return 0; + + vector prime(n,true); + prime[1]=false; + for(int i=2;i