Skip to content

Commit 4da9e3c

Browse files
committed
feat(leetcode): add No.3028
1 parent 0383cc3 commit 4da9e3c

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

3028.Ant-on-the-Boundary.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// https://leetcode.com/problems/ant-on-the-boundary/description/
2+
// algorithms
3+
// Easy (75.0%)
4+
// Total Accepted: 37.5K
5+
// Total Submissions: 49.9K
6+
7+
8+
class Solution {
9+
10+
public int returnToBoundaryCount(int[] nums) {
11+
int curPosition = 0;
12+
int res = 0;
13+
14+
for (int n : nums) {
15+
curPosition += n;
16+
17+
if (curPosition == 0) {
18+
res += 1;
19+
}
20+
}
21+
22+
return res;
23+
}
24+
25+
}

0 commit comments

Comments
 (0)