Python-algos: Sentence Reversal

def rev_word3(s):

words = []
length = len(s)
spaces = [' ']
i = 0
while i < length:
if s[i] not in spaces:
word_start = i

while i < length and s[i] not in spaces:
i += 1
words.append(s[word_start:i])
i += 1
return " ".join(reversed(words))

--

--

--

Problem solver with experience in Software, and Mechanical engineering. Interested in web-dev, machine learning, artificial intelligence, and new technologies.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How to install the LAMP stack on a new server.

Disasters Will Happen

How to Bridge ISP-Provided Gateway to Router

So, Magento sucks and you need an alternative

Building a Product Page in Flutter — Part 2

System Architecture — System Design Materials

Top 20 Algorithms Problems for Coding Interviews with Solutions

20+ Algorithms Coding Problems for Programming and Technical Interviews

Clever SSO Reliability — July 2018 Update

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Avitosh Totaram

Avitosh Totaram

Problem solver with experience in Software, and Mechanical engineering. Interested in web-dev, machine learning, artificial intelligence, and new technologies.

More from Medium

How to Train a Scalable Classifier with FastAPI and SerpApi ?

Train your models faster on AWS: Storage Medium

Tensorflow on multiple GPUs with FastAPI

Binary Search