Hard
Given an integer array nums, you start at index 0. From index i you can move to i+1, i-1, or any index j with nums[j] == nums[i] (all within bounds). Return the minimum number of steps to reach the last index.
Input: nums = [100,-23,-23,404,100,23,23,23,3,404] Output: 3
Input: nums = [7] Output: 0
Input: nums = [7,6,9,6,9,6,9,7] Output: 1