LeetCode 2515 Python Solution: Shortest Distance in Circular Array
Problem Summary You are given: You need to find the shortest distance from startIndex to any index where words[i] == target. Because the array is circular, you can move: If the target does not exist, return -1. Key Observation For every index i where words[i] == target, the circular distance from startIndex is: So the … Read more