Skip to content

Commit aa8db6f

Browse files
committed
✨ upload 2574th java solution
1 parent 8218bdb commit aa8db6f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* Runtime: 3 ms
3+
* Memory Usage: 42 MB
4+
*/
5+
class Solution {
6+
public int[] leftRigthDifference(int[] nums) {
7+
int rightSum = Arrays.stream(nums).sum();
8+
int leftSum = 0;
9+
for (int i = 0; i < nums.length; ++ i) {
10+
int num = nums[i];
11+
rightSum -= num;
12+
nums[i] = Math.abs(leftSum - rightSum);
13+
leftSum += num;
14+
}
15+
return nums;
16+
}
17+
}

0 commit comments

Comments
 (0)