The problem: Palindrome: Implement a function to check if a linked list is a palindrome
If it's a palindrome, the list must be the same backwards and forwards
Below is the code I wrote,:
def isPalindrome[A](list:List[A]):Boolean= (list.head, list.last)match{
case (a,b) if a==b&&list.size>2 => isPadorom[A]isPalindrome[A](list.tail.dropRight(1))
case (a,b) if a==b&&list.size<=2 => true
case (a,b) if a!=b =>false
}
May I know is there any way to improve it?