The only way to get better at solving algorithms and data structures is to power through a few. Can you write a function that reverses an inputted string without using the built-in Array#reverse method?
Can you write a function that reverses an inputted string without using the built-in Array#reverse
method?
Let’s look at some examples. So, calling:
reverseString("jake")
should return "ekaj"
.
reverseString("reverseastring")
should return "gnirtsaesrever"
.
This lesson was originally published at [https://algodaily.com_](https://algodaily.com/challenges/reverse-a-string), where I maintain a technical interview course and write think-pieces for ambitious developers._
In Java, C#, JavaScript, Python and Go, strings are immutable
. This means the string object's state can't be changed after creation.
Solution: True
Reversing a string is one of the most common technical interview questions that candidates get. Interviewers love it because it’s deceptively simple. After all, as a software engineer, you’d probably call the #reverse
method on your favorite String
class and call it a day!
So don’t overlook this one — it appears a surprising amount as a warm-up or build-up question. Many interviewers will take the approach of using an easy question like this one, and actually judge much more harshly. You’ll want to make you sure really nail this.
We want the string reversed, which means that we end up with all our letters positioned backwards. If you need a quick review of `string_`_s, check out [our lesson on arrays and strings_](https://algodaily.com/lessons/a-gentle-refresher-into-arrays-and-strings)._
data-structures technical-interview programming javascript algorithms
An interview for a coding/software position is incomplete without a coding interview. Here’s an explanation for common problems asked
Understanding concepts such as algorithmic complexity and proper use of data structures will enable you to write more optimal code. I will list a few tools you will have under your tool-belt after taking a typical algorithms course.
JavaScript implementation of data-structures and algorithms mentioned in this playlist may be found here https://github.com/trekhleb/javascript-algorithms
Arrays, Linked Lists, Stacks, Queues and Hash Tables. Working with any kind of algorithm starts with learning a set of data structures associated with it.
This is just meant as a friendly introduction to a topic that every computer science and data science program I know off explores in an entire course or a few.