Created
October 5, 2021 14:45
-
-
Save raghavddps2/4795f3cad4fdd04e4df4262e5a161b2a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.Scanner; | |
| import java.util.*; | |
| public class Main{ | |
| public static boolean checkPallindrome(int num){ | |
| int actualNum = num; | |
| int reverseNum = 0; | |
| int rem = 0; | |
| while(num >0){ | |
| rem = num%10; | |
| reverseNum=(reverseNum*10) + rem; | |
| num /= 10; | |
| } | |
| if(actualNum == reverseNum){ | |
| return true; | |
| } | |
| return false; | |
| } | |
| public static void main(String[] args) { | |
| Scanner sc = new Scanner(System.in); | |
| int size = sc.nextInt(); | |
| int arr[] = new int[size]; | |
| for(int i=0;i<size;i++){ | |
| arr[i] = sc.nextInt(); | |
| } | |
| Arrays.sort(arr); | |
| String res = String.valueOf(arr[arr.length-1]) + "-" + String.valueOf(arr[arr.length-2]) + "-"; | |
| if(checkPallindrome(arr[arr.length-2])){ | |
| res += "palindrome"; | |
| } | |
| else{ | |
| res += "notPalindrome"; | |
| } | |
| System.out.println(res); | |
| sc.close(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment