Problem Description:Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull.Follow up:Can you solve it without u...
分类:
其他好文 时间:
2014-07-07 17:00:35
阅读次数:
161
Problem Description:Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?Solution: 1 public bo....
分类:
其他好文 时间:
2014-07-07 16:08:01
阅读次数:
151
Problem Description:Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your pr...
分类:
其他好文 时间:
2014-07-07 15:46:01
阅读次数:
267
You are given annxn2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?矩阵的旋转如1 2 34 5 67 8...
分类:
其他好文 时间:
2014-07-07 15:13:49
阅读次数:
181
题目:Linked List Cycle IIGiven a linked list, return the node where the cycle begins. If there is no cycle, returnnull.Follow up:Can you solve it withou...
分类:
其他好文 时间:
2014-07-07 13:44:29
阅读次数:
281
Follow up for "Search in Rotated Sorted Array":What if duplicates are allowed?
分类:
其他好文 时间:
2014-07-07 13:07:00
阅读次数:
153
Follow up for "Remove Duplicates":What if duplicates are allowed at most twice?
分类:
其他好文 时间:
2014-07-03 11:51:05
阅读次数:
117
题目
Follow up for N-Queens problem.
Now, instead outputting board configurations, return the total number of distinct solutions.
方法
和上题方法一样,使用回溯法,结构基本相同,只需要返回数量。
public i...
分类:
其他好文 时间:
2014-06-30 06:24:22
阅读次数:
273
题目
Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.
Follow up:
Did you use extra space?
A straight forward solution using O(mn) space is probab...
分类:
其他好文 时间:
2014-06-30 06:17:09
阅读次数:
245
【题目】
Given a linked list, determine if it has a cycle in it.
Follow up:
Can you solve it without using extra space?
【题意】
判断一个单向链表是否有环
【思路】
维护两个指针p1和p2,p1每次向前移动一步,p2每次向前移动两步
如果p2能够追上p1,则说明链表中存在环...
分类:
其他好文 时间:
2014-06-29 22:51:33
阅读次数:
267