SHARE
TWEET

Untitled

a guest Sep 20th, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function maxSubsetSum(arr) {
  2.  
  3.     /**
  4.      * int incl = 0, excl = 0, temp;
  5. for(int i = 0; i < arr.size(); i++) {
  6.     temp = incl;
  7.     incl = max(arr[i]+excl, temp);
  8.     excl = temp;
  9. }
  10. return max(incl, excl);
  11.      */
  12.  
  13.     let incl = 0, excl=0, temp;
  14.     for(let i = 0; i< arr.length; i++){
  15.         temp = incl;
  16.         incl= Math.max(arr[i]+excl, temp);
  17.         excl = temp;
  18.     }
  19.     return Math.max(incl, excl);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top