title: Finding palindromes in a linked list
body: <p>This is an interview question(again). </p>
  
  <blockquote>
    <p>Given a singly connected linked list, find the largest palindrome
    in the list. (You may assume the length of the palindrome is even)</p>
  </blockquote>
  
  <p>The first approach I made was using a stack - we traverse over the list from the start and keep pushing in the letters. Whenever we find the letter on the top of the stack is same as the next letter on the linked list, start popping(and incrementing the linked list pointer) and set a count on the number of letters that matches. After we find a mismatch, push back all the letters that you popped from the stack, and continue your pushing and popping operations. The worst case complexity of this method would be O(n2) e.g. when the linked list is just a string of the same letters.  </p>
  
  <p>To improve on the space and time complexity(by some constant factors), I proposed copying the linked list to an array and finding the largest sized palindrome in  the array which again takes O(n2) time complexity and O(n) space complexity. </p>
  
  <p>Any better approach to help me with? :( </p>