Sherlock and Array

  • + 0 comments

    C# SOLUTION

    int[] intArray = arr.ToArray(); if (arr.Count() == 1){ return "YES"; } int[] startEndSums = { 0 , intArray[..].Sum() };

        for (int i = 0; i < arr.Count(); i++){
            startEndSums[1] -= intArray[i];
            if (startEndSums[0] == startEndSums[1])
                return "YES";
            startEndSums[0] += intArray[i];
        }
        return "NO";