← back to unit
Medium
# queues medium
Mirror Line?
Is the parade line the same read from both ends? Check it from BOTH ends at once! 🪞
You get the words of the line. Using a deque, repeatedly compare-and-remove the two ends. Print mirror line or not a mirror. (You solved mirrors with a stack — this is approach two. One more awaits!)
Example:
Input: words = ["drum", "horn", "flag", "horn", "drum"]
Output: mirror line
Comparing and removing both ends each round — drum = drum, horn = horn — leaves just flag in the middle, which is automatically fine.
💡 need a hint?
q-mirror-line.py🔒 given lines are locked — write your code in between
loading...