部分文章内容为公开资料查询整理,原文出处可能未标注,如有侵权,请联系我,谢谢。邮箱地址:gnivor@163.com ►►►需要气球么?请点击我吧!

文章分类 -  Leetcode

摘要:https://leetcode.cn/problems/number-of-ways-to-wear-different-hats-to-each-other/ 状态压缩dp https://blog.csdn.net/u013377068/article/details/81054112 pac 阅读全文
posted @ 2022-08-19 23:42 流了个火 阅读(40) 评论(0) 推荐(0)
摘要:最大连续子序列和 我们用sum[i]来表示以arr[i]结尾的最大连续子序列和,则状态转移方程为: 最大连续子序列乘积 考虑存在负数的情况(ps:负负会得正),因此我们用两个辅助数组,max[i]和min[i],max[i]来表示以arr[i]结尾的最大连续子序列乘积,min[i]来表示以arr[i 阅读全文
posted @ 2016-02-14 14:56 流了个火 阅读(124) 评论(0) 推荐(0)
摘要:segment tree这种数据结构主要应用在计算几何和地理信息系统中树:是一棵树,而且是一棵二叉树。线段:树上的每个节点对应于一个线段(还是叫“区间”更容易理解,区间的起点和终点通常为整数)同一层的节点所代表的区间,相互不会重叠。叶子节点的区间是单位长度,不能再分了。下图是一个线段树线段树是一棵二... 阅读全文
posted @ 2015-11-19 16:15 流了个火 阅读(232) 评论(0) 推荐(0)
摘要:30Substring with Concatenation of All Words37Sudoku Solverpackage com037.SudokuSolver;public class Solution2 { public static void main(String[] arg... 阅读全文
posted @ 2015-10-10 15:41 流了个火 阅读(162) 评论(0) 推荐(0)
摘要:Givennpoints on a 2D plane, find the maximum number of points that lie on the same straight line.Point数据结构class Point { int x; int y; Point()... 阅读全文
posted @ 2015-09-26 18:58 流了个火 阅读(166) 评论(0) 推荐(0)
摘要:参考资料:http://segmentfault.com/a/1190000003786782方法:使用堆复杂度 时间 O(NlogN) 空间 O(N)如果按照一个矩形一个矩形来处理将会非常麻烦,我们可以把这些矩形拆成两个点,一个左上顶点,一个右上顶点。将所有顶点按照横坐标排序后,我们开始遍历这些点... 阅读全文
posted @ 2015-09-26 11:57 流了个火 阅读(588) 评论(0) 推荐(0)
摘要:Word Ladder 解析:http://blog.csdn.net/yutianzuijin/article/details/12887747利用BFSpublic static int ladderLength(String start, String end, Set dict) { ... 阅读全文
posted @ 2015-09-25 22:03 流了个火 阅读(156) 评论(0) 推荐(0)
摘要:Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations:getandset.get(key)- Get the valu... 阅读全文
posted @ 2015-09-25 14:49 流了个火 阅读(133) 评论(0) 推荐(0)
摘要:Word Search: http://blog.csdn.net/ljiabin/article/details/45846231Word Search II: http://blog.csdn.net/ljiabin/article/details/45846527Word Searchpubl... 阅读全文
posted @ 2015-09-22 14:58 流了个火 阅读(167) 评论(0) 推荐(0)
摘要:转自http://www.cnblogs.com/bakari/p/4007368.html题目:Maximum Product SubarrayFind the contiguous subarray within an array (containing at least one number)... 阅读全文
posted @ 2015-09-21 21:33 流了个火 阅读(108) 评论(0) 推荐(0)
摘要:参考资料:http://blog.csdn.net/ljiabin/article/details/39061181http://www.cnblogs.com/changchengxiao/p/3618103.html首先设每个孩子得到一个糖果。然后从前往后扫一遍,如果当前孩子比前一个孩子rati... 阅读全文
posted @ 2015-09-19 19:01 流了个火 阅读(103) 评论(0) 推荐(0)
摘要:Sort a linked list inO(nlogn) time using constant space complexity.对链表排序,要达到O(nlogn)的时间复杂度,可使用归并排序过程分为两部分:1.递归的进行排序; 2. 合并有一个问题:怎么找链表的中点? 采用快慢指针的方法。快指... 阅读全文
posted @ 2015-09-17 13:47 流了个火 阅读(127) 评论(0) 推荐(0)
摘要:Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximu... 阅读全文
posted @ 2015-07-26 19:33 流了个火 阅读(106) 评论(0) 推荐(0)
摘要:Given a string containing just the characters'('and')', find the length of the longest valid (well-formed) parentheses substring.For"(()", the longest... 阅读全文
posted @ 2015-07-26 15:39 流了个火 阅读(361) 评论(0) 推荐(0)
摘要:Givennnon-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.Fo... 阅读全文
posted @ 2015-07-22 18:26 流了个火 阅读(216) 评论(0) 推荐(0)
摘要:题目大意:给出一个数,在数组中寻找一个长度最短的子数组,使得数组和大于给定的数。思路:使用两个指针, start end。end向后走,直到 sum 大于 s. 然后start向后, 直到sum 小于s. 同时更新 min值.类似于编程之美--3.5 最短摘要的生成http://www.cnblog... 阅读全文
posted @ 2015-07-21 08:43 流了个火 阅读(117) 评论(0) 推荐(0)
摘要:问题大意:给定一个链表,找到链表循环部分的头部。如果不存在循环,返回null。找链表头部的方法:链表头是X,环的第一个节点是Y,slow和fast第一次的交点是Z。各段的长度分别是a,b,c,如图所示。环的长度是L。slow每次前进1个元素,fast每次前进两个元素。首先给出判别链表是否有环的方法:... 阅读全文
posted @ 2015-07-20 20:38 流了个火 阅读(315) 评论(0) 推荐(0)
摘要:198 House Robber问题大意:一个强盗打算抢一条街上的若干户人家,每一家都有一定数量的财物。由于存在这样一种报警机制:如果强盗抢了两户相邻的人家,那么就会自动报警。在这种情况下,强盗怎么抢才能使得收益最大。使用一个数组来表示每一户拥有的财物。方法1:采用递归的方法(超时了)第一步一定会选... 阅读全文
posted @ 2015-07-20 18:24 流了个火 阅读(151) 评论(0) 推荐(0)
摘要:问题大意使用用队列来模拟栈的操作。push(x) 将元素x入栈。pop() 出栈。top() 获取栈顶元素。empty() 判断是否为空。注意:只能用队列的标准操作,队头取元素,队尾插入元素,获取队列的大小,以及队列是否为空。方法:使用一个队列来模拟栈入栈=直接入队列出栈=将队列前n-1个元素出队后... 阅读全文
posted @ 2015-07-20 15:40 流了个火 阅读(142) 评论(0) 推荐(0)
摘要:()题目大意:有一个数组,除了一个元素出现了一次,所有其他元素均出现了两次,求出这个元素。题目要求时间复杂度O(n) , 空间复杂度O(1)刚读完题,想到的是使用HashMap来看元素是否重复,时间复杂度为O(n),但是空间复杂度为O(1),不满足题意。仍然给出代码:(如果元素在map内,则删除,否... 阅读全文
posted @ 2015-07-19 17:13 流了个火 阅读(175) 评论(0) 推荐(0)

►►►需要气球么?请点击我吧!►►►
View My Stats