Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static boolean checkPalindrome(SLList list) {
- if (list == null || list.size() == 0){
- return true;
- }
- LibraryStack<Character> stack = new LibraryStack<>();
- int n = list.size()/2;
- int counter = 0;
- while (counter != n){
- stack.push(list.removeFirst());
- counter++;
- }
- if (list.size() % 2 == 1){
- list.removeFirst();
- }
- while(!stack.isEmpty()){
- if (stack.pop().equals(list.removeFirst())){
- return true;
- }
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement