Leetcode 1451: Rearrange Words in a Sentence
2 min readMay 26, 2020
In this Leetcode problem, we rearrange the words in a sentence given a couple of rules:
- Words with fewer letter are first
- If words have the same number of letters, they keep their original order in the sentence
Solution
This is mostly an ordering problem. To solve this, we define a Comparable
class Word
…