- 博客(6)
- 收藏
- 关注
原创 Number of Atoms--LeetCode
最近刷了一道算法题 Number of Atoms,原题链接Number of Atoms发现网上几乎没什么答案,可能是题号太靠后的原因吧,做出来之后收获挺多的,打算分享一下。 这道题的tag是HashTable、Stack和Recursion,拿到题的第一感觉就是有两种解法,一种是stack,一种是递归,两种解法都要用到hashTable。想到了数据结构与算法课学到的逆波兰式,决定用sta
2017-11-23 00:24:19 285
原创 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
原创 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
原创 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
原创 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
原创 Maximum Subarray
原题请戳Maximum Subarray 大意为:求给定数组的最大子数组的元素之和。 本题可用两种方法解题,分别为:动态规划和divide and conquer,本文先介绍动态规划解法,divide and conquer解法见下篇博客 本文算是一道比较经典的动态规划题目了,与暴力求解(穷举法)相比,可将时间复杂度降为O(n),空间复杂度仅为O(1) 采用“局部最优和全局最优解法” 顾
2017-08-12 13:32:29 205 2
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人