class Solution {
public:
int jump(vector<int>& nums) {
int currentBorder = 0;
int maxPosition = 0;
int steps = 0;
for (int i = 0; i < nums.size() - 1; i++) {
maxPosition = max(maxPosition, nums[i] + i);
if (i == currentBorder) {
currentBorder = maxPosition;
steps++;
}
}
return steps;
}
};