LeetCode
文章平均质量分 52
xuegsh_
这个作者很懒,什么都没留下…
展开
-
Minimum Path Sum
原题链接:https://leetcode.com/problems/minimum-path-sum/description/题目描述: Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbe原创 2017-10-29 20:14:11 · 356 阅读 · 0 评论 -
Queue Reconstruction by Height
原题链接: https://leetcode.com/problems/queue-reconstruction-by-height/description/题目: Suppose you have a random list of people standing in a queue. Each person is described by a pair of integers (h, k), w原创 2018-01-21 23:51:21 · 185 阅读 · 0 评论 -
01 Matrix
原题链接: https://leetcode.com/problems/01-matrix/description/题目描述: Given a matrix consists of 0 and 1, find the distance of the nearest 0 for each cell. The distance between two adjacent cells is 1.S原创 2017-11-12 20:34:47 · 239 阅读 · 0 评论 -
Gas Station
原题链接: https://leetcode.com/problems/gas-station/description/题目: 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原创 2017-12-17 22:58:08 · 225 阅读 · 0 评论 -
Combination Sum IV
原题链接: https://leetcode.com/problems/combination-sum-iv/description/原题: Given an integer array with all positive numbers and no duplicates, find the number of possible combinations that add up to a posi原创 2017-12-24 23:32:50 · 262 阅读 · 0 评论 -
Dungeon Game
题目连接: https://leetcode.com/problems/dungeon-game/description/题目分析: 使用一个数组health[][]记录Knight在每一个方格所需要 的最小health值,使用动态规划,通过动态转换方程:health[i][j] = min(health[i][j + 1], health[i + 1][j]) - dungeon[i][j] <原创 2017-11-26 16:18:48 · 246 阅读 · 0 评论 -
Coin Change
原题链接: https://leetcode.com/problems/coin-change/description/题目: You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins原创 2017-12-03 21:46:08 · 231 阅读 · 0 评论 -
Triangle
原题链接:https://leetcode.com/problems/triangle/description/Description: Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.Solution原创 2017-12-10 22:13:44 · 259 阅读 · 0 评论 -
Search a 2D Matrix II
原题链接: https://leetcode.com/problems/search-a-2d-matrix-ii/description/原题描述: Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: (1)Int原创 2017-11-19 23:17:46 · 245 阅读 · 0 评论 -
Unique Paths II
原题链接: https://leetcode.com/problems/unique-paths-ii/description/题目描述: 题目在Unique Path这道题目的基础上增加了一个条件,给定一个m*n的障碍矩阵obstacleGrid,当obstacleGrid[i][j]的值为0时,代表方格(i,j)上没有障碍物;为1时代表方格(i, j)上有障碍物,必须绕开这个障碍物。找出从方原创 2017-11-03 17:16:00 · 340 阅读 · 0 评论 -
Two Sum
原题链接:https://leetcode.com/problems/two-sum/description/题目很简单,最开始用的是两层循环的暴力求解,对数组中的每一个数都遍历一次数组即可,如下:Your runtime beats 17.84 % of cpp submissions.Runtime: 209 msclass Solution {public: vec原创 2017-09-17 23:12:05 · 240 阅读 · 0 评论 -
Maximum Subarray
Maximum Subarray原题链接:https://leetcode.com/problems/maximum-subarray/description/题目很简单,给定一个数组,找出一个子数组使得它的和最大,也就是找出该数组的最大连续和。Solution1: 采取分治法来解决这个问题,首先,将原数组划分为两个元素个数相等的子数组,然后递归求解。注意,递归求解只能找出完全位于数组左半部或者右半原创 2017-09-24 18:14:08 · 214 阅读 · 0 评论 -
Merge k Sorted Lists
Merge k Sorted Lists原题链接:https://leetcode.com/problems/merge-k-sorted-lists/description/题目要求将k个已排好序(升序)的链表,合并成一个有序的链表。Solution1: 第一种方法就是,用分治法,先将这k个list两两合并,得到k/2个长度为2n的新链表;然后继续将这k/2个链表两两合并,直到最后合并成一个链表。原创 2017-09-29 19:44:45 · 178 阅读 · 0 评论 -
Jump Game II
原题链接:https://leetcode.com/problems/jump-game-ii题目描述: Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your max原创 2017-10-15 11:49:45 · 198 阅读 · 0 评论 -
Remove K Digits
原题链接:https://leetcode.com/problems/remove-k-digits/description/题目描述: Given a non-negative integer num represented as a string, remove k digits from the number so that the new number is the smallest po原创 2017-10-22 16:40:23 · 291 阅读 · 0 评论 -
Non-overlapping Intervals
原题链接: https://leetcode.com/problems/non-overlapping-intervals/description/题目: Given a collection of intervals, find the minimum number of intervals you need to remove to make the rest of the intervals原创 2018-01-07 19:58:20 · 418 阅读 · 0 评论