链表
bxyill
这个作者很懒,什么都没留下…
展开
-
在O(1)时间删除链表中某指定结点
题目:给定链表的头指针和一个结点指针,在O(1)时间删除该结点。链表结点的定义如下:structListNode{intm_nKey;ListNode*m_pNext;};函数的声明如下:voidDeleteNode(ListNode*pListHead,ListNode*pToBeDeleted);分析:这是一道广为流传的Google面试题,能有效考察我们的编程基转载 2012-11-18 09:31:19 · 873 阅读 · 0 评论 -
【100题】反转链表(递归实现)
//#include using namespace std;struct ListNode{ int data; struct ListNode *next;};//创建链表void createList(ListNode *&Head){ int num = 0; int flag = 0; ListNode *p = NULL; cin >> num;转载 2012-07-25 22:52:31 · 684 阅读 · 0 评论 -
【100题】找出链表倒数第k个元素
//查找链表中倒数第k个节点#include using namespace std;//定义链表节点结构struct ListNode{ int data; ListNode *next;};//创建不带头结点的单链表void createList(ListNode *&Head){ int num = 0; int flag = 0; ListNode *转载 2012-07-20 23:28:10 · 1607 阅读 · 0 评论 -
【面试题】链表合并-递归和非递归
#include #include typedef struct _Node{ int data; _Node* next;}Node, *LinkList; bool CreateList(LinkList &head, const int *data, const int len) { Node *cur = NULL; Node *next = NULL;转载 2012-09-14 00:44:31 · 797 阅读 · 1 评论 -
【100题】反转链表
//#include using namespace std;struct ListNode{ int data; struct ListNode *next;};//创建链表void createList(ListNode *&Head){ int num = 0; int flag = 0; ListNode *p = NULL; cin >> num;转载 2012-07-25 22:37:30 · 475 阅读 · 0 评论