One problem a day logo One problem a day
Browse problems
All problems 944 About this project

Categories

  • Array & Hashmap 217
  • Backtracking 33
  • Binary Search 27
  • Bit Manipulataion 25
  • Design 46
  • Dynamic Programming 85
  • Graph 74
  • Greedy 59
  • Heap 44
  • Intervals 16
  • Linked List 50
  • Math & Germetry 85
  • Queue 15
  • Sliding Window 29
  • Stack 48
  • Tree 122
  • Trie 14
  • Two Pointers 31

© 2026 One problem a day

Problems Reverse words in a string III
array and hashmap September 22, 2022

Reverse words in a string III

Time O(n) Space O(1) Open original problem

We will split the words, then reverse each word indivisually, then merge them together and return as result.

class Solution:
    def reverseWords(self, s: str) -> str:
        return ' '.join(word[::-1] for word in s.split())

Time Complexity: O(n)
Space Complexity: O(1)

Previous problem ← Sum of even numbers after queries
Next problem Partition to k equal sum subsets →

On this page

Start typing to search all 944 problems.
↑↓ Navigate ↵ Open Powered by Fuse.js