左神进阶四期
看这个题真好看
机器学习+深度学习+leetcode+随时准备转行
展开
-
Leetcode84和85新开一个吧,属于单调栈但是更多是一种思想吧,就是设计柱状图的时候都有类似的思想,还有就是思想的一系列流程
Leetcode84 柱状图中的最大矩形方法1:暴力法,就是找每个高度,连续的个数即可未改进的暴力法用时:646ms,打败5.05class Solution { public int largestRectangleArea(int[] heights) { Map<Integer,Integer> map=new HashMap();//存放高度以...原创 2019-11-13 19:58:56 · 170 阅读 · 0 评论 -
单调栈结构(也会涉及一些别的知识)(利口 讲的很好)
Leetcode42 接雨水题目:方法1: 求每一列的,遍历每个列,当前列只和她左边的最大值以及右边的最大值有关系,因为木桶效应。class Solution { public int trap(int[] height) { //两端一定没水,因为他们 int res=0; for(int i=1;i<height.length...原创 2019-11-11 19:26:11 · 165 阅读 · 0 评论 -
(有马拉车)leetcode409 最长回文串 125
方法1:自己想的,当时看到就想到了可以看组合数,然后根据有没有剩余元素加1和不加1,因为是字母,所以我不想用hashmap,而是用的数组,类似于计数排序的思想,速度非常快,打败了百分之百class Solution { public int longestPalindrome(String s) { int [] next=new int['z'-'A'+1]; ...原创 2019-11-01 18:25:36 · 198 阅读 · 0 评论 -
KMP
先来个题,这块我不确定下次看会不会蒙,但是我也确实用语言表达不出来Leetcode 28暴力法:class Solution { public int strStr(String s1, String s2) { char[] arr1=s1.toCharArray(); char[] arr2=s2.toCharArray(); i...原创 2019-10-30 10:15:07 · 85 阅读 · 0 评论