摘要: Given an array of integers and an integerk, find out whether there are two distinct indicesiandjin the array such thatnums[i] = nums[j]and the differe... 阅读全文
posted @ 2015-10-24 13:48 fenshen371 阅读(88) 评论(0) 推荐(0) 编辑
摘要: Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull.Note:Do not modify the linked list.Follow up:Can you sol... 阅读全文
posted @ 2015-10-24 12:44 fenshen371 阅读(153) 评论(0) 推荐(0) 编辑
摘要: Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?思路:维护两个指针,一快一慢,判断两个指针能否相遇。 1 class Solutio... 阅读全文
posted @ 2015-10-24 11:27 fenshen371 阅读(114) 评论(0) 推荐(0) 编辑
摘要: Reverse a linked list from positionmton. Do it in-place and in one-pass.For example:Given1->2->3->4->5->NULL,m= 2 andn= 4,return1->4->3->2->5->NULL.No... 阅读全文
posted @ 2015-10-24 11:12 fenshen371 阅读(135) 评论(0) 推荐(0) 编辑
摘要: Given a linked list, reverse the nodes of a linked listkat a time and return its modified list.If the number of nodes is not a multiple ofkthen left-o... 阅读全文
posted @ 2015-10-24 10:44 fenshen371 阅读(145) 评论(0) 推荐(0) 编辑
摘要: Given an array withnobjects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, wh... 阅读全文
posted @ 2015-10-24 10:18 fenshen371 阅读(145) 评论(0) 推荐(0) 编辑
摘要: Given a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4, you should return the list as2->1->4->3.Your algor... 阅读全文
posted @ 2015-10-24 02:17 fenshen371 阅读(127) 评论(0) 推荐(0) 编辑