sieve of eratosthenes || Java || C++ || Python Solution
C++ Solution\n\nclass Solution {\npublic:\n  vector<vector<int>> findPrimePairs(int n) {\n        // steive of eratharos\n        vector<bool> vis(n + 1, true);
# C++ Solution\n```\nclass Solution {\npublic:\n  vector<vector<int>> findPrimePairs(int n) {\n        // steive of eratharos\n        vector<bool> vis(n + 1, true);\n        for (int i = 2; i * i <= n; i++){\n            if (vis[i]){\n                for (int j = 2 * i; j <= n; j += i){\n                    vis[j] = false;\n                }\n            }        \n        }\n        \n        vector<vector<int>> ans;\n        \n        for (int i = 2; i <= n / 2; i++){\n            int x = i;\n            int y = n - i;\n            \n            if (vis[x] && vis[y] && x <= y){\n                ans.push_back({x, y});\n            }\n        }\n        \n        return ans;\n    }\n};\n```\n\n# Java Solution\n```\nclass Solution {\n    public static List<List<Integer>> findPrimePairs(int n) {\n        // sieve of Eratosthenes\n        boolean[] vis = new boolean[n + 1];\n        for (int i = 2; i * i <= n; i++) {\n            if (!vis[i]) {\n                for (int j = 2 * i; j <= n; j += i) {\n                    vis[j] = true;\n                }\n            }\n        }\n\n        List<List<Integer>> ans = new ArrayList<>();\n\n        for (int i = 2; i <= n / 2; i++) {\n            int x = i;\n            int y = n - i;\n\n            if (!vis[x] && !vis[y] && x <= y) {\n                List<Integer> pair = new ArrayList<>();\n                pair.add(x);\n                pair.add(y);\n                ans.add(pair);\n            }\n        }\n\n        return ans;\n    }\n}\n```\n\n# Python3 Solution \n```\nclass Solution:\n    def findPrimePairs(self, n: int) -> List[List[int]]:\n        # sieve of Eratosthenes\n        vis = [False] * (n + 1)\n        for i in range(2, int(n**0.5) + 1):\n            if not vis[i]:\n                for j in range(2 * i, n + 1, i):\n                    vis[j] = True\n\n        ans = []\n\n        for i in range(2, n // 2 + 1):\n            x = i\n            y = n - i\n\n            if not vis[x] and not vis[y] and x <= y:\n                ans.append([x, y])\n\n        return ans\n```\n
['Array', 'C', 'Java', 'Python3']