
LeetCode
文章平均质量分 82
xu_xyy
这个作者很懒,什么都没留下…
展开
-
LeetCode---Add Two Numbers
LeetCode---Add Two Numbers Difficulty:MediumC++原创 2017-03-01 21:14:45 · 334 阅读 · 0 评论 -
LeetCode----486. Predict the Winner 动态规划
最近在整理课本第六章动态规划的课后习题,就顺便找leetcode上的题目做啦,顺便复习。。1 题目Given an array of scores that are non-negative integers. Player 1 picks one of the numbers from either end of the array followed by the player原创 2017-05-05 20:51:24 · 1270 阅读 · 0 评论 -
【greedy】LeetCode----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 siz原创 2017-05-29 14:11:45 · 367 阅读 · 0 评论 -
【BFS】Leetcode---111(E)、515(M)、542(M)
复习一下广度优先搜索BFS111. Minimum Depth of Binary Tree515. Find Largest Value in Each Tree Row 542. 01 Matrix原创 2017-05-21 22:37:33 · 260 阅读 · 0 评论 -
LeetCode----537. Complex Number Multiplication
1 题目Given two strings representing two complex numbers.You need to return a string representing their multiplication. Note i2 = -1 according to the definition.Example 1:Input: "1+1i",原创 2017-06-04 13:39:13 · 281 阅读 · 0 评论 -
LeetCode----72. Edit Distance(H) 动态规划
题目 还是动态规划,学到这里算是有了一点感觉,这个题也算是整理一下课堂的学习吧~ 点击打开链接 编辑距离,也就是求两个字符串之间的最短距离,应用实例如搜索引擎(提示你查找的是不是“xxxx”)、医学信息工程的基因问题研究等。分析 字符串:x[1...m] 和y[1...n] E[i原创 2017-04-16 10:48:11 · 402 阅读 · 0 评论 -
LeetCode----521(E)、172(E)、26(E)
521. Longest Uncommon Subsequence I172. Factorial Trailing Zeroes26. Remove Duplicates from Sorted Array原创 2017-06-11 10:52:18 · 254 阅读 · 0 评论 -
LeetCode----241. Different Ways to Add Parenthese(M)分治
1 题目Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. The valid operators are+, - and *.Exam原创 2017-06-25 14:36:03 · 296 阅读 · 0 评论 -
LeetCode----406(M)、392(M)
406. Queue Reconstruction by HeightSuppose you have a random list of people standing in a queue. Each person is described by a pair of integers (h, k), where h is the height of the person and原创 2017-07-04 20:57:30 · 279 阅读 · 0 评论 -
LeetCode----312. Burst Balloons(H) 动态规划
1 题目Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by arraynums. You are asked to burst all the balloons. If the you burst ballooni you will get原创 2017-04-24 00:28:16 · 495 阅读 · 0 评论 -
LeetCode----128. Longest Consecutive Sequence(H)
1 题目Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given [100, 4, 200, 1, 3, 2],The longest consecutive elements sequence is [1,原创 2017-05-14 11:07:53 · 270 阅读 · 0 评论 -
LeetCode----Two Sum
很久没有做过算法题了,脑子也不太好用了,趁着算法课的机会学习一下,这周选了最简单的第一题来做。LeetCode Two Sum,题目如下所示:由于一开始也没有特别多的思路,秉承着先做到再做好的信仰,用了两种方法:(1)一开始使用了最暴力的方法,也就是使用两个循环,显然O(N2)的时间复杂度使得算法超时了。(2)先对数组进行排序,由于排序会使位置发生改变,因此使用结构体记录下数值原创 2017-02-26 22:36:20 · 298 阅读 · 0 评论 -
LeetCode----Minesweeper (M)
1 题目分析 题目链接:点击打开链接 题目就是小时候玩过的扫雷游戏,总结一下规则,在本题中规则也就是思路了: ① 扫到M → 用X替换M,游戏结束(返回board) ② 扫到E → 计算其周围(8个方向)的M的个数Mcount → Mcount > 0,用Mcount替换E原创 2017-03-19 15:02:20 · 360 阅读 · 0 评论 -
LeetCode----Maximum Subarray (E) / Maximum Product Subarray (M)
Maximum Subarray (E) Maximum Product Subarray (M)C++原创 2017-03-10 15:08:34 · 272 阅读 · 0 评论 -
LeetCode----513. Find Bottom Left Tree Value (M)
题目点击打开链接给定一个二叉树,找出最左边的DFS,即返回最大深度BFS,保存每层的第一个值,最后一层的值即为所求原创 2017-03-23 21:38:43 · 221 阅读 · 0 评论 -
LeedCode----169. Majority Element(M)
1 题目 寻找数组中次数多于⌊n/2⌋次的元素,即主元素/众数 题目链接:点击打开链接2 思路和实现 (1) 分治算法: 将数组分为左右两边,分别找出左右两边的主元素并计算其出现的频率,对比频率找出每个小问题的主元素,递归调用完成算法。 class Solution {public: int原创 2017-04-02 22:29:34 · 330 阅读 · 0 评论 -
LeetCode----516. Longest Palindromic Subsequence(M) 动态规划
1 题目求字符串的最长回文子序列长度Given a string s, find the longest palindromic subsequence's length in s. You may assume that the maximum length of s is 1000.Example 1:Input:"bbbab"Output:4O原创 2017-05-01 20:49:56 · 404 阅读 · 1 评论 -
LeetCode---300. Longest Increasing Subsequence (M)
这星期老师刚好讲到动态规划,讲了最长递增子序列(LIS)问题,于是在LeetCode中找了该题来做1 题目 求最长递增子序列长度。即在一个给定的数值序列中,找到一个子序列,使得这个子序列元素的数值依次递增,并且这个子序列的长度尽可能地大。最长递增子序列中的元素在原序列中不一定是连续的。这是一道动态规划的典型问题 点击打开链接2 分析 该题原创 2017-04-09 22:31:15 · 245 阅读 · 0 评论 -
LeetCode----240. Search a 2D Matrix II (M)
1 题目Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted in ascending from left to right.Intege原创 2017-06-25 20:46:44 · 273 阅读 · 0 评论