算法设计
锦心
这个作者很懒,什么都没留下…
展开
-
算法设计Week1 LeetCode Algorithms Problem #1 Two Sum
题目描述: Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not use原创 2017-02-22 20:15:50 · 402 阅读 · 0 评论 -
算法设计Week8 LeetCode Algorithms Problem #70 Climbing Stairs
题目描述: 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 top? Note: Given n wil原创 2017-04-16 22:00:46 · 221 阅读 · 0 评论 -
算法设计Week11 LeetCode Algorithms Problem #303 Range Sum Query - Immutable
题目描述: Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive. Example: Given nums = [-2, 0, 3, -5, 2, -1] sumRange(0, 2) -> 1 sumRange(2, 5)原创 2017-05-07 19:08:31 · 207 阅读 · 0 评论 -
算法设计Week11 LeetCode Algorithms Problem #304 Range Sum Query 2D - Immutable
题目描述: Given a 2D matrix matrix, find the sum of the elements inside the rectangle defined by its upper left corner (row1, col1) and lower right corner (row2, col2). The above rectangle (with t原创 2017-05-07 20:03:50 · 310 阅读 · 0 评论 -
算法设计Week14 LeetCode Algorithms Problem #91 Decode Ways
题目描述: A message containing letters from A-Z is being encoded to numbers using the following mapping: ‘A’ -> 1 ‘B’ -> 2 … ‘Z’ -> 26 Given an encoded message containing digits, determi原创 2017-05-28 11:34:23 · 207 阅读 · 0 评论 -
算法设计Week13 LeetCode Algorithms Problem #64 Minimum Path Sum
题目描述: 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 numbers along its path. Note: You can only move either down or原创 2017-05-18 17:19:51 · 186 阅读 · 0 评论 -
算法设计Week12 LeetCode Algorithms Problem #62 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原创 2017-05-10 16:48:02 · 378 阅读 · 0 评论 -
算法设计Week15 LeetCode Algorithms Problem #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 following triangle [ [2],原创 2017-06-04 17:48:41 · 243 阅读 · 0 评论 -
算法设计Week17 LeetCode Algorithms Problem #264 Ugly Number II
题目描述: Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 is the sequence of the原创 2017-06-22 14:47:03 · 444 阅读 · 0 评论 -
算法设计Week18 LeetCode Algorithms Problem #344 Integer Break
题目描述: Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get. For example, given n原创 2017-06-22 22:14:21 · 270 阅读 · 0 评论 -
算法设计Week16 LeetCode Algorithms Problem #322 Coin Change
题目描述: You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of原创 2017-06-11 16:32:29 · 317 阅读 · 0 评论 -
算法设计Week8 LeetCode Algorithms Problem #198 House Robber
题目描述: You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacen原创 2017-04-16 22:49:06 · 219 阅读 · 0 评论 -
算法设计Week12 LeetCode Algorithms Problem #63 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 respectivel原创 2017-05-10 18:14:49 · 216 阅读 · 0 评论 -
算法设计Week2 LeetCode Algorithms Problem #215 Kth Largest Element in an Array
题目描述: Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element. For example, Given [3,2,1,5,6,4] and k = 2, re原创 2017-03-03 19:42:29 · 265 阅读 · 0 评论 -
算法设计Week1 LeetCode Algorithms Problem #2 Add Two Numbers
题目描述 You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and原创 2017-02-24 16:15:58 · 298 阅读 · 0 评论 -
算法设计Week2 LeetCode #169 Majority Element
题目描述: Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the array is non-empty and the majority原创 2017-03-02 17:26:41 · 226 阅读 · 0 评论 -
算法设计Week4 LeetCode Algorithms Problem #207 Course Schedule
题目要求 There are a total of n courses you have to take, labeled from 0 to n - 1. Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is express原创 2017-03-20 01:04:24 · 355 阅读 · 0 评论 -
算法设计Week3 LeetCode Algorithms Problem #133 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 are labeled uniquely. We use # as a separator for e原创 2017-03-11 20:57:54 · 292 阅读 · 0 评论 -
算法设计Week7 LeetCode Algorithms Problem #53 Maximum Subarray
题目描述: Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [-2,1,-3,4,-1,2,1,-5,4], the contiguous subarray [4,-1,2原创 2017-04-09 23:42:08 · 208 阅读 · 0 评论 -
算法设计Week5 LeetCode Algorithms Problem #122 Best Time to Buy and Sell Stock II
题目描述: 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 complete as many transactions as you like (i原创 2017-03-26 21:55:46 · 288 阅读 · 0 评论 -
算法设计Week6 LeetCode Algorithms Problem #455 Assign Cookies
题目描述: Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a greed factor gi, which is the minimum size o原创 2017-04-03 00:25:38 · 291 阅读 · 0 评论 -
算法设计Week9 LeetCode Algorithms Problem #121. Best Time to Buy and Sell Stock
题目描述: Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction (ie, buy one and sell one share of th原创 2017-04-30 21:27:19 · 202 阅读 · 0 评论 -
算法设计Week10 LeetCode Algorithms Problem #213 House Robber II
题目描述: After robbing those houses on that street, the thief has found himself a new place for his thievery so that he will not get too much attention. This time, all houses at this place are arranged原创 2017-04-30 22:42:15 · 214 阅读 · 0 评论 -
算法设计 《算法概论》第八章 8.10 习题解答
题目描述: Proving NP-completeness by generalization. For each of the problems below, prove that it is NPcomplete by showing that it is a generalization of some NP-complete problem we have seen in this ch原创 2017-06-23 12:44:21 · 616 阅读 · 0 评论