Pergunta de entrevista da empresa Oracle

program to check if the provided string was Palindrome or not using recursion.

Resposta da entrevista

Sigiloso

18 de jan. de 2022

import java.util.Scanner; public class PalindromWithoutRec { public static void main(String args[]) { Scanner scan = new Scanner(System.in); int testCases = scan.nextInt(); while (testCases-- >= 0) { // do code for every TestCase here String str = scan.next(); boolean checkForFalse = false; for (int i = 0; i < str.length() / 2; i++) { if (str.charAt(i) != str.charAt(str.length() - i - 1)) { System.out.println("Not a palindrome"); checkForFalse = true; break; } } if (!checkForFalse) { System.out.println("Palindrome"); } } } }