Practice Freedom Trail
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Freedom Trail
Problem Statement
A circular ring displays the characters of ring, initially with ring[0] at the 12 o'clock pointer. Spell key in order. Rotating the ring by one position clockwise or counterclockwise costs one step. When the next required character reaches the pointer, pressing the center button records it and costs one additional step. The ring stays in its current orientation for the next character. Return the minimum total steps needed to enter all of key.
Source: Freedom Trail on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
ring = "godding", key = "gd"
4
# Example 2
ring = "godding", key = "godding"
13
Constraints
Related LeetCode Problems
Practice more problems similar to Freedom Trail.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.