A non-empty array A consisting of N integers is given. Array A represents numbers on a tape.
Any integer P, such that 0 < P < N, splits this tape into two non-empty parts: A[0], A[1], ..., A[P − 1] and A[P], A[P + 1], ..., A[N − 1].
The difference between the two parts is the value of: |(A[0] + A[1] + ... + A[P − 1]) − (A[P] + A[P + 1] + ... + A[N − 1])|
In other words, it is the absolute difference between the sum of the first part and the sum of the second part.
For example, consider array A such that:
A[0] = 3 A[1] = 1 A[2] = 2 A[3] = 4 A[4] = 3We can split this tape in four places:
- P = 1, difference = |3 − 10| = 7
- P = 2, difference = |4 − 9| = 5
- P = 3, difference = |6 − 7| = 1
- P = 4, difference = |10 − 3| = 7
Write a function:
class Solution { public int solution(int[] A); }
that, given a non-empty array A of N integers, returns the minimal difference that can be achieved.
For example, given:
A[0] = 3 A[1] = 1 A[2] = 2 A[3] = 4 A[4] = 3the function should return 1, as explained above.
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [2..100,000];
- each element of array A is an integer within the range [−1,000..1,000].
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
FindMin(A);
return 0;
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
FindSum(A);
FindMin(A);
return 0;
}
int FindSum()
{
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
FindSum(A);
FindMin(A);
return 0;
}
int FindSum(int[] input)
{
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
FindSum(A);
FindMin(A);
return 0;
}
int FindSum(int[] input)
{
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
FindSum(A);
FindMin(A);
return 0;
}
int FindSum(int[] input)
{
if(input.Length == )
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
Sum(A);
FindMin(A);
return 0;
}
int Sum(int[] input)
{
if(input.Length == 1) return input[0];
return Sum(in);
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
Sum(A);
FindMin(A);
return 0;
}
int Sum(int[] input)
{
if(input.Length == 1) return input[0];
return inputSum(input);
}
}
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
Sum(A);
FindMin(A);
return 0;
}
int Sum(int[] input)
{
if(input.Length == 1) return input[0];
return input[0] + Sum(input.Skip(1));
}
}
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
Sum(A);
FindMin(A);
return 0;
}
int Sum(int[] input)
{
if(input.Length == 1) return input[0];
return input[0] + Sum(input.Skip(1).ToArray());
}
}
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
var overallSum = Sum(A);
FindMin(A);
return 0;
}
int Sum(int[] input)
{
if(input.Length == 1) return input[0];
return input[0] + Sum(input.Skip(1).ToArray());
}
}
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
var overallSum = Sum(A);
FindMin(A);
return 0;
}
int min = int.MaxValue;
int Sum(int[] input)
{
if(input.Length == 1) return input[0];
return input[0] + Sum(input.Skip(1).ToArray());
}
}
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
var overallSum = Sum(A);
FindMin(A);
return 0;
}
int min = int.MaxValue;
int Sum(int[] input)
{
if(input.Length == 1) return input[0];
return ;
}
}
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
var overallSum = Sum(A);
FindMin(A);
return 0;
}
int min = int.MaxValue;
int Sum(int[] input)
{
if(input.Length == 1) return input[0];
return input[0] + Sum(input.Skip(1).ToArray());
}
}
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
var overallSum = Sum(A);
Console.WriteLine(overallSum);
return 0;
}
int min = int.MaxValue;
int Sum(int[] input)
{
if(input.Length == 1) return input[0];
return input[0] + Sum(input.Skip(1).ToArray());
}
}
13
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
var overallSum = Sum(A);
Console.WriteLine(overallSum);
return 0;
}
int min = int.MaxValue;
int Sum(int[] input)
{
if(input.Length == 1) return input[0];
return input[0] + Sum(input.Skip(1).ToArray());
}
}
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
var overallSum = Sum(A);
Console.WriteLine(overallSum);
return 0;
}
int min = int.MaxValue;
int Sum(int[] input)
{
if(input.Length == 1) return input[0];
return input[0] + Sum(input.Skip(1).ToArray());
}
}
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
var overallSum = Sum(A);
Console.WriteLine(overallSum);
return 0;
}
int min = int.MaxValue;
int Sum(int[] input, int length)
{
if(input.Length == 1) return input[0];
return input[0] + Sum(input.Skip(1).ToArray());
}
}
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
var overallSum = Sum(A);
Console.WriteLine(overallSum);
return 0;
}
int min = int.MaxValue;
int Sum(int[] input, int length)
{
if(input.Length == 1) return input[0];
return input[0] + Sum(input, length-1);
}
}
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
var overallSum = Sum(A);
Console.WriteLine(overallSum);
return 0;
}
int min = int.MaxValue;
int Sum(int[] input, int length)
{
if(Length == 1) return input[0];
return input[0] + Sum(input, length-1);
}
}
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
var overallSum = Sum(A);
Console.WriteLine(overallSum);
return 0;
}
int min = int.MaxValue;
int Sum(int[] input, int length)
{
if(length == 1) return input[input.Length -length];
return input[0] + Sum(input, length-1);
}
}
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
var overallSum = Sum(A);
Console.WriteLine(overallSum);
return 0;
}
int min = int.MaxValue;
int Sum(int[] input, int length)
{
if(length == 1) return input[input.Length -length];
return input[0] + Sum(input, length-1);
}
}
Compilation failed: 1 error(s), 0 warnings Solution.cs(14,26): error CS1501: No overload for method `Sum' takes `1' arguments Solution.cs(21,9): (Location of the symbol related to previous error)
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
var overallSum = Sum(A,A.Length);
Console.WriteLine(overallSum);
return 0;
}
int min = int.MaxValue;
int Sum(int[] input, int length)
{
if(length == 1) return input[input.Length -length];
return input[0] + Sum(input, length-1);
}
}
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
var overallSum = Sum(A,A.Length);
Console.WriteLine(overallSum);
return 0;
}
int min = int.MaxValue;
int Sum(int[] input, int length)
{
if(length == 1) return input[input.Length -length];
return input[0] + Sum(input, length-1);
}
}
15
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
var overallSum = Sum(A,A.Length);
Console.WriteLine(overallSum);
return 0;
}
int min = int.MaxValue;
int Sum(int[] input, int length)
{
if(length == 1) return input[input.Length - 1];
return input[0] + Sum(input, length-1);
}
}
15
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
var overallSum = Sum(A,A.Length);
Console.WriteLine(overallSum);
return 0;
}
int min = int.MaxValue;
int Sum(int[] input, int length)
{
if(length == 1) return input[input.Length - 1];
return input[length] + Sum(input, length-1);
}
}
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
var overallSum = Sum(A,A.Length);
Console.WriteLine(overallSum);
return 0;
}
int min = int.MaxValue;
int Sum(int[] input, int length)
{
if(length == 1) return input[input.Length - 1];
return input[A.Length] + Sum(input, length-1);
}
}
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
var overallSum = Sum(A,A.Length);
Console.WriteLine(overallSum);
return 0;
}
int min = int.MaxValue;
int Sum(int[] input, int length)
{
if(length == 1) return input[input.Length - 1];
return input[input.Length - length] + Sum(input, length-1);
}
}
13
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
var overallSum = Sum(A,A.Length);
Console.WriteLine(overallSum);
return 0;
}
int min = int.MaxValue;
int Sum(int[] input, int length)
{
var local
if(length == 1) return input[input.Length - 1];
return + Sum(input, length-1);
}
}
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
var overallSum = Sum(A,A.Length);
Console.WriteLine(overallSum);
return 0;
}
int min = int.MaxValue;
int Sum(int[] input, int length)
{
var localSum = input[input.Length - length];
if(length == 1) return localSum;
return localSum + Sum(input, length-1);
}
}
13
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
var overallSum = Sum(A,A.Length);
Console.WriteLine(overallSum);
return 0;
}
int min = int.MaxValue;
int Sum(int[] input, int length)
{
var localSum = input[input.Length - length];
if(length == 1) return localSum;
return localSum + Sum(input, length-1);
}
}
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
var overallSum = Sum(A,A.Length);
Console.WriteLine(overallSum);
return 0;
}
int min = int.MaxValue;
int[]
int Sum(int[] input, int length)
{
var localSum = input[input.Length - length];
if(length == 1) return localSum;
return localSum + Sum(input, length-1);
}
}
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
var overallSum = Sum(A,A.Length);
Console.WriteLine(overallSum);
return 0;
}
int min = int.MaxValue;
int[] splitSum = new int[];
int Sum(int[] input, int length)
{
var localSum = input[input.Length - length];
if(length == 1) return localSum;
return localSum + Sum(input, length-1);
}
}
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
int[] splitSum ;
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
splitSum = new int[A.Length];
var overallSum = Sum(A,A.Length);
Console.WriteLine(overallSum);
return 0;
}
int min = int.MaxValue;
int Sum(int[] input, int length)
{
var localSum = input[input.Length - length];
if(length == 1) return localSum;
return localSum + Sum(input, length-1);
}
}
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
int[] splitSum ;
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
splitSum = new int[A.Length+1];
var overallSum = Sum(A,A.Length);
Console.WriteLine(overallSum);
return 0;
}
int min = int.MaxValue;
int Sum(int[] input, int length)
{
var localSum = input[input.Length - length];
if(length == 1) return localSum;
return localSum + Sum(input, length-1);
}
}
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
int[] splitSum ;
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
splitSum = new int[A.Length+1];
var overallSum = Sum(A,A.Length);
Console.WriteLine(overallSum);
return 0;
}
int min = int.MaxValue;
int Sum(int[] input, int length)
{
var localSum = input[input.Length - length];
splitSum[input.Length]
if(length == 1) return localSum;
return localSum + Sum(input, length-1);
}
}
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
int[] splitSum ;
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
splitSum = new int[A.Length+1];
var overallSum = Sum(A,A.Length);
Console.WriteLine(overallSum);
return 0;
}
int min = int.MaxValue;
int Sum(int[] input, int length)
{
var localSum = input[input.Length - length];
splitSum[input.Length ]
if(length == 1) return localSum;
return localSum + Sum(input, length-1);
}
}
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
int[] splitSum ;
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
splitSum = new int[A.Length+1];
var overallSum = Sum(A,A.Length);
Console.WriteLine(overallSum);
return 0;
}
int min = int.MaxValue;
int Sum(int[] input, int length)
{
var localSum = input[input.Length - length];
splitSum[input.Length - length] = localSum;
if(length == 1) return localSum;
splitSum[input.Length - length] = localSum;
localSum + Sum(input, length-1);
return splitSum[];
}
}
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
int[] splitSum ;
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
splitSum = new int[A.Length+1];
var overallSum = Sum(A,A.Length);
Console.WriteLine(overallSum);
return 0;
}
int min = int.MaxValue;
int Sum(int[] input, int length)
{
var localSum = input[input.Length - length];
splitSum[input.Length - length] = localSum;
if(length == 1) return localSum;
var allSum = localSum + Sum(input, length-1);
splitSum[input.Length - length] =allSum;
return allSum;
}
}
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
int[] splitSum ;
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
splitSum = new int[A.Length+1];
var overallSum = Sum(A,A.Length);
for(int i=0;i<splitSum.Length; i++)
{
Console.WriteLine(spli);
}
return 0;
}
int min = int.MaxValue;
int Sum(int[] input, int length)
{
var localSum = input[input.Length - length];
splitSum[input.Length - length] = localSum;
if(length == 1) return localSum;
var allSum = localSum + Sum(input, length-1);
splitSum[input.Length - length] =allSum;
return allSum;
}
}
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
int[] splitSum ;
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
splitSum = new int[A.Length+1];
var overallSum = Sum(A,A.Length);
for(int i=0;i<splitSum.Length; i++)
{
Console.WriteLine(splitSum[i]);
}
return 0;
}
int min = int.MaxValue;
int Sum(int[] input, int length)
{
var localSum = input[input.Length - length];
splitSum[input.Length - length] = localSum;
if(length == 1) return localSum;
var allSum = localSum + Sum(input, length-1);
splitSum[input.Length - length] =allSum;
return allSum;
}
}
13 10 9 7 3 0
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
int[] splitSum ;
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
splitSum = new int[A.Length+1];
var overallSum = Sum(A,A.Length);
for(int i=0;i<splitSum.Length; i++)
{
Console.WriteLine(splitSum[i]);
}
return 0;
}
int Sum(int[] input, int length)
{
var localSum = input[input.Length - length];
splitSum[input.Length - length] = localSum;
if(length == 1) return localSum;
var allSum = localSum + Sum(input, length-1);
splitSum[input.Length - length] =allSum;
return allSum;
}
}
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
int[] splitSum ;
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
splitSum = new int[A.Length+1];
var overallSum = Sum(A,A.Length);
int min = int.MaxValue;
for(int i=0;i<splitSum.Length; i++)
{
Console.WriteLine(splitSum[i]);
}
return 0;
}
int Sum(int[] input, int length)
{
var localSum = input[input.Length - length];
splitSum[input.Length - length] = localSum;
if(length == 1) return localSum;
var allSum = localSum + Sum(input, length-1);
splitSum[input.Length - length] =allSum;
return allSum;
}
}
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
int[] splitSum ;
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
splitSum = new int[A.Length+1];
var overallSum = Sum(A,A.Length);
int min = int.MaxValue;
for(int i=0;i<splitSum.Length; i++)
{
var diff = splitSum[i]-splitSum[i];
Console.WriteLine();
}
return 0;
}
int Sum(int[] input, int length)
{
var localSum = input[input.Length - length];
splitSum[input.Length - length] = localSum;
if(length == 1) return localSum;
var allSum = localSum + Sum(input, length-1);
splitSum[input.Length - length] =allSum;
return allSum;
}
}
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
int[] splitSum ;
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
splitSum = new int[A.Length+1];
var overallSum = Sum(A,A.Length);
int min = int.MaxValue;
for(int i=0;i<splitSum.Length; i++)
{
var diff = overallSum - splitSum[i];
Console.WriteLine();
}
return 0;
}
int Sum(int[] input, int length)
{
var localSum = input[input.Length - length];
splitSum[input.Length - length] = localSum;
if(length == 1) return localSum;
var allSum = localSum + Sum(input, length-1);
splitSum[input.Length - length] =allSum;
return allSum;
}
}
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
int[] splitSum ;
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
splitSum = new int[A.Length+1];
var overallSum = Sum(A,A.Length);
int min = int.MaxValue;
for(int i=0;i<splitSum.Length; i++)
{
var diff = overallSum - splitSum[i];
Console.WriteLine(diff);
}
return 0;
}
int Sum(int[] input, int length)
{
var localSum = input[input.Length - length];
splitSum[input.Length - length] = localSum;
if(length == 1) return localSum;
var allSum = localSum + Sum(input, length-1);
splitSum[input.Length - length] =allSum;
return allSum;
}
}
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
int[] splitSum ;
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
splitSum = new int[A.Length+1];
var overallSum = Sum(A,A.Length);
int min = int.MaxValue;
for(int i=0;i<splitSum.Length; i++)
{
var diff = overallSum - 2splitSum[i];
Console.WriteLine(diff);
}
return 0;
}
int Sum(int[] input, int length)
{
var localSum = input[input.Length - length];
splitSum[input.Length - length] = localSum;
if(length == 1) return localSum;
var allSum = localSum + Sum(input, length-1);
splitSum[input.Length - length] =allSum;
return allSum;
}
}
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
int[] splitSum ;
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
splitSum = new int[A.Length+1];
var overallSum = Sum(A,A.Length);
int min = int.MaxValue;
for(int i=0;i<splitSum.Length; i++)
{
var diff = overallSum - 2* splitSum[i];
Console.WriteLine(diff);
}
return 0;
}
int Sum(int[] input, int length)
{
var localSum = input[input.Length - length];
splitSum[input.Length - length] = localSum;
if(length == 1) return localSum;
var allSum = localSum + Sum(input, length-1);
splitSum[input.Length - length] =allSum;
return allSum;
}
}
-13 -7 -5 -1 7 13
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
int[] splitSum ;
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
splitSum = new int[A.Length+1];
var overallSum = Sum(A,A.Length);
int min = int.MaxValue;
for(int i=0;i<splitSum.Length; i++)
{
var diff = overallSum - 2* splitSum[i];
Console.WriteLine(diff);
Console.WriteLine(diff);
}
return 0;
}
int Sum(int[] input, int length)
{
var localSum = input[input.Length - length];
splitSum[input.Length - length] = localSum;
if(length == 1) return localSum;
var allSum = localSum + Sum(input, length-1);
splitSum[input.Length - length] =allSum;
return allSum;
}
}
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
int[] splitSum ;
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
splitSum = new int[A.Length+1];
var overallSum = Sum(A,A.Length);
int min = int.MaxValue;
for(int i=0;i<splitSum.Length; i++)
{
var diff = overallSum - 2* splitSum[i];
Console.WriteLine(diff);
Console.WriteLine(splitSum[i]);
}
return 0;
}
int Sum(int[] input, int length)
{
var localSum = input[input.Length - length];
splitSum[input.Length - length] = localSum;
if(length == 1) return localSum;
var allSum = localSum + Sum(input, length-1);
splitSum[input.Length - length] =allSum;
return allSum;
}
}
-13 13 -7 10 -5 9 -1 7 7 3 13 0
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
int[] splitSum ;
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
splitSum = new int[A.Length+1];
var overallSum = Sum(A,A.Length);
int min = int.MaxValue;
for(int i=0;i<splitSum.Length; i++)
{
var diff = overallSum - 2* splitSum[i];
// Console.WriteLine(diff);
Console.WriteLine(splitSum[i]);
}
return 0;
}
int Sum(int[] input, int length)
{
var localSum = input[input.Length - length];
splitSum[input.Length - length] = localSum;
if(length == 1) return localSum;
var allSum = localSum + Sum(input, length-1);
splitSum[input.Length - length] =allSum;
return allSum;
}
}
13 10 9 7 3 0
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
int[] splitSum ;
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
splitSum = new int[A.Length+];
var overallSum = Sum(A,A.Length);
int min = int.MaxValue;
for(int i=0;i<splitSum.Length; i++)
{
var diff = overallSum - 2* splitSum[i];
// Console.WriteLine(diff);
Console.WriteLine(splitSum[i]);
}
return 0;
}
int Sum(int[] input, int length)
{
var localSum = input[input.Length - length];
splitSum[input.Length - length] = localSum;
if(length == 1) return localSum;
var allSum = localSum + Sum(input, length-1);
splitSum[input.Length - length] =allSum;
return allSum;
}
}
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
int[] splitSum ;
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
splitSum = new int[A.Length];
var overallSum = Sum(A,A.Length);
int min = int.MaxValue;
for(int i=0;i<splitSum.Length; i++)
{
var diff = overallSum - 2* splitSum[i];
// Console.WriteLine(diff);
Console.WriteLine(splitSum[i]);
}
return 0;
}
int Sum(int[] input, int length)
{
var localSum = input[input.Length - length];
splitSum[input.Length - length] = localSum;
if(length == 1) return localSum;
var allSum = localSum + Sum(input, length-1);
splitSum[input.Length - length] =allSum;
return allSum;
}
}
13 10 9 7 3
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
int[] splitSum ;
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
splitSum = new int[A.Length];
var overallSum = Sum(A,A.Length);
int min = int.MaxValue;
for(int i=0;i<splitSum.Length; i++)
{
var diff = Math.abs(overallSum - 2* splitSum[i]);
Console.WriteLine(diff);
//Console.WriteLine(splitSum[i]);
}
return 0;
}
int Sum(int[] input, int length)
{
var localSum = input[input.Length - length];
splitSum[input.Length - length] = localSum;
if(length == 1) return localSum;
var allSum = localSum + Sum(input, length-1);
splitSum[input.Length - length] =allSum;
return allSum;
}
}
Compilation failed: 1 error(s), 0 warnings Solution.cs(20,29): error CS0117: `System.Math' does not contain a definition for `abs' /opt/lang/mono/lib/mono/4.5/mscorlib.dll (Location of the symbol related to previous error)
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
int[] splitSum ;
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
splitSum = new int[A.Length];
var overallSum = Sum(A,A.Length);
int min = int.MaxValue;
for(int i=0;i<splitSum.Length; i++)
{
var diff = Math.Abs(overallSum - 2* splitSum[i]);
Console.WriteLine(diff);
//Console.WriteLine(splitSum[i]);
}
return 0;
}
int Sum(int[] input, int length)
{
var localSum = input[input.Length - length];
splitSum[input.Length - length] = localSum;
if(length == 1) return localSum;
var allSum = localSum + Sum(input, length-1);
splitSum[input.Length - length] =allSum;
return allSum;
}
}
13 7 5 1 7
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
int[] splitSum ;
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
splitSum = new int[A.Length];
var overallSum = Sum(A,A.Length);
int min = int.MaxValue;
for(int i=1;i<splitSum.Length; i++)
{
var diff = Math.Abs(overallSum - 2* splitSum[i]);
Console.WriteLine(diff);
//Console.WriteLine(splitSum[i]);
}
return 0;
}
int Sum(int[] input, int length)
{
var localSum = input[input.Length - length];
splitSum[input.Length - length] = localSum;
if(length == 1) return localSum;
var allSum = localSum + Sum(input, length-1);
splitSum[input.Length - length] =allSum;
return allSum;
}
}
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
int[] splitSum ;
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
splitSum = new int[A.Length];
var overallSum = Sum(A,A.Length);
int min = int.MaxValue;
for(int i=1;i<splitSum.Length; i++)
{
var diff = Math.Abs(overallSum - 2* splitSum[i]);
Console.WriteLine(diff);
//Console.WriteLine(splitSum[i]);
}
return 0;
}
int Sum(int[] input, int length)
{
var localSum = input[input.Length - length];
splitSum[input.Length - length] = localSum;
if(length == 1) return localSum;
var allSum = localSum + Sum(input, length-1);
splitSum[input.Length - length] =allSum;
return allSum;
}
}
7 5 1 7
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
int[] splitSum ;
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
splitSum = new int[A.Length];
var overallSum = Sum(A,A.Length);
int min = int.MaxValue;
for(int i=1;i<splitSum.Length; i++)
{
var diff = Math.Abs(overallSum - 2* splitSum[i]);
if(min> diff) min = diff;
Console.WriteLine(diff);
//Console.WriteLine(splitSum[i]);
}
return 0;
}
int Sum(int[] input, int length)
{
var localSum = input[input.Length - length];
splitSum[input.Length - length] = localSum;
if(length == 1) return localSum;
var allSum = localSum + Sum(input, length-1);
splitSum[input.Length - length] =allSum;
return allSum;
}
}
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
int[] splitSum ;
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
splitSum = new int[A.Length];
var overallSum = Sum(A,A.Length);
int min = int.MaxValue;
for(int i=1;i<splitSum.Length; i++)
{
var diff = Math.Abs(overallSum - 2* splitSum[i]);
if(min> diff) min = diff;
Console.WriteLine(diff);
//Console.WriteLine(splitSum[i]);
}
return min;
}
int Sum(int[] input, int length)
{
var localSum = input[input.Length - length];
splitSum[input.Length - length] = localSum;
if(length == 1) return localSum;
var allSum = localSum + Sum(input, length-1);
splitSum[input.Length - length] =allSum;
return allSum;
}
}
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
int[] splitSum ;
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
splitSum = new int[A.Length];
var overallSum = Sum(A,A.Length);
int min = int.MaxValue;
for(int i=1;i<splitSum.Length; i++)
{
var diff = Math.Abs(overallSum - 2* splitSum[i]);
if(min> diff) min = diff;
Console.WriteLine(diff);
//Console.WriteLine(splitSum[i]);
}
return min;
}
int Sum(int[] input, int length)
{
var localSum = input[input.Length - length];
splitSum[input.Length - length] = localSum;
if(length == 1) return localSum;
var allSum = localSum + Sum(input, length-1);
splitSum[input.Length - length] =allSum;
return allSum;
}
}
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
int[] splitSum ;
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
splitSum = new int[A.Length];
var overallSum = Sum(A,A.Length);
int min = int.MaxValue;
for(int i=1;i<splitSum.Length; i++)
{
var diff = Math.Abs(overallSum - 2* splitSum[i]);
if(min> diff) min = diff;
//Console.WriteLine(diff);
//Console.WriteLine(splitSum[i]);
}
return min;
}
int Sum(int[] input, int length)
{
var localSum = input[input.Length - length];
splitSum[input.Length - length] = localSum;
if(length == 1) return localSum;
var allSum = localSum + Sum(input, length-1);
splitSum[input.Length - length] =allSum;
return allSum;
}
}
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
int[] splitSum ;
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
splitSum = new int[A.Length];
var overallSum = Sum(A,A.Length);
int min = int.MaxValue;
for(int i=1;i<splitSum.Length; i++)
{
var diff = Math.Abs(overallSum - 2* splitSum[i]);
if(min> diff) min = diff;
//Console.WriteLine(diff);
//Console.WriteLine(splitSum[i]);
}
return min;
}
int Sum(int[] input, int length)
{
var localSum = input[input.Length - length];
splitSum[input.Length - length] = localSum;
if(length == 1) return localSum;
var allSum = localSum + Sum(input, length-1);
splitSum[input.Length - length] =allSum;
return allSum;
}
}
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
int[] splitSum ;
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
splitSum = new int[A.Length];
var overallSum = Sum(A,A.Length);
int min = int.MaxValue;
for(int i=1;i<splitSum.Length; i++)
{
var diff = Math.Abs(overallSum - 2* splitSum[i]);
if(min> diff) min = diff;
//Console.WriteLine(diff);
//Console.WriteLine(splitSum[i]);
}
return min;
}
int Sum(int[] input, int length)
{
var localSum = input[input.Length - length];
splitSum[input.Length - length] = localSum;
if(length == 1) return localSum;
var allSum = localSum + Sum(input, length-1);
splitSum[input.Length - length] =allSum;
return allSum;
}
}
The solution obtained perfect score.