技术随感
搜索此博客
2011年2月23日星期三
Given a pointer to a node (not the tail node) in a singly linked list. Delete that node from the linked list.
Solution: move the data from the next node into the current node and then deleting the next node. This solution has O(1) runtime.
只给定单链表中某个结点p(非空结点),在p前面插入一个结点。
办法与前者类似,首先分配一个结点q,将q插入在p后,接下来将p中的数据copy入q中,然后再将要插入的数据记录在p中。
没有评论:
发表评论
较新的博文
较早的博文
主页
订阅:
博文评论 (Atom)
没有评论:
发表评论