随笔分类 -  算法设计与分析

摘要:#week19 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 yo 阅读全文
posted @ 2018-01-13 04:41 小预备 阅读(163) 评论(0) 推荐(0)
摘要:#week18 Given a binary tree, return all root-to-leaf paths. For example, given the following binary tree: All root-to-leaf paths are: 分析: 这是一题比较简单的递归 阅读全文
posted @ 2018-01-13 04:37 小预备 阅读(177) 评论(0) 推荐(0)
摘要:#week17 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 yo 阅读全文
posted @ 2018-01-13 04:31 小预备 阅读(178) 评论(0) 推荐(0)
摘要:#week16 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 阅读全文
posted @ 2018-01-13 04:21 小预备 阅读(136) 评论(0) 推荐(0)
摘要:#week15 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 ma 阅读全文
posted @ 2018-01-13 04:13 小预备 阅读(214) 评论(0) 推荐(0)
摘要:#week14 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 阅读全文
posted @ 2018-01-13 04:05 小预备 阅读(308) 评论(0) 推荐(0)
摘要:#week13 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 it 阅读全文
posted @ 2018-01-13 03:59 小预备 阅读(168) 评论(0) 推荐(0)
摘要:#week12 Given an unsorted array of integers, find the length of longest increasing subsequence. For example,Given [10, 9, 2, 5, 3, 7, 101, 18],The lon 阅读全文
posted @ 2018-01-13 03:52 小预备 阅读(184) 评论(0) 推荐(0)
摘要:#week11 Given an unsorted array of integers, find the number of longest increasing subsequence. Example 1: Input: [1,3,5,4,7] Output: 2 Explanation: T 阅读全文
posted @ 2018-01-13 03:41 小预备 阅读(182) 评论(0) 推荐(0)
摘要:#week10 On an NxN chessboard, a knight starts at the r-th row and c-th column and attempts to make exactly K moves. The rows and columns are 0 indexed 阅读全文
posted @ 2018-01-13 03:23 小预备 阅读(185) 评论(0) 推荐(0)
摘要:#week9 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, 阅读全文
posted @ 2018-01-13 03:11 小预备 阅读(196) 评论(0) 推荐(0)
摘要:#week8 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 tran 阅读全文
posted @ 2018-01-13 02:59 小预备 阅读(170) 评论(0) 推荐(0)
摘要:#week7 You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stop 阅读全文
posted @ 2018-01-13 02:40 小预备 阅读(226) 评论(0) 推荐(0)
摘要:#week6 Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive. Example: Note: 分析: 动态规划类型 代码: 超时版本: 修改为一维 阅读全文
posted @ 2018-01-13 02:23 小预备 阅读(151) 评论(0) 推荐(0)
摘要:#week5 问题: 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 t 阅读全文
posted @ 2018-01-13 02:01 小预备 阅读(224) 评论(0) 推荐(0)
摘要:#week4# #from leetcode# Description You are given a data structure of employee information, which includes the employee's unique id, his importance va 阅读全文
posted @ 2017-09-29 21:07 小预备 阅读(480) 评论(0) 推荐(0)
摘要:#week3# #from leetcode# Description Equations are given in the format A / B = k, where A and B are variables represented as strings, and k is a real n 阅读全文
posted @ 2017-09-24 21:23 小预备 阅读(259) 评论(0) 推荐(0)
摘要:#week2# #from leetcode# Description Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For examp 阅读全文
posted @ 2017-09-17 23:29 小预备 阅读(314) 评论(0) 推荐(0)
摘要:#Week_1# #From LeetCode# Description: Given an array of size n, find the majority element. The majority element is the element that appears more than  阅读全文
posted @ 2017-09-08 20:48 小预备 阅读(255) 评论(0) 推荐(0)