Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

Maximum Points You Can Obtain from Cards

public class Solution 
{
    public int MaxScore(int[] c, int k) 
    {
        var wSize = c.Length - k;
        var sum = c.Sum();
        var res = 0;
        var temp = 0;
        var j = 0;
        for (var i = 0; i < c.Length; i++)
        {
            temp += c[i];
            if (i < wSize)
            {
                if(i==wSize-1)
                {
                    res = Math.Max(res, sum - temp);
                }
                continue;
            }
            temp -= c[j++];
            res = Math.Max(res, sum - temp);
        }
        return res;
    }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: select vs where linq 
Csharp :: itext7 c# memorystream 
Csharp :: how to make a respaen script in unity 
Csharp :: does Registry.CurrentUser.OpenSubKey create the key if it does not exist? 
Csharp :: get web api relative path 
Csharp :: unity blender shadow messed up 
Csharp :: asp.net render control to string 
Csharp :: esaddex34 
Csharp :: c# check file similarities 
Csharp :: dotnet core ef add multiple records 
Csharp :: epmty char c# 
Csharp :: convert list of object linq 
Csharp :: asp.net unregister client script 
Csharp :: conveyor function in f# 
Csharp :: unity use of possibly unassigned field struct 
Csharp :: Remove tabpage by key 
Csharp :: poems 
Csharp :: Delete last modification on EntityFramework Core 
Csharp :: model showing in scne view but not in game view 
Csharp :: orderby make sunday last day c# 
Csharp :: six simple machines labeled 
Csharp :: unity shader show object behind object 
Csharp :: windows forms tablelayoutpanel scroll 
Csharp :: how to make a variable unity 
Csharp :: get position of gameobject unity 
Csharp :: c# is string nullable 
Csharp :: convert array to list c# 
Csharp :: c# windows forms function after load 
Csharp :: how to dynamically load value in startup file in c# 
Csharp :: export2excel with logo and header and many table on one click stackoverflow 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =