Leetcode 1451: Rearrange Words in a Sentence

  • Words with fewer letter are first
  • If words have the same number of letters, they keep their original order in the sentence
Problem statement

Solution

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store