- 博客(8)
- 资源 (1)
- 收藏
- 关注
原创 leetcode795+最大值在LR之间的连续的子数组个数,剪枝
https://leetcode.com/problems/number-of-subarrays-with-bounded-maximum/class Solution {public: int numSubarrayBoundedMax(vector<int>& A, int L, int R) { int res = 0, len = A....
2019-02-28 23:49:37 280
原创 leetcode797+所有0->N-1的路径,递归DFS
https://leetcode.com/problems/all-paths-from-source-to-target///0 -> N-1class Solution {public: void helper(vector<vector<int>>& graph, int cur, vector<int>path, vect...
2019-02-28 23:09:58 189
原创 leetcode787+s到目的地最多停K次最小花费,Dp
https://leetcode.com/problems/cheapest-flights-within-k-stops/class Solution {public: int findCheapestPrice(int n, vector<vector<int>>& flights, int src, int dst, int K) { ...
2019-02-24 21:59:55 559
原创 leetcode785+二部图染色问题,BFS
https://leetcode.com/problems/is-graph-bipartite/class Solution {public: bool isBipartite(vector<vector<int>>& graph) { vector<int> colors(graph.size()); ...
2019-02-17 22:18:20 770
原创 leetcode791+T中包含S的字符按S排序,map的使用
https://leetcode.com/problems/custom-sort-string/class Solution {public: string customSortString(string S, string T) { string res = ""; map<char, int>mp; for(auto...
2019-02-10 23:44:29 172
原创 leetcode771+S字符串中有多少J中的字符,hash
https://leetcode.com/problems/jewels-and-stones/class Solution {public: int numJewelsInStones(string J, string S) { int res = 0; set<char> st; for(char c : J) st....
2019-02-05 18:24:33 144
原创 leetcode765+调整数组变成couple对都是在一起,贪心
https://leetcode.com/problems/couples-holding-hands/class Solution {public: int minSwapsCouples(vector<int>& row) { int res = 0, len = row.size(); for(int i=0; i<l...
2019-02-05 17:56:22 160
原创 leetcode769+划分数组最多多少段,内部排序能成最后的有序数组,有trick
https://leetcode.com/problems/max-chunks-to-make-sorted/class Solution {public: int maxChunksToSorted(vector<int>& arr) { int res = 0, len = arr.size(), mx = 0; for(i...
2019-02-01 00:24:06 249
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人