摘要: 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 阅读(134) 评论(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 阅读(144) 评论(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 阅读(126) 评论(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:A: a... 阅读全文
posted @ 2015-10-23 14:37 fenshen371 阅读(149) 评论(0) 推荐(0) 编辑
摘要: Given a stringsand a dictionary of wordsdict, determine ifscan be segmented into a space-separated sequence of one or more dictionary words.For exampl... 阅读全文
posted @ 2015-10-23 13:05 fenshen371 阅读(205) 评论(0) 推荐(0) 编辑
摘要: Givenn, how many structurally uniqueBST's(binary search trees) that store values 1...n?For example,Givenn= 3, there are a total of 5 unique BST's. 1... 阅读全文
posted @ 2015-10-23 11:20 fenshen371 阅读(191) 评论(0) 推荐(1) 编辑
摘要: Given a 2D binary matrix filled with 0's and 1's, find the largest square containing all 1's and return its area.For example, given the following matr... 阅读全文
posted @ 2015-10-23 02:22 fenshen371 阅读(154) 评论(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 integer... 阅读全文
posted @ 2015-10-22 01:32 fenshen371 阅读(199) 评论(0) 推荐(0) 编辑
摘要: 两个人轮流捡石子,只有一堆石子,石子数为n。每个人每次至少捡一个石子,至多捡m个。取走最后一个石子的人胜利,若我方先手,求能否胜利。若n % (m + 1)为0,则必输,否则必赢。 阅读全文
posted @ 2015-10-21 07:34 fenshen371 阅读(192) 评论(0) 推荐(0) 编辑