Easy C# solution


  • -1
    D
    int[] result = new int[nums.Length-k+1];
            if (nums == null||k==0) return nums;
            if (k == 1) return nums;
            else
            {
                for (int i = 0; i < nums.Length - k + 1; ++i)
                {
                    result[i] = nums[i];
                    for (int j = i; j < k+i;++j )
                    {
                        result[i] = Math.Max(result[i],nums[j]);
                    }
                }
            }
            return result;

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.