Skip to content

Commit

Permalink
feat(leetcode): add No.3028
Browse files Browse the repository at this point in the history
  • Loading branch information
mickey0524 committed Mar 21, 2024
1 parent 0383cc3 commit 4da9e3c
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions 3028.Ant-on-the-Boundary.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// https://leetcode.com/problems/ant-on-the-boundary/description/
// algorithms
// Easy (75.0%)
// Total Accepted: 37.5K
// Total Submissions: 49.9K


class Solution {

public int returnToBoundaryCount(int[] nums) {
int curPosition = 0;
int res = 0;

for (int n : nums) {
curPosition += n;

if (curPosition == 0) {
res += 1;
}
}

return res;
}

}

0 comments on commit 4da9e3c

Please sign in to comment.