fueanta

LeetCode 151: Reverse Words in a String

Jul 8th, 2021
1,029
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function reverseWords(s: string): string {
  2.    
  3.     return s.trim()
  4.         .split(" ")
  5.         .filter(Boolean)
  6.         .reverse()
  7.         .join(" ");
  8. };
RAW Paste Data