In Showcase Name Roll, you are given a single string and need to return a new string with all of its characters in reverse order.
This is a character-by-character reversal problem. You are not sorting letters alphabetically, removing punctuation, or skipping spaces. Every character that appears in the original string should still appear in the answer, just in the opposite direction from end to start.
For example, s = "hello" becomes "olleh". The string "Hannah" becomes "hannaH", which shows that uppercase and lowercase letters stay exactly as they were and are simply moved to mirrored positions. A longer string like "A man, a plan, a canal: Panama" becomes "amanaP :lanac a ,nalp a ,nam A", and that example makes it clear that spaces, commas, and colons are also part of the reversal.
If the input is empty, the answer is also an empty string. So the task is simply to flip the entire string from back to front.
Example Input & Output
The characters appear in the exact opposite order.
Uppercase and lowercase letters stay unchanged; only their positions are reversed.
Spaces and punctuation are part of the reversal too.
Algorithm Flow

Solution Approach
The simplest way to solve this problem is to reverse the string from end to start and return the reversed result. Since the task is only about flipping character order, you do not need sorting, counting, or any complex data structure. You just need a reliable way to visit the characters in reverse order.
One very common approach is to split the string into characters, reverse that array, and join it back into a string. In JavaScript, that looks like this:
This works well for the kind of test cases used here because the inputs are ordinary ASCII-style strings. The call to split('') turns the string into an array of single-character strings. Then reverse() flips their order in place, and join('') stitches them back together without any separator.
Another way to think about the same problem is with two pointers or a backward loop. You could start from the last index, append each character into a result string, and stop when you reach the beginning. That version is also easy to understand and makes the reversal process very explicit. For example:
Both approaches preserve every character exactly as it appears in the input. That matters because punctuation and spaces are not special cases here. In the long sample with commas and a colon, those characters move into reversed positions just like letters do. The same idea also explains why "Hannah" becomes "hannaH": the string is mirrored exactly, not normalized in any way.
Edge cases are simple too. An empty string returns an empty string because there are no characters to reverse. A one-character string returns itself. Palindromes are not treated specially; they just happen to look similar after reversal if their characters mirror naturally.
The time complexity is O(n) because every character is processed once. The extra space is also O(n) because you build a new reversed result. So the full strategy is: take the input string, reverse the order of all characters, and return the reversed string exactly as a new string.
Best Answers
import java.util.*;
class Solution {
public String[] organize_names(String[] names) {
String[] res = names.clone();
Arrays.sort(res);
return res;
}
}Comments (0)
Join the Discussion
Share your thoughts, ask questions, or help others with this Challenge.
