there 3 lane road length n consist n 1 point label 0 n a frog start point 0 second lane want jump point n however obstacle wayyou give array obstacle length n 1 obstaclesi range 0 3 describe obstacle lane obstaclesi point if obstaclesi 0 obstacle point there obstacle 3 lane pointfor example obstacles2 1 obstacle lane 1 point 2the frog travel point point 1 lane obstacle lane point 1 to avoid obstacle frog perform jump jump lane adjacent point obstacle new laneFor example frog jump lane 3 point 3 lane 1 point 3return minimum number jump frog need reach lane point n start lane 2 point 0note there obstacle point 0 n example 1input obstacle 01230output 2 Explanation the optimal solution show arrow there 2 jump red arrowsNote frog jump obstacle make jump show point 2example 2input obstacle 011330output 0explanation there obstacle lane 2 no jump requiredExample 3input obstacle 021030output 2explanation the optimal solution show arrow there 2 jump Constraintsobstacleslength n 11 n 5 1050 obstaclesi 3obstacles0 obstaclesn 0