C++ || Sieve of Eratosthenes || Two pointers
Intuition\nTo find all the prime numbers till n and then find the sum pair\n\n# Approach\nWe will be finding the prime nunbers till n by using the concept of si
# Intuition\nTo find all the prime numbers till n and then find the sum pair\n\n# Approach\nWe will be finding the prime nunbers till n by using the concept of sieve of eratosthenes. And then we will use two pointers to find the sum pair.\nIn seive of eratosthenes we mark all the number which is divisble by 2 and are greater than or equal to square of it. We continue this process for all the numbers till n. \nThe numbers which are unmarked are the prime numbers till n.\n\nWe will then store these prime numbers in a new vector and apply two pointer approach to find the pair of sum equal to n;\n\n\n# Code\n```\nclass Solution {\npublic:\n    vector<vector<int>> findPrimePairs(int n) {\n        vector<int> temp(n,0);\n\n        for(int i=2;i*i<n;i++){\n            if(temp[i]==0){\n                for(int j=i*i;j<n;j+=i){\n                    temp[j]=1;\n                }\n            }\n        }\n        vector<int> prime;\n        for(int i=2;i<n;i++){\n            if(temp[i]==0){\n                prime.push_back(i);\n            }\n        }\n\n        vector<vector<int>> ans;\n        int i=0;\n        int j=prime.size()-1;\n        while(i<=j){\n            vector<int> t;\n            if((prime[i]+prime[j])==n){\n                \n                ans.push_back({prime[i],prime[j]});\n                i++;\n                j--;\n            }\n            else if((prime[i]+prime[j])<n){\n                i++;\n            }\n            else\n            j--;\n        }\n        return ans;\n    }\n};\n```
['Math', 'Two Pointers', 'C++']