摘要: http://oj.leetcode.com/problems/linked-list-cycle-ii/Given a linked list, return the node where the cycle begins. If there is no cycle, return null.Follow up:Can you solve it without using extra space?思路:如果前面Linked List Cycle的问题已经解决,再扩展一下就可以了。如果一步走两步走的方法在某个点交汇了,那么这个点肯定在环内。那么算出环的长度n,令某个节点从head出发先走n步, 阅读全文
posted @ 2013-11-01 13:33 移山测试工作室黑灯老师 阅读(461) 评论(0) 推荐(0) 编辑
摘要: http://oj.leetcode.com/problems/valid-sudoku/Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character '.'.A partially filled sudoku which is valid.思路:按行,按列,再按3 * 3小方块检查,只要都通过就返回true,不然 阅读全文
posted @ 2013-11-01 13:12 移山测试工作室黑灯老师 阅读(2755) 评论(0) 推荐(0) 编辑
摘要: http://oj.leetcode.com/problems/search-insert-position/Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the array.Here are few examples.[1,3,5,6], 5 → 2[1,3,5,6], 阅读全文
posted @ 2013-11-01 12:52 移山测试工作室黑灯老师 阅读(249) 评论(0) 推荐(0) 编辑
摘要: http://oj.leetcode.com/problems/search-for-a-range/Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the order of O(log n).If the target is not found in the array, return [-1, -1].For example,Given [5, 7 阅读全文
posted @ 2013-11-01 11:52 移山测试工作室黑灯老师 阅读(395) 评论(0) 推荐(0) 编辑
摘要: http://oj.leetcode.com/problems/search-in-rotated-sorted-array/Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target value to search. If found in the array return its index, otherwise return -1.You may assume 阅读全文
posted @ 2013-11-01 11:11 移山测试工作室黑灯老师 阅读(592) 评论(0) 推荐(0) 编辑
count website visits
Buy Computers