算法
文章平均质量分 85
一_然
学渣一枚。。。。。
展开
-
Jump Game 和Jump Game II---LeetCode
今天我们来看一下LeetCode的第55题和第45题:Jump Game和Jump Game II,原题连接:Jump GameII,Jump Game;个人认为这是两道典型的贪心算法题目。Jump Game的大意为:给定一组非负整数,每个整数代表着当前位置能够跳的最大的步数,判断能否从开始位置到达末尾。如: A = [2,3,1,1,4], return true. A = [3原创 2017-08-20 13:51:31 · 237 阅读 · 0 评论 -
Merge Intervals--LeetCode
昨晚做了一道LeetCode算法题,Merge Intervals,题目难度中等,原题链接:Merge Intervals。 Given a collection of intervals, merge all overlapping intervals. For example, Given [1,3],[2,6],[8,10],[15,18], return [1,6],[原创 2017-08-21 09:23:39 · 222 阅读 · 1 评论 -
Insert Intervals---LeetCode
又刷了一道算法题——Insert Intervals,原题链接Insert Intervals,显示为hard,但是我觉得很简单,并没有达到hard等级,哈哈,小小的装一个逼啊。原题如下: Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessa原创 2017-08-28 14:05:51 · 164 阅读 · 0 评论 -
Spiral Matrix II ---leetcode
Spiral Matrix II,原题链接leetcode原题链接 Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order. For example, Given n = 3, You should return the following matri原创 2017-09-09 16:46:39 · 144 阅读 · 0 评论 -
Number of Atoms--LeetCode
最近刷了一道算法题 Number of Atoms,原题链接Number of Atoms发现网上几乎没什么答案,可能是题号太靠后的原因吧,做出来之后收获挺多的,打算分享一下。 这道题的tag是HashTable、Stack和Recursion,拿到题的第一感觉就是有两种解法,一种是stack,一种是递归,两种解法都要用到hashTable。想到了数据结构与算法课学到的逆波兰式,决定用sta原创 2017-11-23 00:24:19 · 285 阅读 · 0 评论