Java String Reverse Hackerrank Solution
For Explanation Watch Video:
Sample Input
madam
Sample Output
Yes
Code:
import java.io.*;import java.util.*;
public class Solution {
public static void main(String[] args) { Scanner sc=new Scanner(System.in); String A=sc.next(); StringBuilder sb = new StringBuilder(A); String n = sb.reverse().toString(); if(A.equals(n)){ System.out.println("Yes"); }else{ System.out.println("No"); } }}
Comments
Post a Comment