LeetCode 151. Reverse Words in a String || Java Solution Walkthrough

preview_player
Показать описание
LeetCode is a great platform for people who want general coding practice, whether that be for interviews or just wanting to practice their problem solving. I will be taking you through all the steps of finding the optimal solution to each problem on the site following a logical ordering setout by LeetCode themselves.

In this video, we are going over the problem 151. Reverse Words in a String and the goal is to detect each instance of a word, ignoring extra spaces anywhere in the string, and reversing the order of the words in the string. The ordering of the words themselves stays the same.

This is a medium problem that doesn't neccessarily have a pattern, you must just figure out the different parts involved to get it to work. The first step is to determine which indexes of the string contain a word. We can determine this by looking for letter or digits between space characters, and ignoring all spaces characters we find. Then we must copy those characters at the indexes we found to a new string in the correct order, also being sure to copy over a single space between each word before moving onto the next word.

~~~ Stay Up To Date With My Social Media ~~~

Feeling Generous? Donate to the stream to help cover equipment and upgrade costs at:

#unknownkoder #leetcode #algorithms
Рекомендации по теме