140ms || BEATS 100% ⚡⚡||  O(Nlog(log(N)) || Erathosthenes Sieve
\n\n# Complexity\n- Time complexity:\nO(N\log(\log(N))\n\n- Space complexity:\nO(n)\n\n# Code\ncpp []\nclass Solution {\nprivate:\n    void erathostenes(bool sv
![image.png](https://assets.leetcode.com/users/images/b7b1189c-0b35-4ed8-a7e2-663bb813733c_1729999596.0236626.png)\n\n# Complexity\n- Time complexity:\n$$O(N\\log(\\log(N))$$\n\n- Space complexity:\n$$O(n)$$\n\n# Code\n```cpp []\nclass Solution {\nprivate:\n    void erathostenes(bool sv[], const int &n){\n        for (size_t i = 2; i*i <= n; i++)\n            if(sv[i])\n                for (size_t j = i*i; j <= n; j+=i)\n                    sv[j] = false;\n    }\n    \npublic:\n    vector<vector<int>> findPrimePairs(int n) {\n        bool sv[n + 1];\n        for (size_t i = 0; i <= n; i++)\n            sv[i] = true;\n\n        erathostenes(sv, n);\n        \n        vector<vector<int>> answ;\n\n        for (int i = 2; i <= n/2+1; i++)\n            if(sv[i] && n-i >= i && sv[n - i])\n                answ.push_back({i, n - i});\n        \n        return answ;\n    }\n};\n```
['Math', 'Enumeration', 'Number Theory', 'C++']