Algorithm · ByteDance · Easy
Problem You are given an array cost of length n. Each entry cost[i] is the price charged whenever you step onto index i. Your path starts at index 0, and from any index you may jump forward either 1 or 2 positions. The goal is to reach index n - 1. The total cost is the sum of cost[i] for every index you occupy, including the starting index. In other words: Paying cost[0] is required to begin at index 0. Each time you land on index i, add cost[i] to the total. Return the…
Checking your access…