#1824

Minimum Sideway Jumps

specialist · 845 · lc medium +31 · verified · 51.5% accepted · 1,281 likes · top 41%

Description

A frog in lane 2 at point 0 must reach point n on a 3-lane road. It advances in its lane unless blocked by an obstacle, in which case it may side-jump (free) to another unblocked lane. obstacles[i] (0-3) is the blocked lane at point i. Return the minimum side jumps needed.

Code

1
2
3