自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

caisense的专栏

诗和远方

  • 博客(18)
  • 收藏
  • 关注

原创 484. Find Permutation

https://leetcode.com/problems/find-permutation/description/题目大意:给一串DDII…D代表下降趋势,I代表上升.根据这一串DDII的序列构建出一个整数vector,且若有多个vector符合要求,返回字典序最小的. 解题思路:根据讨论的思路,首先构建出完全增序(IIII….)的序列1,2,3,4,…n,然后找序列中所有的D,将对应位...

2018-02-27 00:36:55 273

原创 723. Candy Crush

https://leetcode.com/problems/candy-crush/description/题目大意:就是消消乐,横竖数字相同且连起来大于3的消掉. 解题思路:暴力法,遍历每个位置,然后检查是否有横竖连续大于3的,有就将该位置记录在to_crash中.然后对 to_crash中的点进行处理,直到to_Crash为空.画图模拟比较好理解. 代码:class Solut...

2018-02-26 00:35:11 506

原创 293. Flip Game

题目大意:给一串字符++–….,要依次把所有两个连续++翻转成–,求所有可能的输出.解题思路:一次遍历,遇到两个连续的++就翻转,输出.同时保证不影响原串,用一个tmp来操作. 注意:这里有一个奇怪的bug,若不先求出s的长度n,而是在for循环中设终止条件为 s.length()-1,则遇到空串(长度为0)会报错 代码:class Solution {public: vec...

2018-02-16 19:07:20 180

原创 531. Lonely Pixel I

https://leetcode.com/problems/lonely-pixel-i/description/题目大意:给一个矩形,由字符’W’和’B’组成,w代表空白,b代表像素,找出矩阵中横竖方向都只有它自己一个像素的像素总数. 解题思路:两次遍历矩阵.第一次建立横竖方向的像素数表rows,cols,第二次根据表中数据,若a[i,j]位置为像素,且rows[i], cols[j]都等...

2018-02-16 03:25:55 177

原创 370. Range Addition

https://leetcode.com/problems/range-addition/description/题目大意:给一个二维数组,其中每个数组长度为3,包含了更新信息. 解题思路:直接读取更新即可.class Solution {public: vector<int> getModifiedArray(int length, vector<vec...

2018-02-16 00:47:19 121

原创 266. Palindrome Permutation

https://leetcode.com/problems/palindrome-permutation/description/题目大意:(题意有点模糊,看讨论猜的)给一个字符串,判断该串重排列后能否成为回文串. 解题思路:看字符串每个字符的出现频率,出现偶数次的必然能组成回文,出现奇数次的字符最多只能有1个,这个字符即作为回文的中心. 用c++的bitset容器实现,检测到每个字符,相...

2018-02-15 15:24:10 133

原创 346. Moving Average from Data Stream

https://leetcode.com/problems/moving-average-from-data-stream/description/题目大意:初始化一个滑动窗口,大小为w,输入一系列数,求窗口内的平均数,窗口会向前滑动,当窗口填满时,将最早进入的数弹出,加入新的数. 解题思路:用队列,求和时可以利用上次的和,不用每次从头到尾求 代码:class MovingAverag...

2018-02-15 00:47:05 241

原创 280. Wiggle Sort

https://leetcode.com/problems/wiggle-sort/description/题目大意:一串无规则数,要排成驼峰状,即a[1] , a[3], a[5] 比左右两侧的数都大(>=). 题目思路1:先排序,然后插入新数组,时间复杂度: O(nlgn)+O(n)=O(nlgn),空间O(n).题目思路2:一次遍历,a[i]与a[i-1]比较,当i时奇数时...

2018-02-14 01:52:23 153

原创 359. Logger Rate Limiter

https://leetcode.com/problems/logger-rate-limiter/description/ Design a logger system that receive stream of messages along with its timestamps, each message should be printed if and only if it is no...

2018-02-13 17:12:41 156

原创 366. Find Leaves of Binary Tree

https://leetcode.com/problems/find-leaves-of-binary-tree/description/Given a binary tree, collect a tree’s nodes as if you were doing this: Collect and remove all leaves, repeat until the tree is em...

2018-02-13 01:58:34 236

原创 339. Nested List Weight Sum

https://leetcode.com/problems/nested-list-weight-sum/description/Given a nested list of integers, return the sum of all integers in the list weighted by their depth.Each element is either an integ...

2018-02-10 19:34:06 200

原创 544. Output Contest Matches

During the NBA playoffs, we always arrange the rather strong team to play with the rather weak team, like make the rank 1 team play with the rank nth team, which is a good strategy to make the contest...

2018-02-10 15:33:28 196

原创 462. Minimum Moves to Equal Array Elements II

Given a non-empty integer array, find the minimum number of moves required to make all array elements equal, where a move is incrementing a selected element by 1 or decrementing a selected element by

2018-02-04 03:17:21 111

原创 520. Detect Capital

Given a word, you need to judge whether the usage of capitals in it is right or not.We define the usage of capitals in a word to be right when one of the following cases holds:All letters in this

2018-02-03 15:57:02 118

原创 695. Max Area of Island

Given a non-empty 2D array grid of 0’s and 1’s, an island is a group of 1’s (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the grid are surrou

2018-02-03 15:49:38 103

原创 677. Map Sum Pairs

Implement a MapSum class with insert, and sum methods.For the method insert, you’ll be given a pair of (string, integer). The string represents the key and the integer represents the value. If the k

2018-02-03 15:15:22 152

原创 690. Employee Importance

You are given a data structure of employee information, which includes the employee’s unique id, his importance value and his direct subordinates’ id.For example, employee 1 is the leader of employe

2018-02-02 01:26:07 133

原创 508. Most Frequent Subtree Sum

Given the root of a tree, you are asked to find the most frequent subtree sum. The subtree sum of a node is defined as the sum of all the node values formed by the subtree rooted at that node (includi

2018-02-02 01:19:06 125

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除