摘要: Given a linked list, determine if it has a cycle in it. Follow up:Can you solve it without using extra space? 解决这个问题需要很巧妙的思路,一般我们会想到观察链表中是否出现过重复出现的节点。 阅读全文
posted @ 2016-04-18 19:57 Black_Knight 阅读(143) 评论(0) 推荐(0) 编辑
摘要: Reverse a linked list from position m to n. Do it in-place and in one-pass. For example:Given 1->2->3->4->5->NULL, m = 2 and n = 4, return 1->4->3->2- 阅读全文
posted @ 2016-04-18 17:09 Black_Knight 阅读(205) 评论(0) 推荐(0) 编辑
摘要: Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the 阅读全文
posted @ 2016-04-18 16:23 Black_Knight 阅读(148) 评论(0) 推荐(0) 编辑
摘要: Given a sorted linked list, delete all duplicates such that each element appear only once. For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, 阅读全文
posted @ 2016-04-18 10:35 Black_Knight 阅读(135) 评论(0) 推荐(0) 编辑
摘要: Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. For example,Given 1->2 阅读全文
posted @ 2016-04-18 10:33 Black_Knight 阅读(176) 评论(0) 推荐(0) 编辑
摘要: Given a list, rotate the list to the right by k places, where k is non-negative. For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2->3- 阅读全文
posted @ 2016-04-15 11:19 Black_Knight 阅读(191) 评论(0) 推荐(0) 编辑
摘要: Given a linked list, remove the nth node from the end of list and return its head. For example, Note:Given n will always be valid.Try to do this in on 阅读全文
posted @ 2016-04-13 11:30 Black_Knight 阅读(233) 评论(0) 推荐(0) 编辑
摘要: Write a program to find the node at which the intersection of two singly linked lists begins. For example, the following two linked lists: begin to in 阅读全文
posted @ 2016-04-13 10:37 Black_Knight 阅读(264) 评论(0) 推荐(0) 编辑
摘要: Write an algorithm to determine if a number is "happy". A happy number is a number defined by the following process: Starting with any positive intege 阅读全文
posted @ 2016-04-12 15:34 Black_Knight 阅读(219) 评论(0) 推荐(0) 编辑
摘要: Given an array of integers, find out whether there are two distinct indices i and j in the array such that the difference between nums[i] and nums[j]  阅读全文
posted @ 2016-04-11 15:48 Black_Knight 阅读(197) 评论(0) 推荐(0) 编辑