Reverse a String - Microsoft Interview Question

preview_player
Показать описание
**A SUBTLETY ON THIS VIDEO** - I mention in this video that we can think of strings as character arrays. There's a caveat to thinking of strings as character arrays-- it's not always true. As readers and viewers have pointed out, a string represents text formed from graphemes (the smallest functional unit of a writing system)-- formed by combining character sequences in unicode.

Though strings and arrays contain similar methods like `length`, `concat`, and character position access-- they are not identical. As an example, arrays are mutable and strings usually are not. Before we can operate on the string as an array, we'll need to separate the units (in JS by calling the `.split()` method, or bypass this property by generating a brand new string instead of trying to operate on the original. However, after the `split` operation, we can apply that paradigm to operating on this string.

---

Today on AlgoDaily, we're going to reverse a string. 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.



---
Creative Commons Attribution-ShareAlike 3.0 Unported
Рекомендации по теме
Комментарии
Автор

The Java solution looked more like recursion that two pointers. It should have taken in a char[] instead of a string. That would have allowed the algo to focus on traversing arrays and two pointers.

fullmoonparty