由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - Doubly Linked List reverse Why I cann't reverse twice
相关主题
一个Java面试题目帮忙看一段小程序有没问题,谢谢
ms面试题hash table 如果是doubly linked 为啥删除也是 O(1)呢
BST to double linked list的codeconvert bst to doubly linked list 求个干净容易理解的答案
贡献几道amazon电面题Python有什么好的数据结构2-day or 3-day学习资料?
std::list如何检测环?也发一个 F,L,G 电面
为什么我做了快1000道题了,还是不行呢?!bloomberg onsite被据,暑假3个月怎么过新手求建议
remove a node (and its memory) from a doubly linked list问一道常见面试题,reverse a linked list
Some coding problems from Amazonalternative solution to detect cycle in linked list
相关话题的讨论汇总
话题: reverse话题: temp话题: doublenode话题: null话题: head
进入JobHunting版参与讨论
1 (共1页)
s******d
发帖数: 61
1
public void reverse(){
DoubleNode start=head;
DoubleNode temp=null;
while(head!=null){
temp=head.getNext();
head.setNext(head.prev);
head.setPrev(temp);
if(head.getPrev()==null){
head.setPrev(start);
break;
}
head=head.getPrev();
}

}
If I reverse onece, it prints successfully. While I reverse again, it prints
nothing.
Appreciate your help!
1 (共1页)
进入JobHunting版参与讨论
相关主题
alternative solution to detect cycle in linked liststd::list如何检测环?
如何 reversely print一个single linked-list中各个node里的数据?为什么我做了快1000道题了,还是不行呢?!
问个reverse linked listremove a node (and its memory) from a doubly linked list
内疚啊~~ 一周才做3小时题Some coding problems from Amazon
一个Java面试题目帮忙看一段小程序有没问题,谢谢
ms面试题hash table 如果是doubly linked 为啥删除也是 O(1)呢
BST to double linked list的codeconvert bst to doubly linked list 求个干净容易理解的答案
贡献几道amazon电面题Python有什么好的数据结构2-day or 3-day学习资料?
相关话题的讨论汇总
话题: reverse话题: temp话题: doublenode话题: null话题: head