Hackerrank - Java Solution - Java String Reverse Solution - Online Judge Solution

Latest

It is a free Online judges problems solution list. Here you can find UVA online Judge Solution, URI Online Judge Solution, Code Marshal Online Judge Solution, Spoz Online Judge Problems Solution

Tuesday, December 12, 2017

Hackerrank - Java Solution - Java String Reverse Solution

Hackerrank - Java Solution - Java String Reverse Solution

HackerRank Problem Solution

Problem Name - Java String Reverse
Problem Link -  Java String Reverse 
Level - String

Java Code
import java.util.Scanner;

public class Solution {
    public static void main(String[] args) {
        /* Read input */
        Scanner scan = new Scanner(System.in);
        String str = scan.nextLine();
        scan.close();
        
        /* Reverse string and compare to original */
        /* If a String is equivalent to itself when reversed, it's a palindrome */
        
        String reversed = new StringBuilder(str).reverse().toString();
        System.out.println(str.equals(reversed) ? "Yes" : "No");
    }
}



Tags: HackerRank Online Judge Solution, HackerRank OJ Solution list, HackerRank Problems Solution, HackerRank solver, HackerRank all problem solution list, HackerRank solution in java, Hackerrank Java Solution, Hackerrank Online Judge Solution, Hackerrank - Java Solutions, Hackerrank - Java Solution - Java String Reverse Solution

No comments:

Post a Comment