Skip to content

Instantly share code, notes, and snippets.

@riyadparvez
Created July 23, 2013 06:34
Show Gist options
  • Select an option

  • Save riyadparvez/6060269 to your computer and use it in GitHub Desktop.

Select an option

Save riyadparvez/6060269 to your computer and use it in GitHub Desktop.
Returns largest subsequence sum in C#.
public static double LargestSubsequenceSum(IEnumerable<double> list)
{
var arr = list.ToArray();
double currentMax = arr[0];
double max = currentMax;
for (int i = 1; i < arr.Length; i++)
{
currentMax = Max(currentMax, currentMax+arr[i]);
max = Max(max, currentMax);
}
return max;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment