Fruits are placed on an infinite number line. You are given a fruits where fruits[i] = [ position_i, amount_i ] indicates that there are amount_i fruits positioned at coordinate position_i. The array fruits is sorted by position_i in strictly ascending order.
You are also given two integers startPos and k. Initially, you are at position startPos. In one step, you can move k steps in total. Whenever you reach a coordinate containing fruits, you collect all fruits at that location. Each fruit can only be collected once.
Return the maximum total number of fruits you can collect.
Constraints:
fruits.length
fruits[i].length
startPos, position_i
position_position_
amount_i
k
Fruits are placed on an infinite number line. You are given a fruits where fruits[i] = [ position_i, amount_i ] indicates that there are amount_i fruits positioned at coordinate position_i. The array fruits is sorted by position_i in strictly ascending order.
You are also given two integers startPos and k. Initially, you are at position startPos. In one step, you can move k steps in total. Whenever you reach a coordinate containing fruits, you collect all fruits at that location. Each fruit can only be collected once.
Return the maximum total number of fruits you can collect.
Constraints:
fruits.length
fruits[i].length
startPos, position_i
position_position_
amount_i
k