-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolution.java
More file actions
45 lines (39 loc) · 1.13 KB
/
Solution.java
File metadata and controls
45 lines (39 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package edu.buffalo.liveramp;
public class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
int j = 0,k = 0;
for(int i = 0;i<A.length;i++)
{
j = 0;
k = i+1;
int sum_I = 0;
int sum_J = 0;
// System.out.println(i);
while(j<i)
{
sum_I = sum_I +A[j];
j++;
}
System.out.println(sum_I);
while( k<=A.length-1)
{
sum_J = sum_J +A[k];
//System.out.println( k + " ");
k++;
}
System.out.println(sum_J);
if(sum_I== sum_J)
{
//System.out.println(sum_I + " "+i);
return i;
}
}
return -1;
}
public static void main(String[] args) {
Solution s = new Solution();
int i = s.solution(new int[]{0, 1111111111, -111111111});
System.out.println(i);
}
}