Easiest Dynamic Programming solution | |C++
What you have to do is  basically check if all different combinations of number when multiplied with 2 give the maximum bitwise OR or they do not.\nSimple knaps
What you have to do is  basically check if all different combinations of number when multiplied with 2 give the maximum bitwise OR or they do not.\nSimple knapsack solution.\nTime Complexity is (K* K* N)\nSpace Complexity is (K*N)\n```\nclass Solution {\npublic:\n    long long dp[100005][16];\n    long long recur(vector<int> &nums,int k,int index){\n        if(index==nums.size())return 0;\n        if(dp[index][k]!=-1)return dp[index][k];\n        long long count = 1;\n        long long maxx = 0;\n        for(int i = 0; i<=k; i++){\n            maxx = max(maxx,(nums[index]*count)|recur(nums,k-i,index+1));\n            count*=2;\n        }\n        return dp[index][k] = maxx;\n    }\n    long long maximumOr(vector<int>& nums, int k) {\n        memset(dp,-1,sizeof(dp));\n        return recur(nums,k,0);\n    }\n};\n```
['Dynamic Programming', 'Recursion', 'Memoization']