File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change 114114506|[ Relative Ranks] ( ./0506-relative-ranks.js ) |Easy|
115115541|[ Reverse String II] ( ./0541-reverse-string-ii.js ) |Easy|
116116551|[ Student Attendance Record I] ( ./0551-student-attendance-record-i.js ) |Easy|
117+ 557|[ Reverse Words in a String III] ( ./0557-reverse-words-in-a-string-iii.js ) |Easy|
117118565|[ Array Nesting] ( ./0565-array-nesting.js ) |Medium|
118119566|[ Reshape the Matrix] ( ./0566-reshape-the-matrix.js ) |Easy|
119120606|[ Construct String from Binary Tree] ( ./0606-construct-string-from-binary-tree.js ) |Easy|
Original file line number Diff line number Diff line change 1+ /**
2+ * 557. Reverse Words in a String III
3+ * https://leetcode.com/problems/reverse-words-in-a-string-iii/
4+ * Difficulty: Easy
5+ *
6+ * Given a string s, reverse the order of characters in each word within a sentence while
7+ * still preserving whitespace and initial word order.
8+ */
9+
10+ /**
11+ * @param {string } str
12+ * @return {string }
13+ */
14+ var reverseWords = function ( str ) {
15+ return str . split ( / \s / ) . map ( s => s . split ( '' ) . reverse ( ) . join ( '' ) ) . join ( ' ' ) ;
16+ } ;
You can’t perform that action at this time.
0 commit comments