using System.Collections.Generic;
public static class ArrayHelper {
public static IList<int> Intersection(int[] arr1, int[] arr2) {
if(arr1 == null || arr1.Length == 0 || arr2 == null || arr2.Length == 0) {
var res = new List<int>();
while(i < arr1.Length && j < arr2.Length) {
if(res.LastOrDefault() != arr1[i]) {
} else if(arr1[i] < arr2[j]) {
public static int[] SlidingSum(int[] arr, int k) {
throw new ArgumentException(nameof(k));
throw new ArgumentException(nameof(arr));
var sum = arr.Take(Math.Min(arr.Length, k)).Sum();
var res = new int[arr.Length];
for(int left = 1; left < res.Length; left++) {
public static void Main()
var res = ArrayHelper.SlidingSum(new [] { 1, 3 ,5 ,3 , 4}, 4);
Console.WriteLine("{0}", string.Join(",", res));