Playing Hacks and Stuffs!
Given a string s
, reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.
To solve this I just converted the words in the string to a list and then iterate through the list and reverse the characters, then returned it’s reformed value
Solve Script: link
class Solution:
def reverseWords(self, s: str) -> str:
arr = s.split()
r = []
for i in range(len(arr)):
r.append(arr[i][::-1])
return " ".join(r)