Skip to content

Commit

Permalink
344
Browse files Browse the repository at this point in the history
  • Loading branch information
Deepanshuchauhan123 committed Apr 22, 2021
1 parent 45802fe commit cb0980e
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions LeetCode Practice/Problem_344_reverseString.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import java.util.Scanner;

class Problem_344_reverseString{
static Scanner sc = new Scanner(System.in);

public static void main(String[] args) {
try {
String value;
System.out.println("Enter String = ");
value = sc.nextLine();
char arr[] = value.toCharArray();
reverse_String(arr);
} catch (Exception e) {
e.printStackTrace();
}

}

static void reverse_String(char arr[]) {
char c;
for (int left = 0, right = arr.length - 1; left < right; left++, right--) {
c = arr[left];
arr[left] = arr[right];
arr[right] = c;
}
System.out.println(arr);
}
}

0 comments on commit cb0980e

Please sign in to comment.