算法分析与设计习题
kanbei_kotori
这个作者很懒,什么都没留下…
展开
-
LeetCode34. Search for a Range
题目Given an array of integers sorted in ascending order, find the starting and ending position of a given target value.Your algorithm’s runtime complexity must be in the order of O(log n).If the target原创 2017-09-15 16:30:59 · 281 阅读 · 0 评论 -
Leetcode746. Min Cost Climbing Stairs
题目:On a staircase, the i-th step has some non-negative cost cost[i] assigned (0 indexed).Once you pay the cost, you can either climb one or two steps. You need to find minimum cost to reac原创 2018-01-09 13:24:49 · 189 阅读 · 0 评论 -
LeetCode739. Daily Temperatures
题目:Given a list of daily temperatures, produce a list that, for each day in the input, tells you how many days you would have to wait until a warmer temperature. If there is no future day for原创 2018-01-09 18:30:19 · 312 阅读 · 0 评论 -
LeetCode718. Maximum Length of Repeated Subarray
题目:Given two integer arrays A and B, return the maximum length of an subarray that appears in both arrays.Example 1:Input:A: [1,2,3,2,1]B: [3,2,1,4,7]Output: 3Explanation: The rep原创 2018-01-09 20:02:51 · 184 阅读 · 0 评论 -
LeetCode740. Delete and Earn
题目:Given an array nums of integers, you can perform operations on the array.In each operation, you pick any nums[i] and delete it to earn nums[i] points. After, you must delete every eleme原创 2018-01-09 16:50:42 · 341 阅读 · 0 评论 -
LeetCode62. Unique Paths
题目:A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to r原创 2018-01-10 20:03:15 · 127 阅读 · 0 评论 -
LeetCode63. Unique Paths II
题目:Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space is marked as 1 and 0 respectively原创 2018-01-10 20:38:07 · 184 阅读 · 0 评论 -
LeetCode55. Jump Game
题目: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 maximum jump length at that position.De原创 2018-01-10 21:00:43 · 121 阅读 · 0 评论 -
LeetCode41. First Missing Positive
题目:Given an unsorted integer array, find the first missing positive integer.For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2.Your algorithm should run in O(n) time and uses原创 2018-01-20 01:58:02 · 135 阅读 · 0 评论 -
Leetcode10. Regular Expression Matching
题目:Implement regular expression matching with support for '.' and '*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The matching should cover the entire原创 2018-01-09 01:04:45 · 128 阅读 · 0 评论 -
LeetCode14. Longest Common Prefix
题目:Write a function to find the longest common prefix string amongst an array of strings.题目分析:题目意思是给定一个字符串的数组,要我们求出这些字符串数组的最长公共前缀,这里的前缀必定是从字符串的开头开始的首先最长公共前缀必定是由这些字符串中最短的那个决定的,因此我们可以先找出这些字符串中最短原创 2018-01-07 21:39:05 · 140 阅读 · 0 评论 -
LeetCode695. Max Area of Island
题目:Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the gr原创 2018-01-12 21:18:36 · 213 阅读 · 0 评论 -
LeetCode11. Container With Most Water
题目:Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i,原创 2017-09-07 20:16:08 · 174 阅读 · 0 评论 -
Leetcode32. Longest Valid Parentheses
题目Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the longest valid parentheses substring is原创 2017-09-29 20:03:41 · 166 阅读 · 0 评论 -
LeetCode42. Trapping Rain Water
题目Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.For example, Given [0,1,0,2,1,0,1,3,原创 2017-09-22 16:46:18 · 198 阅读 · 0 评论 -
LeetCode200. Number of Islands
题目:Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You原创 2017-10-27 17:29:44 · 198 阅读 · 0 评论 -
LeetCode22.Generate Parentheses
题目Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:[ "((()))", "(()())", "(())()",原创 2017-10-22 16:47:11 · 188 阅读 · 0 评论 -
LeetCode331. Verify Preorder Serialization of a Binary Tree
题目:One way to serialize a binary tree is to use pre-order traversal. When we encounter a non-null node, we record the node's value. If it is a null node, we record using a sentinel value such as原创 2017-11-05 16:13:08 · 244 阅读 · 0 评论 -
NPC问题8.3
题目:STINGY SAT is the following problem: given a set of clauses (each a disjunction of literals) and an integer k, find a satisfying assignment in which at most k variables are true, if such an a原创 2018-01-02 00:33:04 · 239 阅读 · 0 评论 -
LeetCode49. Group Anagrams
题目:Given an array of strings, group anagrams together.For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"], Return:[ ["ate", "eat","tea"], ["nat","tan"], ["bat"]]原创 2018-01-20 19:54:19 · 130 阅读 · 0 评论