Description
Given a ring of characters and a key string, find the minimum steps to spell the key by rotating the ring and pressing center. Return minimum steps.
Examples
Input:
ring = "godding", key = "gd"Output:
4Explanation:
2 rotations + 2 confirms.
Input:
ring = "a", key = "a"Output:
0Explanation:
Edge case with a single character.
Input:
ring = "iotfo", key = "foo"Output:
5Explanation:
The minimum number of steps to spell 'foo' on ring 'iotfo' is 5, using counterclockwise rotations and confirms.
Constraints
- •
1 ≤ ring.length, key.length ≤ 100