check if LL is palindrome
Anonymous
public boolean palindromeLink() { Link current1=first; Link current2=last; while(current1!=null) { s1=s1+current1.d; current1=current1.next; } System.out.println("s1: "+s1); while(current2!=null) { s2=s2+current2.d; current2=current2.previous; } System.out.println("s2: "+s2); if(s1.equals(s2)) { return true; } else return false; }
Check out your Company Bowl for anonymous work chats.