摘要: http://oj.leetcode.com/problems/linked-list-cycle/Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?思路:这个问题是面试时很常见的问题,但是要求写代码的比较少。最简单的方法就是两个指针,一个每次走一步,一个每次走两步,等赶上了就说明有环。 1 class Solution { 2 public: 3 bool hasCycle(ListNode *head) { 4 ... 阅读全文
posted @ 2013-10-31 17:58 移山测试工作室黑灯老师 阅读(207) 评论(0) 推荐(0) 编辑
摘要: http://oj.leetcode.com/problems/longest-valid-parentheses/Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the longest valid parentheses substring is "()", which has leng 阅读全文
posted @ 2013-10-31 17:34 移山测试工作室黑灯老师 阅读(373) 评论(0) 推荐(0) 编辑
count website visits
Buy Computers