Yahoo India Web Search

Search results

  1. 3 days ago · 1. The idea is to traverse the length of the string . 2. Extract each character while traversing . 3. Add each character in front of the existing string. Implementation: Java.

  2. Reverse a String. You can easily reverse a string by characters with the following example: Example. String originalStr = "Hello"; String reversedStr = ""; for (int i = 0; i < originalStr.length(); i++) { . reversedStr = originalStr.charAt(i) + reversedStr; } System.out.println("Reversed string: "+ reversedStr); Try it Yourself »

  3. Reverse String. Easy. Write a function that reverses a string. The input string is given as an array of characters s. You must do this by modifying the input array in-place with O(1) extra memory. Example 1: Input: s = ["h","e","l","l","o"] Output: ["o","l","l","e","h"] Example 2: Input: s = ["H","a","n","n","a","h"]

  4. Jan 25, 2024 · Reverse a String. Solve Problem. Reverse String using a Loop: Initialize an empty string to store the reversed result. Iterate through the original string in reverse order. Append each character to the new string. The new string is the reversed version of the original string.

  5. 5 days ago · 1. Reverse a String Using reverse () Function. C++ provides a built-in function in the <algorithm> library called reverse (), which can be used to reverse a string efficiently. Syntax. reverse(str.begin(), str.end()) Example. C++.

  6. Sep 10, 2017 · public static String reverse(String input){ char[] in = input.toCharArray(); int begin=0; int end=in.length-1; char temp; while(end>begin){ temp = in[begin]; in[begin]=in[end]; in[end] = temp; end--; begin++; } return new String(in); }

  7. How to reverse String in Java. There are many ways to reverse String in Java. We can reverse String using StringBuffer, StringBuilder, iteration etc. Let's see the ways to reverse String in Java. 1) By StringBuilder / StringBuffer. File: StringFormatter.java

  1. People also search for