HackerRank Java String Reverse problem solution YASH PAL, 31 July 2024 In this HackerRank Java string Reverse problem in the java programming language you have Given a string A, print Yes if it is a palindrome, print No otherwise. HackerRank java string reverses problem solution. 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(); /* Enter your code here. Print output to STDOUT. */ System.out.println( A.equals( new StringBuilder(A).reverse().toString()) ? "Yes" : "No" ); } } Second solution 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(); boolean valid = true; for(int i = 0; i < (A.length() / 2); i++) { if(A.charAt(i) != A.charAt((A.length() - 1) - i)) { valid = false; break; } // end if } // end for(i) if(valid) System.out.println("Yes"); else System.out.println("No"); } // end main } // end class The solution in java8 programming. 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(); /* Enter your code here. Print output to STDOUT. */ String reverse = new StringBuilder(A).reverse().toString(); if (A.equals(reverse)) { System.out.println("Yes"); } else { System.out.println("No"); } } } coding problems hackerrank solutions java