Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Try using dynamic programming.
Consider a dp with the following states: The current position in the array b, and the number of indices considered.
Solve with full IDE support and test cases