自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

原创 143. Reorder List

Given a singly linked listL:L0→L1→…→Ln-1→Ln, reorder it to:L0→Ln→L1→Ln-1→L2→Ln-2→… You maynotmodify the values in the list's nodes, only nodes ...

2019-07-22 23:15:47

阅读数 8

评论数 0

原创 142. Linked List Cycle II

Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull. To represent a cycle in the given linked list, we use...

2019-07-22 21:36:47

阅读数 13

评论数 0

原创 141. Linked List Cycle

Given a linked list, determine if it has a cycle in it. To represent a cycle in the given linked list, we use an integerposwhich represents the posi...

2019-07-22 20:58:39

阅读数 13

评论数 0

原创 140. Word Break II

Given anon-emptystringsand a dictionarywordDictcontaining a list ofnon-emptywords, add spaces insto construct a sentence where each word is a valid d...

2019-07-22 20:05:00

阅读数 9

评论数 0

原创 139. Word Break

Given anon-emptystringsand a dictionarywordDictcontaining a list ofnon-emptywords, determine ifscan be segmented into a space-separated sequence of o...

2019-07-21 23:00:28

阅读数 11

评论数 0

原创 138. 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 null. Return adeep cop...

2019-07-21 21:24:48

阅读数 16

评论数 0

原创 136. Single Number

Given anon-emptyarray of integers, every element appearstwiceexcept for one. Find that single one. Note: Your algorithm should have a linear runtim...

2019-07-12 21:55:13

阅读数 16

评论数 0

原创 135. Candy

There areNchildren standing in a line. Each child is assigned a rating value. You are giving candies to these children subjected to the following re...

2019-07-12 21:11:11

阅读数 13

评论数 0

原创 134. Gas Station

There areNgas stations along a circular route, where the amount of gas at stationiisgas[i]. You have a car with an unlimited gas tank and it costsco...

2019-07-11 22:21:46

阅读数 9

评论数 0

原创 133. Clone Graph

Givena reference of a node in aconnectedundirected graph, return adeep copy(clone) of the graph. Each node in the graph contains a val (int) and a li...

2019-07-11 21:34:11

阅读数 19

评论数 0

转载 132. Palindrome Partitioning II

Given a strings, partitionssuch that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning ...

2019-07-11 20:34:50

阅读数 12

评论数 0

转载 131. Palindrome Partitioning

Given a strings, partitionssuch that every substring of the partition is a palindrome. Return all possible palindrome partitioning ofs. Example: ...

2019-07-11 16:24:05

阅读数 26

评论数 0

原创 130. Surrounded Regions

Given a 2D board containing'X'and'O'(the letter O), capture all regions surrounded by'X'. A region is captured by flip...

2019-07-05 15:12:50

阅读数 19

评论数 0

原创 129. Sum Root to Leaf Numbers

Given a binary tree containing digits from0-9only, each root-to-leaf path could represent a number. An example is the root-to-leaf path1->2->3...

2019-07-05 14:35:12

阅读数 30

评论数 0

原创 128. Longest Consecutive Sequence

Given an unsorted array of integers, find the length of the longest consecutive elements sequence. Your algorithm should run in O(n) complexity. Ex...

2019-07-05 11:49:55

阅读数 18

评论数 0

转载 127. Word Ladder

Given two words (beginWordandendWord), and a dictionary's word list, find the length of shortest transformation sequence frombeginWordtoendWord,...

2019-07-05 10:14:21

阅读数 18

评论数 0

原创 125. Valid Palindrome

Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. Note:For the purpose of this problem, ...

2019-07-04 16:45:56

阅读数 24

评论数 0

原创 124. Binary Tree Maximum Path Sum

Given anon-emptybinary tree, find the maximum path sum. For this problem, a path is defined as any sequence of nodes from some starting node to any ...

2019-07-04 16:30:17

阅读数 25

评论数 0

原创 123. Best Time to Buy and Sell Stock III

Say you have an array for which theithelement is the price of a given stock on dayi. Design an algorithm to find the maximum profit. You may complet...

2019-07-04 15:35:28

阅读数 28

评论数 0

原创 122. Best Time to Buy and Sell Stock II

Say you have an array for which theithelement is the price of a given stock on dayi. Design an algorithm to find the maximum profit. You may complet...

2019-07-04 14:21:55

阅读数 29

评论数 0

原创 121. Best Time to Buy and Sell Stock

Say you have an array for which theithelement is the price of a given stock on dayi. If you were only permitted to complete at most one transaction ...

