Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Result
- {
- /*
- * Complete the 'balancedSums' function below.
- *
- * The function is expected to return a STRING.
- * The function accepts INTEGER_ARRAY arr as parameter.
- */
- public static string balancedSums(List<int> arr)
- {
- int rightSum = arr.Sum();
- int leftSum = 0;
- for (var i = 0; i < arr.Count; i++)
- {
- rightSum -= arr[i];
- if (leftSum == rightSum)
- {
- return "YES";
- }
- leftSum += arr[i];
- }
- return "NO";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment