Check if a linked list of strings forms a palindrome | C # Program to check if a given linked list of strings form a palindrome ; Linked List node ;  ; A utility function to check if str is palindrome or not ; Match characters from beginning and end . ; Returns true if string formed by linked list is palindrome ; Append all nodes to form a string ; Check if the formed string is palindrome ; Driver code
using System ; class Node { public String data ; public Node next ; public Node ( String d ) { data = d ; next = null ; } } public class LinkedList_Palindrome { Node head ; bool isPalidromeUtil ( String str ) { int length = str . Length ; for ( int i = 0 ; i < length / 2 ; i ++ ) if ( str [ i ] != str [ length - i - 1 ] ) return false ; return true ; } bool isPalindrome ( ) { Node node = head ; String str = " " ; while ( node != null ) { str = str + ( node . data ) ; node = node . next ; } return isPalidromeUtil ( str ) ; } public static void Main ( String [ ] args ) { LinkedList_Palindrome list = new LinkedList_Palindrome ( ) ; list . head = new Node ( " a " ) ; list . head . next = new Node ( " bc " ) ; list . head . next . next = new Node ( " d " ) ; list . head . next . next . next = new Node ( " dcb " ) ; list . head . next . next . next . next = new Node ( " a " ) ; Console . WriteLine ( list . isPalindrome ( ) ) ; } }