In the introduction of this series, I talked about how I wanted to dive right into runtime complexity. After thinking about this concept for a little while, I realized that trying to comprehend runtime complexity would be awfully difficult without any experience in solving some of these types of problems first. So in this blog, I’m going to start with a very basic beginner question to help get the ball rolling. Feel free to try the solutions out by creating the function in Google Chrome’s developer console, creating a string, and then calling the function with the string as the argument.

Let’s get started!

String reversal is one of the most commonly given beginner algorithm questions and although it might not show up frequently in technical interviews, it’s a good way to start working with algorithms in general:

Given a string, write a function that will take an input of a string and then reverse that string. For example, “Hello world!”, when inputted into the function, would return “!dlrow olleH”.

There are three different ways to tackle this problem.

#javascript #programming #data-structures #coding #algorithms

JavaScript Algorithms: Simple String Reversal
1.15 GEEK