Skip to content

Commit

Permalink
[LEET-3340] add 3340
Browse files Browse the repository at this point in the history
  • Loading branch information
fishercoder1534 committed Nov 3, 2024
1 parent b3d7f8d commit 9782608
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions paginated_contents/algorithms/4th_thousand/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
| # | Title | Solutions | Video | Difficulty | Tag
|------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------|------------|----------------------------------------------------------------------
| 3340 | [Check Balanced String](https://leetcode.com/problems/check-balanced-string/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3340.java) | | Easy |
| 3330 | [Find the Original Typed String I](https://leetcode.com/problems/find-the-original-typed-string-i/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3330.java) | | Easy |
| 3324 | [Find the Sequence of Strings Appeared on the Screen](https://leetcode.com/problems/find-the-sequence-of-strings-appeared-on-the-screen/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3324.java) | | Easy |
| 3318 | [Find X-Sum of All K-Long Subarrays I](https://leetcode.com/problems/find-x-sum-of-all-k-long-subarrays-i/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3318.java) | | Easy |
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/com/fishercoder/solutions/fourththousand/_3340.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.fishercoder.solutions.fourththousand;

public class _3340 {
public static class Solution1 {
public boolean isBalanced(String num) {
int oddSum = 0;
int evenSum = 0;
for (int i = 0; i < num.length(); i++) {
if (i % 2 == 0) {
evenSum += Character.getNumericValue(num.charAt(i));
} else {
oddSum += Character.getNumericValue(num.charAt(i));
}
}
return oddSum == evenSum;
}
}
}

0 comments on commit 9782608

Please sign in to comment.