Coding Interview Tutorial 52: Reverse Words in a String [LeetCode]

preview_player
Показать описание
Learn how to reverse the words in a string in a concise and simple way!

This is an important programming interview question, and we use the LeetCode platform to solve this problem.
Рекомендации по теме
Комментарии
Автор

There are two categories of solutions. The hard way would comprise basically reversing the letters in the sentence and also reversing the letters in each word. That would correct the problem. This is not a good solution, but one the interviewer might expect. The better way is to use the standard library methods. In C++ you would define an iterator for the std::reverse function that understands what is meant by words. Now you've not only solved the problem given, but you have an iterator where you could use every standard library algorithm with the sentence.

bessermt
Автор

I was hoping you would solve it without using trim or split helpers.

walterwhite
Автор

cmon man, you can do better than this. am a fan. dont use inbuilt methods.

snehasish
visit shbcf.ru