Write a program which finds if the given array is a palindrome. A palindrome array is in which the elements either printed from the beginning or printed from the end should be the same.
Input (Integer Array) | Output (Boolean) (TRUE / FALSE) |
---|---|
{ 6, 7, 8, 7, 6 } |
true |
{ 6, 7, 8, 9, 10 } |
false |
{ 88, 34, 145, 145, 34, 88 } |
true |
{ 88, 34, 145, 34, 88 } |
true |
class CheckIfArrayIsPalindrome
{ public static void main(String s[])
{
int [] input = { 6, 7, 8, 7, 6 };
System.out.println("The array { 6, 7, 8, 7, 6 } is palindrome : " + isArrayPalindrome(input));
}
public static boolean isArrayPalindrome(int[] input)
{
boolean result = false;
//Write code here to check if the array is a palindrome and assign the value to the result.
return result;
}
}
Topic: Learn Arrays And Loops