leetcode_算法
文章平均质量分 68
木木______
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
上周挖的坑来填了
上周说要好好整理这道题的,因为确实花了很多时间去完成它。但是今天准备回顾的时候发现草稿纸一扔有很多细节记不起来了,看来还是要打铁趁热,现在我尽量写清楚自己的解题经过。53. Maximum Subarray - EasyDescriptionFind the contiguous subarray within an array (containing at least one number) wh原创 2017-09-25 00:54:40 · 343 阅读 · 0 评论 -
446. Arithmetic Slices II - Subsequence - Hard
Description(原题描述太罗嗦了,我转换一下语言) 算出一个数组中的等差序列个数,其中找到的序列为原数组子序列。 Example: Input: [-1, 1, 2, 3, 4, 7] Output: 6 Explanation: All arithmetic subsequence slices are[-1,1,3]、[-1,3,7]、[1,2,3]、[2,3,4]、[1,2原创 2017-12-28 10:25:32 · 251 阅读 · 0 评论 -
413. Arithmetic Slices - Medium
Description(原题描述太罗嗦了,我转换一下语言) 算出一个数组中的等差序列个数,其中找到的序列为连续子串。 Example: input: A = [1, 2, 3, 4] return: 3, for 3 arithmetic slices in A: [1, 2, 3], [2, 3, 4] and [1, 2, 3, 4] itself.Analyze目标等差序列都成片(sl原创 2017-12-28 00:03:39 · 277 阅读 · 0 评论 -
72. Edit Distance - hard
最短编辑距离,这么经典的DP问题我就不描述了。 解法就是在三种操作对应的代价中取最小作为下一状态值,值得一提的是评论区O(n)的优化。Code-ordinaryint minDistance(string word1, string word2) { //1 as row, 2 as column int row = word1.size(), column = word2.size();原创 2018-01-03 00:40:20 · 302 阅读 · 0 评论 -
210. Course Schedule II - Medium
Description 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 expr原创 2018-01-11 14:11:47 · 250 阅读 · 0 评论 -
207. Course Schedule - Medium
Description 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 expr原创 2018-01-11 13:53:32 · 275 阅读 · 0 评论 -
537. Complex Number Multiplication-Medium
大水题!leetcode大概是看答案代码行数判断难易程度的吧。 写一道Medium动态规划写到心态崩了,所以今天先水一道,下周再填那个坑。Description给定两个用string表示的复数输出乘积。 Example: Input: “1+1i”, “1+1i” Output: “0+2i”Code#include <cstdlib> #include <sstream> class So原创 2017-12-06 20:42:50 · 217 阅读 · 0 评论 -
712. Minimum ASCII Delete Sum for Two Strings - Medium
DescriptionGiven two strings s1, s2, find the lowest ASCII sum of deleted characters to make two strings equal.Example 1: Input: s1 = “sea”, s2 = “eat” Output: 231 Explanation: Deleting “s” from “se原创 2017-12-04 17:48:54 · 201 阅读 · 0 评论 -
349. Intersection of Two Arrays - Easy
DescriptionGiven two arrays, write a function to compute their intersection.Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2].Note: Each element in the result must be unique. The resul原创 2017-12-21 10:08:55 · 181 阅读 · 0 评论 -
689. Maximum Sum of 3 Non-Overlapping Subarrays - Hard
DescriptionIn a given array nums of positive integers, find three non-overlapping subarrays with maximum sum. Each subarray will be of size k, and we want to maximize the sum of all 3*k entries. Retu原创 2017-12-19 21:03:44 · 316 阅读 · 0 评论 -
55. Jump Game - Medium
DescriptionGiven 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. Deter原创 2017-10-19 01:20:05 · 261 阅读 · 0 评论 -
455. Assign Cookies - Easy
DescriptionAssume 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 siz原创 2017-10-18 23:11:44 · 261 阅读 · 0 评论 -
690. Employee Importance - Easy
DescriptionYou are given a data structure of employee information, which includes the employee’s unique id, his importance value and his direct subordinates’ id.For example, employee 1 is the leader of原创 2017-10-18 09:22:40 · 258 阅读 · 0 评论 -
542. 01 Matrix -- Medium
DescriptionGiven 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. Example 1: Input:0 0 0 0 1 0 0 0 0Output:0 0 0 0 1 0 0 0原创 2017-10-07 12:09:13 · 270 阅读 · 0 评论 -
leetcode试水
7.Reverse Integer - EasyDescriptionReverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 Note: The input is assumed to be a 32-bit signed integer. Your functio原创 2017-09-10 18:20:40 · 224 阅读 · 0 评论 -
应付检查的一道水题
这周写了两道,另一道题目是挑的分治的更好的题目。但由于我现在脑子里一团浆糊,打算先完成作业把博客写了,这道题没啥好说的,读者请随便看看。另一道整理好了再发。3. Longest Substring Without Repeating Characters - MediumDescriptionGiven a string, find the length of the longest substri原创 2017-09-18 00:48:20 · 428 阅读 · 0 评论 -
630. Course Schedule III - Hard
Description There are n different online courses numbered from 1 to n. Each course has some duration(course length) t and closed on dth day. A course should be taken continuously for t days and must原创 2018-01-12 16:21:42 · 253 阅读 · 0 评论
分享