随笔分类 -  LeetCode

摘要:Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. For example, given the fo 阅读全文
posted @ 2015-02-11 15:14 Grandyang 阅读(16232) 评论(6) 推荐(1)
摘要:The DNA sequence is composed of a series of nucleotides abbreviated as 'A', 'C', 'G', and 'T'. For example, "ACGAATTCCG" is a DNA sequence. When study 阅读全文
posted @ 2015-02-10 16:11 Grandyang 阅读(18058) 评论(17) 推荐(1)
摘要:Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may comple 阅读全文
posted @ 2015-02-09 17:09 Grandyang 阅读(40391) 评论(18) 推荐(1)
摘要:Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may comple 阅读全文
posted @ 2015-02-09 08:39 Grandyang 阅读(28450) 评论(3) 推荐(1)
摘要:Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction 阅读全文
posted @ 2015-02-08 16:12 Grandyang 阅读(23192) 评论(1) 推荐(1)
摘要:Given a non-empty binary tree, find the maximum path sum. For this problem, a path is defined as any sequence of nodes from some starting node to any 阅读全文
posted @ 2015-02-08 15:55 Grandyang 阅读(25658) 评论(11) 推荐(3)
摘要:Given an unsorted array of integers, find the length of the longest consecutive elements sequence. Your algorithm should run in O(n) complexity. Examp 阅读全文
posted @ 2015-02-06 01:01 Grandyang 阅读(25665) 评论(13) 推荐(2)
摘要:Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. An example is the root-to-leaf path 1->2->3 whic 阅读全文
posted @ 2015-02-05 00:14 Grandyang 阅读(9945) 评论(4) 推荐(0)
摘要:Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning 阅读全文
posted @ 2015-02-04 05:04 Grandyang 阅读(18075) 评论(10) 推荐(1)
摘要:Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. A palindro 阅读全文
posted @ 2015-02-03 14:54 Grandyang 阅读(22558) 评论(3) 推荐(1)
摘要:Given a reference of a node in a connected undirected graph, return a deep copy (clone) of the graph. Each node in the graph contains a val (int) and 阅读全文
posted @ 2015-02-02 13:56 Grandyang 阅读(22098) 评论(15) 推荐(1)
摘要:There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. You have a car with an unlimited gas tank and it cost 阅读全文
posted @ 2015-02-02 09:19 Grandyang 阅读(21442) 评论(6) 推荐(2)
摘要:Given a non-empty array of integers, every element appears three times except for one, which appears exactly once. Find that single one. Note: Your al 阅读全文
posted @ 2015-01-31 13:05 Grandyang 阅读(33958) 评论(6) 推荐(0)
摘要:A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null. Return a deep copy 阅读全文
posted @ 2015-01-30 05:34 Grandyang 阅读(24483) 评论(16) 推荐(4)
摘要:Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequ 阅读全文
posted @ 2015-01-29 04:59 Grandyang 阅读(36752) 评论(12) 推荐(5)
摘要:Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You may not modify the values in the list's nodes, only nodes its 阅读全文
posted @ 2015-01-28 07:16 Grandyang 阅读(15426) 评论(3) 推荐(1)
摘要:Given a binary tree, return the postorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, return [3,2,1]. Note: Recursive so 阅读全文
posted @ 2015-01-27 00:32 Grandyang 阅读(16350) 评论(6) 推荐(1)
摘要:Sort a linked list using insertion sort. A graphical example of insertion sort. The partial sorted list (black) initially contains only the first elem 阅读全文
posted @ 2015-01-26 13:38 Grandyang 阅读(13708) 评论(8) 推荐(0)
摘要:Sort a linked list in O(n log n) time using constant space complexity. Example 1: Example 2: 常见排序方法有很多,插入排序,选择排序,堆排序,快速排序,冒泡排序,归并排序,桶排序等等。。它们的时间复杂度不尽相 阅读全文
posted @ 2015-01-26 11:53 Grandyang 阅读(28016) 评论(15) 推荐(2)
摘要:Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, /. Each operand may be an integer or another e 阅读全文
posted @ 2015-01-25 06:48 Grandyang 阅读(10472) 评论(3) 推荐(0)

Fork me on GitHub