Speed : 99.62!
Intuition\nusing the static array of SeiveO... we can get the prime value\ntable[i] && table[n - i] add to list(i, n-i).\ndone!!\n// Using BitSet will improve m
# Intuition\nusing the static array of SeiveO... we can get the prime value\n**$$table[i]$$ && $$table[n - i]$$ add to list(i, n-i)**.\ndone!!\n// Using BitSet will improve memroy usage but wrosen the performance.\n\nBitset Usage 1 bit as true or false. But boolean usage 1 byte(8bit) for true or false.\n\nInternally BitSet usage some bitwise operation such that it can store the bitmap of total 64 binary value in 8 byte only.\n\nTraditional approach using boolean[] is lot faster than BitSet!.\n# Approach\nTable of primes\n\n# Complexity\n- Time complexity:\n$$O(log(n))$$\n\n- Space complexity:\n$$O(1)$$\nReason: we usage only half of the n only to get a pair.\n\n# Code\n```java []\nimport java.util.List;\nimport java.util.LinkedList;\nimport java.util.stream.IntStream;\nimport java.util.concurrent.CopyOnWriteArrayList;\n\nclass Solution {\n    static final boolean[] PRIME_TABLE;\n    static {\n        final boolean[] pT = new boolean[1_000_001];\n        pT[0] = true;\n        pT[1] = true;\n        for (int i = 2; i <= 1000; i++) {\n            if (!pT[i]) {\n                for (int j = i * i; j <= 1_000_000; j += i) {\n                    pT[j] = true;\n                }\n            }\n        }\n        PRIME_TABLE = pT;\n    }\n\n    void usingStream(int range, List<List<Integer>> data, int n) {\n        boolean[] table = Solution.PRIME_TABLE;\n        IntStream.range(0, range).filter(i -> {\n            return !table[i] && !table[n - i];\n        }).forEach(i -> {\n            data.add(List.of(i, n-i));\n        });\n    }\n\n    public List<List<Integer>> findPrimePairs(int n) {\n        // cache the table in instance!\n        final boolean[] table = Solution.PRIME_TABLE;\n        List<List<Integer>> data = new ArrayList<>();\n        if (n < 4) {\n            return data;\n        }\n        int range = (n >> 1);\n        for (int i = 2; i <= range; i++) {\n            // if prime number\n            if (!table[i] && !table[n - i]) {\n                List<Integer> al = new LinkedList();\n                al.add(i);\n                al.add(n - i);\n                data.add(al);\n            }\n        }\n        return data;\n    }\n}\n```
['Array', 'Math', 'Enumeration', 'Java']