NeetCode #759LC-514Hard2-D Dynamic Programming
← Back to All Problems

#759 · #514 · Freedom Trail(自由之路)

📌 Problem Statement & Constraints

The string ring is written around a dial with index 0 at the top, and a center button can be pressed. To spell key, rotate the ring so the needed character is at the top (one step per position, either direction) and press the button (one step). Return the minimum total steps to spell the entire key. Constraints: 1 <= ring.length, key.length <= 100, and key is spellable from ring.
🔒

Sign In to Unlock Full Solutions for All 973 Problems

Sign in to access step-by-step logic, benchmark Python3 code, complexity breakdown, and offline export!