← All problemsSign in

3028. Ant on the Boundary

LeetCodeArraySimulationPrefix SumOpen on judge ↗

An ant is on a boundary. It sometimes goes left and sometimes right. You are given an array of non-zero integers nums. The ant starts reading nums from the first element of it to its end. At each step, it moves according to the value of the current element: - If nums[i] < 0, it moves left by -nums[i] units. - If nums[i] > 0, it moves right by nums[i] units. Return the number of times the ant r

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start