Skip to content

Commit 82c0b37

Browse files
committed
1216
1 parent e956057 commit 82c0b37

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Feel free to submit pull requests, add issues and be a contributer.
7171
| Leetcode | [674. Longest Continuous Increasing Subsequence](https://leetcode.com/problems/longest-continuous-increasing-subsequence/description/) | [Java](./java/findLengthOfLCIS.java) | _O(n)_ | _O(1)_ | Easy | |
7272
| Leetcode | [713. Subarray Product Less Than K](https://leetcode.com/problems/subarray-product-less-than-k/description/) | [Java](./java/numSubarrayProductLessThanK.java) | _O(n)_ | _O(1)_ | Medium | |
7373
| Leetcode | [714. Best Time to Buy and Sell Stock with Transaction Fee](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/description/) | [Java](./java/maxProfitWithFee.java) | _O(n)_ | _O(1)_ | Medium | |
74-
74+
| Leetcode | [724. Find Pivot Index](https://leetcode.com/problems/find-pivot-index/description/) | [Java](./java/pivotIndex.java) | _O(n)_ | _O(1)_ | Easy | |
7575

7676

7777
## Strings

java/pivotIndex.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution {
2+
public int pivotIndex(int[] nums) {
3+
int sum = 0, leftSum = 0;
4+
5+
for(int num: nums)
6+
sum += num;
7+
8+
9+
for(int i=0; i<nums.length; i++)
10+
{
11+
if(leftSum == sum - leftSum - nums[i])
12+
return i;
13+
leftSum += nums[i];
14+
}
15+
return -1;
16+
}
17+
}

0 commit comments

Comments
 (0)