We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0383cc3 commit 4da9e3cCopy full SHA for 4da9e3c
3028.Ant-on-the-Boundary.java
@@ -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