You are given a circular array of strings words and a string target. You are also given an integer startIndex representing your starting position in words.
In a circular array, moving right from the last index leads to the first index, and moving left from the first index leads to the last index.
Starting from startIndex, you can move either left or right by
Return the shortest distance needed to reach any index where the string is equal to target. If target does not exist in words, return
Constraints:
words.length
words[i].length
words[i] and target consist of only lowercase English letters.
startIndex words.length
You are given a circular array of strings words and a string target. You are also given an integer startIndex representing your starting position in words.
In a circular array, moving right from the last index leads to the first index, and moving left from the first index leads to the last index.
Starting from startIndex, you can move either left or right by
Return the shortest distance needed to reach any index where the string is equal to target. If target does not exist in words, return
Constraints:
words.length
words[i].length
words[i] and target consist of only lowercase English letters.
startIndex words.length