Fork me on GitHub
#code-reviews
<
2021-05-25
>
jaihindhreddy15:05:06

Here's a working impl (my take on it):

(defn max-subset-sum [nums]
  (let [nxt
    #(let [n (count %)
           taking (+ %2 (nth % (- n 2) 0))
           not-taking (nth % (dec n) 0)]
        (conj % (max taking not-taking)))]
    (apply max (reduce nxt [] nums))))