Difficulty: Easy
Maximum Score: 10
Solved language: Java, Python, JavaScript, C++
Have the function FirstReverse(str) take the str parameter being passed and return the string in reversed order.
Examples 1:
Examples 2:
Solution - First Reverse Java Coderbyte Solution
Explanation:
In this Solution i used StringBuffer to find the reverse of given String.
1) Create StringBuffer object and pass the String value
2) Use reverse() of StringBuffer
3) Convert StringBuffer back to a string using toString().
Solution- First Reverse Coderbyte JavaScript
Explanation:
There is no reverse function for Strings in JavaScript BUT there is a reverse() function for arrays. I will use this built-in function for my solution.
1) Convert the string to an array using the split() function.
2) Use Array Reverse() function.
3) Convert array back to a string using join() function.
Solution- First Reverse Coderbyte Python
Disclaimer: The above Problem is generated by Coderbyte but the Solution is provided by ShouterFolk.
Excellent solutions
ReplyDelete