Better than 100 % || Easy to understand || Beginner friendly solution
Intuition\n Describe your first thoughts on how to solve this problem. \nCheck for prime numbers till n/2.\n\n# Approach\n Describe your approach to solving the
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nCheck for prime numbers till n/2.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. Check for the prime number till n/2, as we need the sum to be n, therefore to be a pair of prime numbers, one number should be <= n/2.\n2. If i and n - i both are prime, then push them in the answer vector.\n3. Return the ans.\n4. The prime no function: We will deal with a few numbers such as 1, 2, 3, and the numbers which are divisible by 2 and 3 in separate cases and for remaining numbers. Iterate from 5 to sqrt(n) and check for each iteration whether (that value) or (that value + 2) divides n or not and increment the value by 6 [**because any prime can be expressed as 6n+1 or 6n-1**]. If we find any number that divides, we return false.\n\n\n# Complexity\n- Time complexity: **O(n sqrt(n))**\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: **O(n)**\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    bool isPrime(int n)\n    {\n        if (n <= 1)\n            return 0;\n        if (n == 2 || n == 3)\n            return 1;\n        if (n % 2 == 0 || n % 3 == 0)\n            return 0;\n        for (int i = 5; i * i <= n; i = i + 6)\n        {\n            if (n % i == 0 || n % (i + 2) == 0)\n                return 0;\n        }\n        return 1;\n    }\n    vector<vector<int>> findPrimePairs(int n) {\n        \n        vector<vector<int>> ans;\n        \n        for(int i = 2; i <= n/2; i++)\n        {\n            if (isPrime(i) && isPrime(n - i)) \n            {\n                ans.push_back({i, n - i});\n            }\n        }\n        \n        return ans;\n    }\n};\n```
['Math', 'Python', 'C++', 'Java']