CareerCup 2.6
来源:互联网 发布:淘宝超级掌柜 编辑:程序博客网 时间:2024/04/29 16:05
2.6 Given a circular linked list, implement an algorithem which returns the node at the beginning of the loop.
struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {}};
ListNode* findBeginning(ListNode *head) { ListNode *fast = head; ListNode *slow = head; while (fast && fast->next) { slow = slow->next; fast = fast->next->next; if (slow == fast) { break; } } if (fast == NULL || fast->next == NULL) { return NULL; } slow = head; while (slow != fast) { slow = slow->next; fast = fast->next; } return fast;}
- CareerCup 2.6
- CareerCup 1.3
- CareerCup 1.4
- CareerCup 5.7
- CareerCup 14.6
- CareerCup 1.1
- CareerCup 1.2
- CareerCup 1.3
- CareerCup 1.4
- CareerCup 1.5
- CareerCup 1.6
- CareerCup 1.7
- CareerCup 1.8
- CareerCup 2.1
- CareerCup 2.2
- CareerCup 2.3
- CareerCup 2.4
- CareerCup 2.5
- Java Arrays Tutorial (3)
- Android中Rect和RectF的区别
- hadoop基本命令
- 仿人智能控制器的参数简化(已发表于《计算机测量与控制》2013年第4期)
- 零字节WSASend,WSARecv
- CareerCup 2.6
- .net中js取服务端控件的值
- asp.net中onclientclick事件与服务器事件click
- linq hello world
- 新一代数据访问工具(二)--SQLDataSource
- sqldatasource 检测是否插入记录成功
- c# 调用js函数
- js与c#互相调用方法
- 去除链接 的虚框