
leetcode
文章平均质量分 69
BrcLi
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Leetcode495 Teemo Attacting
// C++In LOL world, there is a hero called Teemo and his attacking can make his enemy Ashe be in poisoned condition. Now, given the Teemo's attacking ascending time series towards Ashe and the poison原创 2017-08-09 22:40:55 · 663 阅读 · 0 评论 -
LeetCode 84. Largest Rectangle in Histogram 单调栈应用
单调栈即栈内元素必须单调增或者单调减,假设有数组arr[2,1,5,6,2,3],求数组中每个数字左右两边离他最近的比他小的数, 2: 左边—无 右边—11: 左边—无 右边—无5: 左边—1 右边—2。。。最容易想到的方法是对于每个数字,分别从左遍历到此位置找到左边最近且最小的数字,从右遍历到此位置找到右边最近且最小的数字,对于原创 2017-08-17 10:04:30 · 985 阅读 · 0 评论 -
Leetcode 142. Linked List Cycle II
Given a linked list, return the node where the cycle begins. If there is no cycle, return null.Note: Do not modify the linked list.题意:找到循环链表的循环开始位置设置快指针一次走2步和慢指针一次走1步同时遍历链表,若快指针最后和慢指针指向同一节原创 2017-08-13 17:22:24 · 386 阅读 · 0 评论 -
最大子序列和
求最大子序列的和是一道经典的动态规划题目:给一个数组,求出数组中和最大的子序列,输出最大的和,有些题目还需要输出子序列的开始和结束位置:题目参考:LeetCode :https://leetcode.com/problems/maximum-subarray/description/hdoj :http://acm.hdu.edu.cn/showproblem.php?pid=100原创 2017-08-13 12:50:16 · 617 阅读 · 0 评论 -
Leetcode :Intersection of Two Arrays 两个数组的交集
LeetCode349. Intersection of Two ArraysGiven two arrays, write a function to compute their intersection.Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2].Note:Each原创 2017-08-12 09:45:54 · 379 阅读 · 0 评论 -
LeetCode 648. Replace Words 字典树练习
In English, we have a concept called root, which can be followed by some other words to form another longer word - let's call this word successor. For example, the root an, followed by other, whic原创 2017-08-15 11:23:42 · 1057 阅读 · 0 评论 -
字典树的应用:求数组中异或最大的两个数
求数组中异或最大的两个数,题目参考LeetCode:https://leetcode.com/problems/maximum-xor-of-two-numbers-in-an-array/description/hdoj :http://acm.hdu.edu.cn/showproblem.php?pid=4825最暴力也最容易想到的是遍历数组中每一个数,计算与其他数的异或,原创 2017-08-15 11:53:46 · 936 阅读 · 0 评论 -
LeetCode200. Number of Islands 基础dfs
题目:https://leetcode.com/problems/number-of-islands/description/dfs寻找联通区域个数,使用递归会超时,要用栈模拟递归,代码如下:class Solution {public: void dfs(vector> grid,vector> &visited ,int i,int j){原创 2017-08-16 08:40:52 · 471 阅读 · 0 评论 -
leetcode:739. Daily Temperatures 单调栈
Given a list of daily temperatures, produce a list that, for each day in the input, tells you how many days you would have to wait until a warmer temperature. If there is no future day for which thi原创 2017-12-20 22:42:25 · 1491 阅读 · 0 评论