C++ || Fast Solution O(n) 🔥🔥 Easy to understand
\n# Intuition\n\nThe sieve of Eratosthenes is one of the most efficient ways to find all primes smaller than n\n\nWe use sieve of Eratosthenes for filling the v
\n# Intuition\n\n**The sieve of Eratosthenes is one of the most efficient ways to find all primes smaller than n**\n\nWe use sieve of Eratosthenes for filling the vector isPrime.\nThe time complexity of filling this vector will be O(n).\n\n\n# Complexity\n- Time complexity: $$O(n)$$\n\n\n# Code\n```\nclass Solution {\npublic:\n    void fill(vector<bool>& isPrime, int n) {\n        for (int i=2;i<n;i++) {\n            if (isPrime[i]==true) \n                for (int j=2;i*j<=n;j++) {\n                    isPrime[i*j]=false;\n                }\n        }\n    }\n    vector<vector<int>> findPrimePairs(int n) {\n        vector<vector<int>> res;\n        vector<bool> isPrime(n+1,true);\n        fill(isPrime,n);\n        for (int i=2;i<=n/2;i++) {\n            if (isPrime[i] && isPrime[n-i]) {\n                res.push_back({i,n-i});\n            }\n        }\n        return res;\n    }\n};\n```\n\n\n\n\n![LeetCode](https://assets.leetcode.com/users/images/6a87bc25-d70b-424f-9e60-7da6f345b82a_1673875931.8933976.jpeg){:style=\'border-radius:5px;width:300px;margin:auto;\'}
['C++']