You are viewing a single comment's thread. Return to all comments →
C#
static int maxSubsetSum(int[] arr) { for(var i = 2; i < arr.Length; i++){ arr[i-1] = Math.Max(arr[i-1], arr[i-2]); arr[i] = Math.Max(arr[i], Math.Max(arr[i-2], arr[i] + arr[i-2])); } return Math.Max(arr[arr.Length - 1], arr[arr.Length - 2]); }
Seems like cookies are disabled on this browser, please enable them to open this website
Max Array Sum
You are viewing a single comment's thread. Return to all comments →
C#