This is an open source platform. Create coding videos, upload them on YouTube, and help the community grow.
Teaching is the fastest way to learn β and the best way to never forget what you know π
Screen only
Screen With Camera
β‘Start Recording
Selected Template
Start Recording
Generating Thumbnail...
Difficulty:
function reverseString(s) { return s.split('').reverse().join(''); }
Explanation: We split the string into characters, reverse the array, and then join it back into a string.
β± O(n) | πΎ O(n)
class Solution { public String reverseString(String s) { return new StringBuilder(s).reverse().toString(); } }
Explanation: StringBuilder provides a built-in reverse method which efficiently reverses the string.
def reverse_string(s): return s[::-1]
Explanation: Python slicing with a step of -1 returns the reversed string.
Solve using editor β