- why can't the recurrence be 1D dp (Form 1) like:-
rec(level,k)
- and use transitions like this to get the max value.
long ans = element | dp(arr, i+1, k);
if(k > 0) ans = max(ans, (element << 1) | dp(arr, i+1, k-1));
rec(level,k)
long ans = element | dp(arr, i+1, k);
if(k > 0) ans = max(ans, (element << 1) | dp(arr, i+1, k-1));