Mirror words: A literary detective game

Report a typo

Hey there! This problem might be a bit unpredictable, but give it a go and let us know how you do!

Create a program that checks if a given string is a palindrome, ignoring spaces and case. A palindrome reads the same forwards and backwards. Read a string input and print 'Yes' if it's a palindrome, and 'No' otherwise.

You can use the reverse() method of StringBuilder to easily reverse a string.

Sample Input 1:

A man a plan a canal Panama

Sample Output 1:

Yes

Sample Input 2:

race a car

Sample Output 2:

No
Write a program in Java 25
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String input = scanner.nextLine();

// Implement palindrome check here
boolean isPalindrome = false;

// Print result
System.out.println(isPalindrome ? "Yes" : "No");
}
}

Create a free account to access the full topic