Asymptotic O(1) - Constant Time Solution || Faster than 100% || Explanation
\nclass Solution { // 0ms - 100.00% Faster \n    static HashSet<String> set;\n    Solution(){ // this checks if the set is null, or it computes all the powers o
```\nclass Solution { // 0ms - 100.00% Faster \n    static HashSet<String> set;\n    Solution(){ // this checks if the set is null, or it computes all the powers of 2 and stores it in the set(this operation occurs only once)\n        if(set==null){\n            set = new HashSet<String>();\n            for(long i=1;i<=1000000000;i=i<<1){\n                String s = getFrequencyChart(i);\n                set.add(s);\n            }\n        }\n    }\n    private String getFrequencyChart(long n){ // this is the function to calculate the frequency of all the digits in the array\n        int[] freq = new int[10];\n        while(n>0){\n            freq[(int)n%10]++;\n            n/=10;\n        }\n        return Arrays.toString(freq);\n    }\n    \n    public boolean reorderedPowerOf2(int n) {\n        return set.contains(getFrequencyChart((long)n));\n    }\n}\n```\nExplanation:\n* Which we are setting the map as static, it creates only one `set` map object for all the object of the Solution class. Thus reducing the time to recalculate the set\n* `getFrequencyChart generates a frequency map of a number\'s digits and returns it which is used as a hashset key\n* In the Main Function we are just checking if the frequencies of the given numbers matches with the any power of 2.\n\n`Please Upvote if you find it helpful` \uD83D\uDE4F\uD83D\uDE4F
['Ordered Set', 'Java']