Skip to content

Instantly share code, notes, and snippets.

@jugshaurya
Last active August 29, 2022 10:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jugshaurya/cbd1fe0982058582bfa9cc667550fba7 to your computer and use it in GitHub Desktop.
Save jugshaurya/cbd1fe0982058582bfa9cc667550fba7 to your computer and use it in GitHub Desktop.

Question 1: Finding Maximum OR

My Problem with it.

  • 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));

You said that it will require masking, i didnt get that why would we need that? BTw above solution was only passing 7/15 test cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment