DP Working! easy intitutive DP solution beats 50% +
\n# Complexity\n- Time complexity: O(nk)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(nk)\n Add your space complexity here, e.g. O(n) \n
\n# Complexity\n- Time complexity: O(n*k)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n*k)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    inline long long int power(long long a, long long b) {\n        long long res = 1;\n        while (b > 0) {\n            if (b & 1)\n                res = res * a;\n            a = a * a;\n            b >>= 1;\n        }\n        return res;\n    }\n    \n    long long int dp[(int)1e5 + 1][16];\n    long long solve(int i,vector<int> &v ,long long k) {\n        int n = v.size();\n        if(i == n) return 0LL;\n        // cout<<i<<\' \'<<k<<endl;\n        \n        if(dp[i][k] != -1) return dp[i][k];\n        \n        long long int ans = 0;\n        for(long long j = 0; j <= k; j++) {\n            ans = max(ans , solve(i + 1 , v,  k - j) | (1ll*power(2,j*1LL)*v[i]));\n        }\n        // ans = max(ans , solve(i + 1 , v , k) | v[i]);\n        \n        // cout<<ans<<endl;\n        \n        return dp[i][k] = ans;\n        \n    }\npublic:\n    long long maximumOr(vector<int>& nums, int k) {\n        memset(dp,-1, sizeof dp);\n        sort(nums.begin() , nums.end(),greater<int> ());\n        long long int a = solve(0,nums,k);\n        memset(dp,-1, sizeof dp);\n        sort(nums.begin() , nums.end());\n        long long int b = solve(0,nums,k);\n        return max(a,b);\n    }\n};\n```
['Dynamic Programming', 'Memoization', 'C++']