public static boolean test5(Node node) {
Stack<Integer> stack = new Stack<Integer>();
Node head = node;
while (head!=null) {
stack.push(head.value);
head = head.next;
}
while (!stack.isEmpty()) {
if (stack.pop()!=node.value) {
return false;
}
node = node.next;
}
return true;
}
网友评论