- 博客(213)
- 收藏
- 关注
原创 LeetCode 124. Binary Tree Maximum Path Sum(二叉树最大路径和)
原题网址:https://leetcode.com/problems/binary-tree-maximum-path-sum/Given a binary tree, find the maximum path sum.For this problem, a path is defined as any sequence of nodes from some starting
2016-05-27 00:27:32 2040
原创 LeetCode 125. Valid Palindrome(校验对称)
原题网址:https://leetcode.com/problems/valid-palindrome/Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan,
2016-05-27 00:27:03 445
原创 LeetCode 126. Word Ladder II(单词梯子)
原题网址:https://leetcode.com/problems/word-ladder-ii/Given two words (beginWord and endWord), and a dictionary's word list, find all shortest transformation sequence(s) from beginWord to endWord, s
2016-05-27 00:26:42 866
原创 LeetCode 127. Word Ladder(单词梯子)
原题网址:https://leetcode.com/problems/word-ladder/Given two words (beginWord and endWord), and a dictionary's word list, find the length of shortest transformation sequence from beginWord to endWor
2016-05-27 00:26:28 1092
原创 LeetCode 128. Longest Consecutive Sequence(最长连续序列)
原题网址:https://leetcode.com/problems/longest-consecutive-sequence/Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given [100, 4,
2016-05-27 00:26:15 815
原创 LeetCode 129. Sum Root to Leaf Numbers(节点求和)
原题网址:https://leetcode.com/problems/sum-root-to-leaf-numbers/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-l
2016-05-27 00:26:01 495
原创 LeetCode 130. Surrounded Regions(包围区域)
原题网址:https://leetcode.com/problems/surrounded-regions/Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'.A region is captured by flipping all 'O's into 'X's i
2016-05-27 00:25:49 503
原创 LeetCode 131. Palindrome Partitioning(回文分区)
原题网址:https://leetcode.com/problems/palindrome-partitioning/Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitionin
2016-05-27 00:25:24 638
原创 LeetCode 133. Clone Graph(克隆图)
原题网址:https://leetcode.com/problems/clone-graph/Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.OJ's undirected graph serialization:Nodes ar
2016-05-27 00:22:58 794
原创 LeetCode 132. Palindrome Partitioning II(回文切分)
原题网址:https://leetcode.com/problems/palindrome-partitioning-ii/Given a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a pa
2016-05-27 00:22:56 719
原创 LeetCode 134. Gas Station(加油站)
原题网址:https://leetcode.com/problems/gas-station/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 i
2016-05-27 00:22:49 680
原创 LeetCode 135. Candy(糖果)
原题网址:https://leetcode.com/problems/candy/There are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following re
2016-05-27 00:22:41 450
原创 LeetCode 136. Single Number(单个数字)
原题网址:https://leetcode.com/problems/single-number/Given an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runti
2016-05-27 00:22:39 382
原创 LeetCode 137. Single Number II(单个数字)
原题网址:https://leetcode.com/problems/single-number-ii/Given an array of integers, every element appears three times except for one. Find that single one.Note:Your algorithm should have a lin
2016-05-27 00:22:35 617
原创 LeetCode 138. Copy List with Random Pointer(拷贝随机指针)
原题网址:https://leetcode.com/problems/copy-list-with-random-pointer/A linked list is given such that each node contains an additional random pointer which could point to any node in the list or nul
2016-05-27 00:22:32 491
原创 LeetCode 139. Word Break(单词分隔)
原题网址:https://leetcode.com/problems/word-break/Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.
2016-05-27 00:22:29 794
原创 LeetCode 140. Word Break II(单词切分)
原题网址:https://leetcode.com/problems/word-break-ii/Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word.Return al
2016-05-27 00:22:25 2863
原创 LeetCode 141. Linked List Cycle(链表循环)
原题网址:https://leetcode.com/problems/linked-list-cycle/Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?方法:使用两个指针。/** * Defini
2016-05-27 00:22:22 436
原创 LeetCode 142. Linked List Cycle II(循环链表)
原题网址:https://leetcode.com/problems/linked-list-cycle-ii/Given a linked list, return the node where the cycle begins. If there is no cycle, return null.Note: Do not modify the linked list.
2016-05-26 03:07:42 1067
原创 LeetCode 30. Substring with Concatenation of All Words(所有单词的连接)
原题网址:https://leetcode.com/problems/substring-with-concatenation-of-all-words/You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of
2016-05-26 02:21:59 398
原创 LeetCode 143. Reorder List(重组链表)
原题网址:https://leetcode.com/problems/reorder-list/Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' va
2016-05-26 02:08:26 1483
原创 LeetCode 144. Binary Tree Preorder Traversal(二叉树前缀遍历)
原题网址:https://leetcode.com/problems/binary-tree-preorder-traversal/Given a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1
2016-05-26 01:57:11 540
原创 LeetCode 145. Binary Tree Postorder Traversal(二叉树后序遍历)
原题网址:https://leetcode.com/problems/binary-tree-postorder-traversal/Given a binary tree, return the postorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1
2016-05-26 01:31:28 495
原创 LeetCode 146. LRU Cache(LRU缓存)
原题网址:https://leetcode.com/problems/lru-cache/Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set.get(key) - Get
2016-05-26 01:24:27 813
原创 LeetCode 147. Insertion Sort List(插入有序链表)
原题网址:https://leetcode.com/problems/insertion-sort-list/Sort a linked list using insertion sort.方法:/** * Definition for singly-linked list. * public class ListNode { * int val; * Li
2016-05-26 01:20:22 733
原创 LeetCode 148. Sort List(链表排序)
原题网址:https://leetcode.com/problems/sort-list/Sort a linked list in O(n log n) time using constant space complexity.方法一:分区排序,以第一个元素为参照,分为大中小。/** * Definition for singly-linked list. * publi
2016-05-26 01:18:10 830
原创 LeetCode 149. Max Points on a Line(直线上的点)
原题网址:https://leetcode.com/problems/max-points-on-a-line/Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.方法一:逐点比较斜率。/** * Definition for a
2016-05-26 01:12:31 564
原创 LeetCode 150. Evaluate Reverse Polish Notation(计算后缀表达式)
原题网址:https://leetcode.com/problems/evaluate-reverse-polish-notation/Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand m
2016-05-26 01:10:23 607
原创 LeetCode 151. Reverse Words in a String(反转单词)
原题网址:https://leetcode.com/problems/reverse-words-in-a-string/Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".U
2016-05-26 01:06:09 535
原创 LeetCode 152. Maximum Product Subarray(最大乘积)
原题网址:https://leetcode.com/problems/maximum-product-subarray/Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the
2016-05-26 01:04:48 999
原创 LeetCode 153. Find Minimum in Rotated Sorted Array(旋转数组查找)
原题网址:https://leetcode.com/problems/find-minimum-in-rotated-sorted-array/Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7
2016-05-26 01:02:22 400
原创 LeetCode 154. Find Minimum in Rotated Sorted Array II(旋转数组查找)
原题网址:https://leetcode.com/problems/find-minimum-in-rotated-sorted-array-ii/Follow up for "Find Minimum in Rotated Sorted Array":What if duplicates are allowed?Would this affect the run-time
2016-05-26 00:57:56 452
原创 LeetCode 155. Min Stack(最小栈)
原题网址:https://leetcode.com/problems/min-stack/Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Re
2016-05-26 00:56:06 915
原创 LeetCode 159. Longest Substring with At Most Two Distinct Characters(最长字串)
原题网址:https://leetcode.com/problems/longest-substring-with-at-most-two-distinct-characters/Given a string, find the length of the longest substring T that contains at most 2 distinct characters.
2016-05-26 00:54:39 556
原创 LeetCode 156. Binary Tree Upside Down(树的倒转)
原题网址:https://leetcode.com/problems/binary-tree-upside-down/Given a binary tree where all the right nodes are either leaf nodes with a sibling (a left node that shares the same parent node) or em
2016-05-26 00:48:19 829
原创 LeetCode 157. Read N Characters Given Read4(读文件流)
原题网址:https://leetcode.com/problems/read-n-characters-given-read4/The API: int read4(char *buf) reads 4 characters at a time from a file.The return value is the actual number of characters re
2016-05-26 00:48:11 588
原创 LeetCode 158. Read N Characters Given Read4 II - Call multiple times(读文件流)
原题网址:https://leetcode.com/problems/read-n-characters-given-read4-ii-call-multiple-times/The API: int read4(char *buf) reads 4 characters at a time from a file.The return value is the actual
2016-05-26 00:47:49 1046
原创 LeetCode 91. Decode Ways(解码方法)
原题网址:https://leetcode.com/problems/decode-ways/A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an enco
2016-05-26 00:47:29 711
原创 LeetCode 160. Intersection of Two Linked Lists
原题网址:https://leetcode.com/problems/intersection-of-two-linked-lists/Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following
2016-05-25 01:41:05 440
原创 LeetCode 161. One Edit Distance(编辑距离)
原题网址:https://leetcode.com/problems/one-edit-distance/Given two strings S and T, determine if they are both one edit distance apart.方法:两个字符串长度最多相差1,或者最多只有一个字符不同。public class Solution { publ
2016-05-25 01:40:56 1074
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人