Tagged in

Python

Towards Dev
Towards Dev
A publication for sharing projects, ideas, codes, and new theories.
More information
Followers
3.6K
Elsewhere
More, on Medium

LeetCode Problem no. 1859

Question no. 1859. Sorting the Sentence

class Solution:
def sortSentence(self, s: str) -> str:
ans = []

for i in range(len(s)):
if i == len(s)-1 or s[i+1] == " ":
ans.append("")

a = ""

for i…