算法分析与设计
SGAFPZ
这个作者很懒,什么都没留下…
展开
-
Jump Game II - LeetCode
Jump Game II - LeetCode大概翻译一下题目的意思,有一个非负整数数组,数组某个index上的数值代表在这个index上能跳的最大步数,要从这个数组的第一个位置跳到最后一个位置,求跳动的最少次数。 例:A = [2,3,1,1,4] 从A[0]开始跳,A[0]=2,所以在这个位置最多能跳2步。 如果跳两步那么就到了A[2],而A[2]=1所以在这个位置只能跳1步 显然这个样原创 2017-09-07 19:51:21 · 403 阅读 · 0 评论 -
Remove Invalid Parentheses - LeetCode
Remove Invalid Parentheses - LeetCode 题目: Remove the minimum number of invalid parentheses in order to make the input string valid. Return all possible results. Note: The input string may con原创 2017-12-24 16:25:57 · 319 阅读 · 0 评论 -
Interleaving String - LeetCode
Interleaving String - LeetCode 题目: Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. For example, Given: s1 = “aabcc”, s2 = “dbbca”, When s3 = “aadbbcb原创 2017-12-07 14:21:43 · 319 阅读 · 0 评论 -
Longest Increasing Path in a Matrix - LeetCode
Longest Increasing Path in a Matrix - LeetCode 题目: Given an integer matrix, find the length of the longest increasing path. From each cell, you can either move to four directions: left, right,原创 2017-12-17 20:18:35 · 374 阅读 · 1 评论 -
算法第八章NP完全问题作业
8.14 prove that the following problem is NP-complete: given an undirected graph G = (V,E) and an integer k, return a clique of size k as well as an independent set of size k, provided both exist.题目中原创 2017-12-30 10:01:49 · 584 阅读 · 0 评论 -
Russian Doll Envelopes - LeetCode
Russian Doll Envelopes - LeetCode 题目: You have a number of envelopes with widths and heights given as a pair of integers (w, h). One envelope can fit into another if and only if both the width and原创 2018-01-09 02:00:47 · 372 阅读 · 0 评论 -
Climbing Stairs - LeetCode
Climbing Stairs - LeetCode 题目: You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the t原创 2018-01-20 20:28:03 · 284 阅读 · 0 评论 -
Network Delay Time - LeetCode
Network Delay Time - LeetCode 题目: There are N network nodes, labelled 1 to N. Given times, a list of travel times as directed edges times[i] = (u, v, w), where u is the source node, v is the ta原创 2018-01-20 20:50:35 · 381 阅读 · 0 评论 -
Word Break II - LeetCode
Word Break II - LeetCode题目:Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, add spaces in s to construct a sentence where each word is a valid dictionary w...原创 2019-01-18 17:05:30 · 476 阅读 · 0 评论 -
Dungeon Game - LeetCode
Dungeon Game - LeetCode 题目: 这又是一道动态规划的题目。 一开始的想法是用一个二维数组记录在(i,j)位置所能剩下的最大生命值,但是这是不对的。 后来想到了另一种方法,从右下角开始推,在(i,j)位置记录所需要的最小生命值。然后往起点推。 在走到最后一格后,只需要剩下一滴血就可以,虽然事实上可能剩下很多血,但是剩一滴血是满足条件的最小血量,这是个必原创 2017-11-27 20:19:19 · 332 阅读 · 0 评论 -
Search Insert Position - LeetCode
题目: Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.时间比较紧,,选了一道特别简单的题目, 找到第一个大于等于target的数,原创 2017-11-26 23:40:20 · 262 阅读 · 0 评论 -
K Inverse Pairs Array - LeetCode
K Inverse Pairs Array - LeetCode 题目: Given two integers n and k, find how many different arrays consist of numbers from 1 to n such that there are exactly k inverse pairs. We define an invers原创 2017-11-19 13:24:13 · 386 阅读 · 0 评论 -
Candy - LeetCode
Candy - LeetCode 题目: 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 requirements: 1.Each原创 2017-09-26 15:07:47 · 328 阅读 · 0 评论 -
Max Points on a Line - LeetCode
Max Points on a Line - LeetCode 题目:Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.这道题一看就能知道大概要怎么做,先选中vector第一个点A,然后遍历剩下的点Xi,求出剩下每个点Xi与A之间的坐标差,这个坐标原创 2017-09-21 15:56:06 · 480 阅读 · 0 评论 -
Find Median from Data Stream - LeetCode
Find Median from Data Stream - LeetCode 题目: Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two m原创 2017-10-08 22:33:42 · 351 阅读 · 0 评论 -
Regular Expression Matching - LeetCode
Regular Expression Matching - LeetCode 题目: Implement regular expression matching with support for ‘.’ and ‘*’. ‘.’ Matches any single character. ‘*’ Matches zero or more of the preceding ele原创 2017-10-20 00:54:06 · 331 阅读 · 0 评论 -
Frog Jump - LeetCode
Frog Jump - LeetCode 题目: A frog is crossing a river. The river is divided into x units and at each unit there may or may not exist a stone. The frog can jump on a stone, but it must not jump into原创 2017-10-13 15:01:41 · 782 阅读 · 0 评论 -
Best Time to Buy and Sell Stock IV - LeetCode
Best Time to Buy and Sell Stock IV - LeetCode 题目: 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原创 2017-11-09 21:04:11 · 342 阅读 · 0 评论 -
Decode Ways II - LeetCode
Decode Ways II - LeetCode 题目: A message containing letters from A-Z is being encoded to numbers using the following mapping way: 'A' -> 1 'B' -> 2 ... 'Z' -> 26 Beyond that, now t原创 2017-11-02 14:27:03 · 303 阅读 · 0 评论 -
Reverse Nodes in k-Group - LeetCode
Reverse Nodes in k-Group - LeetCode 题目: Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. k is a positive integer and is less than or equal to原创 2017-10-26 13:59:42 · 274 阅读 · 0 评论 -
Reach a Number - LeetCode
Reach a Number - LeetCode题目:You are standing at position 0 on an infinite number line. There is a goal at position target.On each move, you can either go left or right. During the n-th move (start...原创 2019-07-29 15:41:36 · 384 阅读 · 0 评论