← back to unit
Medium
# sorting medium
Ordered by Length, Not Letters
The scrabble champion stacks tiles words shortest to longest, and couldn't care less about the alphabet. 🔠
You get a list of words. Print stacked if each word is at least as long as the one before it, otherwise restack.
Example:
Input: words = ["ox", "cat", "bear", "horse"]
Output: stacked
The lengths go 2, 3, 4, 5 — each word is at least as long as the one before it, so the stack is fine.
💡 need a hint?
sort-by-length-check.py🔒 given lines are locked — write your code in between
loading...