2019-07-04 13:54:08

阅读数 24

评论数 0

原创 117. Populating Next Right Pointers in Each Node II

Given a binary tree struct Node { int val; Node *left; Node *right; Node *next; } Populate each next pointer to point to its next right n...

2019-07-04 13:41:44

阅读数 26

评论数 0

原创 120. Triangle

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 ...

2019-06-27 21:26:57

阅读数 8

评论数 0

原创 119. Pascal's Triangle II

Given a non-negativeindexkwherek≤33, return thekthindex row of the Pascal's triangle. Note that the row index starts from0. In Pascal's ...

2019-06-27 20:11:20

阅读数 8

评论数 0

原创 118. Pascal's Triangle

Given a non-negative integernumRows, generate the firstnumRowsof Pascal's triangle. In Pascal's triangle, each number is the sum of the two...

2019-06-27 20:02:27

阅读数 6

评论数 0

原创 116. Populating Next Right Pointers in Each Node

You are given aperfect binary treewhereall leaves are on the same level, and every parent has two children. The binary tree has the following definit...

2019-06-27 19:44:25

阅读数 10

评论数 0

原创 115. Distinct Subsequences

Given a stringSand a stringT, count the number of distinct subsequences ofSwhich equalsT. A subsequence of a string is a new string which is formed ...

2019-06-27 19:08:47

阅读数 16

评论数 0

原创 114. Flatten Binary Tree to Linked List

Given a binary tree, flatten it to a linked list in-place. For example, given the following tree: 1 / \ 2 5 / \ \ 3 4 6 The fl...

2019-06-27 16:02:27

阅读数 7

评论数 0

原创 113. Path Sum II

Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum. Note:A leaf is a node with no children. ...

2019-06-27 15:34:41

阅读数 7

评论数 0

原创 112. Path Sum

Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. ...

2019-06-27 14:53:36

阅读数 6

评论数 0

原创 111. Minimum Depth of Binary Tree

Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest...

2019-06-27 14:39:09

阅读数 4

评论数 0

原创 110. Balanced Binary Tree

Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as: a binary tree in which the...

2019-06-23 00:04:35

阅读数 8

评论数 0

原创 109. Convert Sorted List to Binary Search Tree

Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. For this problem, a height-balanced bi...

2019-06-22 23:28:52

阅读数 7

评论数 0

原创 108. Convert Sorted Array to Binary Search Tree

Given an array where elements are sorted in ascending order, convert it to a height balanced BST. For this problem, a height-balanced binary tree is...

2019-06-22 23:23:08

阅读数 6

评论数 0

原创 107. Binary Tree Level Order Traversal II

Given a binary tree, return thebottom-up level ordertraversal of its nodes' values. (ie, from left to right, level by level from leaf to root). ...

2019-06-22 22:52:19

阅读数 8

评论数 0

原创 106. Construct Binary Tree from Inorder and Postorder Traversal

Given inorder and postorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tree. For exam...

2019-06-22 22:17:59

阅读数 9

评论数 0

原创 1007 Maximum Subsequence Sum(25 分)

Given a sequence of K integers { N​1​​, N​2​​, ..., N​K​​ }. A continuous subsequence is defined to be { N​i​​, N​i+1​​, ..., N​j​​ } where 1≤i≤j≤K. ...

2018-08-28 22:55:19

阅读数 63

评论数 0

原创 问题 C: 畅通工程

题目描述 省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可)。经过调查评估,得到的统计表中列出了有可能建设公路的若干条道路的成本。现请你编写程序,计算出全省畅通需要的最低成本。 输入 测试输入包含若干测试用例。每个测试用例...

2018-08-26 23:37:34

阅读数 142

评论数 0

原创 问题 A: 还是畅通工程

题目描述         某省调查乡村交通状况,得到的统计表中列出了任意两村庄间的距离。省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可),并要求铺设的公路总长度为最小。请计算最小的公路总长度。 输入         测试...

2018-08-26 23:32:18

阅读数 77

评论数 0

原创 问题 E: 最短路径问题

题目描述 给你n个点,m条无向边,每条边都有长度d和花费p,给你起点s终点t,要求输出起点到终点的最短距离及其花费,如果最短距离有多条路线,则输出花费最少的。 输入 输入n,m,点的编号是1~n,然后是m行,每行4个数 a,b,d,p,表示a和b之间有一条边,且其长度为d,花费为p。最后...

2018-08-25 23:47:27

阅读数 70

评论数 0

提示
确定要删除当前文章?
取消 删除