🌟Simple Solution✅😀Easy Explanation🌟|| Find All Prime Pairs That Sum to  𝑛
IntuitionThe problem involves finding all pairs of prime numbers (x,y) such that:
x+y=n
x≤y
To solve this efficiently :
Use the Sieve of Eratosthenes to generat
# Intuition
The problem involves finding all pairs of prime numbers ($$𝑥, 𝑦$$) such that:
1. $$𝑥 + 𝑦 = 𝑛$$
2. $$𝑥 ≤ 𝑦$$

To solve this efficiently :
1.  Use the **Sieve of Eratosthenes** to generate a list of all prime numbers up to 𝑛.
2. Use two pointers to find pairs of primes that sum to 𝑛, ensuring the pair is added only once in the sorted order.

# Approach
1. **Prime Number Generation** :
    - Use the Sieve of Eratosthenes to mark all numbers up to 𝑛 as prime or non-prime.
2. **Two-Pointer Technique** :
    - Use one pointer starting from the smallest prime (𝑖) and another from the largest (𝑗).
    - If $$𝑖 + 𝑗 == 𝑛$$, add the pair to the result.
    - Adjust the pointers :
        - Increment $$𝑖$$ if $$𝑖 + 𝑗 < 𝑛$$.
        - Decrement $$𝑗$$ if $$𝑖 + 𝑗 > 𝑛$$.
3. **Result** :
    - Return a sorted list of all valid prime pairs.

# Complexity
- **Time complexity** : ***O(n loglogn)***
    - ***O(n loglogn)*** for the **Sieve of Eratosthenes**.
    - ***O(n)*** for the **two-pointer traversal**.
- **Space complexity** : ***O(n)***
    - For, the boolean array used in the sieve.

# Code
```java []
class Solution {
    public List<List<Integer>> findPrimePairs(int n) {
        // Handle edge cases for small n
        if (n <= 2) {
            return new ArrayList<>();
        }

        // Step 1: Generate prime numbers using the Sieve of Eratosthenes
        boolean[] prime = new boolean[n + 1];
        Arrays.fill(prime, true);
        prime[0] = prime[1] = false; // 0 and 1 are not prime

        for (int i = 2; i * i <= n; i++) {
            if (prime[i]) {
                for (int j = i * i; j <= n; j += i) {
                    prime[j] = false;
                }
            }
        }

        // Step 2: Use two pointers to find prime pairs
        List<List<Integer>> result = new ArrayList<>();
        int i = 2, j = n;

        while (i <= j) {
            if (prime[i] && prime[j] && i + j == n) {
                // Add the valid pair to the result
                result.add(Arrays.asList(i, j));
                i++;
                j--;
            } else if (i + j > n) {
                j--; // Decrease the sum by moving j left
            } else {
                i++; // Increase the sum by moving i right
            }
        }

        // Step 3: Return the sorted list of prime pairs
        return result;
    }
}
```
# Logic Explanation :
1. **Prime Detection** :
    - Generate a boolean array where `prime[x]` is true if $$𝑥$$ is a prime number.
    - Use the Sieve of Eratosthenes to populate this array.
2. **Two-Pointer Search** :
    - Start with $$𝑖 = 2$$ (smallest prime) and $$𝑗 = 𝑛$$ (largest possible number in the range).
    - Adjust the pointers based on the sum of $$𝑖 + 𝑗$$ compared to 
𝑛 :
        - If $$𝑖 + 𝑗 == 𝑛$$, add the pair to the result.
        - If $$𝑖 + 𝑗 < 𝑛$$, increment $$𝑖$$ to increase the sum.
        - If $$𝑖 + 𝑗 > 𝑛$$, decrement $$𝑗$$ to reduce the sum.
3. **Termination** :
    - Stop when $$𝑖 > 𝑗$$, ensuring no duplicate pairs.
['Array', 'Math', 'Java']