随笔分类 -  LeetCode

上一页 1 2 3 4 5 6 7 下一页

摘要:Sort ListSort a linked list in O(n log n) time using constant space complexity.使用Merge Sort, 空间复杂度是 O(logN) 因为使用了栈空间。SOLUTION 1:使用Merge Sort来解决问题。为什么不... 阅读全文

posted @ 2014-11-29 20:55 Yu's Garden 阅读(3543) 评论(4) 推荐(0)

摘要:Swap Nodes in Pairs Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as... 阅读全文

posted @ 2014-11-29 20:23 Yu's Garden 阅读(393) 评论(0) 推荐(0)

摘要:November 28, 2014 Leetcode全垒打!以此纪念。找工作的路还是很漫长。继续奋斗。有学长学姐们的督促,必须更加努力。http://mcds.cs.cmu.edu/?q=node/262013Chun Chen (Twitter, San Francisco, CA)Yiwen C... 阅读全文

posted @ 2014-11-28 16:27 Yu's Garden 阅读(2421) 评论(3) 推荐(0)

摘要:Intersection of Two Linked ListsWrite a program to find the node at which the intersection of two singly linked lists begins.For example, the followin... 阅读全文

posted @ 2014-11-28 16:20 Yu's Garden 阅读(12933) 评论(1) 推荐(2)

摘要:Text JustificationGiven an array of words and a length L, format the text such that each line has exactly L characters and is fully (left and right) j... 阅读全文

posted @ 2014-11-27 21:58 Yu's Garden 阅读(732) 评论(0) 推荐(0)

摘要:Evaluate Reverse Polish NotationEvaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand... 阅读全文

posted @ 2014-11-26 20:38 Yu's Garden 阅读(437) 评论(0) 推荐(0)

摘要:Max Points on a LineGiven n points on a 2D plane, find the maximum number of points that lie on the same straight line.SOLUTION 1:全部的点扫一次,然后计算每一个点与其它点... 阅读全文

posted @ 2014-11-26 19:45 Yu's Garden 阅读(683) 评论(0) 推荐(0)

摘要:Gray CodeThe gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the t... 阅读全文

posted @ 2014-11-25 19:53 Yu's Garden 阅读(2214) 评论(1) 推荐(0)

摘要:Word Ladder II Given two words (start and end), and a dictionary, find all shortest transformation sequence(s) from start to end, such that:Only one l... 阅读全文

posted @ 2014-11-24 19:55 Yu's Garden 阅读(1679) 评论(0) 推荐(0)

摘要:Count and SayThe count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1 is read off as "one 1" or 11.11... 阅读全文

posted @ 2014-11-24 10:41 Yu's Garden 阅读(731) 评论(0) 推荐(0)

摘要:Roman to IntegerGiven a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.SOLUTION 1:思路:从后往前遍历罗马数字,如果某... 阅读全文

posted @ 2014-11-23 20:05 Yu's Garden 阅读(627) 评论(0) 推荐(0)

摘要:Roman to IntegerGiven a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.SOLUTION 1:思路:从后往前遍历罗马数字,如果某... 阅读全文

posted @ 2014-11-23 18:43 Yu's Garden 阅读(428) 评论(0) 推荐(0)

摘要:Integer to Roman Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.SOLUTION 1:从大到小的贪心写法。从大到小匹配... 阅读全文

posted @ 2014-11-23 17:06 Yu's Garden 阅读(555) 评论(0) 推荐(0)

摘要:ZigZag ConversionThe string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern... 阅读全文

posted @ 2014-11-23 16:04 Yu's Garden 阅读(816) 评论(0) 推荐(0)

摘要:Multiply StringsGiven two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large ... 阅读全文

posted @ 2014-11-23 10:33 Yu's Garden 阅读(631) 评论(0) 推荐(0)

摘要:Wildcard MatchingImplement wildcard pattern matching with support for '?' and '*'.'?' Matches any single character.'*' Matches any sequence of charact... 阅读全文

posted @ 2014-11-23 09:22 Yu's Garden 阅读(7764) 评论(0) 推荐(2)

摘要:Decode WaysA message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded ... 阅读全文

posted @ 2014-11-22 18:34 Yu's Garden 阅读(921) 评论(0) 推荐(0)

摘要:Substring with Concatenation of All WordsYou are given a string, S, and a list of words, L, that are all of the same length. Find all starting indices... 阅读全文

posted @ 2014-11-22 07:32 Yu's Garden 阅读(738) 评论(0) 推荐(0)

摘要:Longest Valid ParenthesesGiven a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses sub... 阅读全文

posted @ 2014-11-21 20:03 Yu's Garden 阅读(1420) 评论(0) 推荐(0)

摘要:Generate ParenthesesGiven n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a... 阅读全文

posted @ 2014-11-21 18:34 Yu's Garden 阅读(893) 评论(0) 推荐(1)

上一页 1 2 3 4 5 6 7 下一页

导航