- 博客(20)
- 资源 (1)
- 收藏
- 关注
原创 leetcode637+ 求二叉树每一层sum的average+BFS
https://leetcode.com/problems/average-of-levels-in-binary-tree/description/struct TreeNode { int val; TreeNode *left; TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NU...
2018-09-29 00:30:33 147
原创 leetcode633+判断一个数是否为两个数的平方和
https://leetcode.com/problems/sum-of-square-numbers/description/class Solution {public: bool judgeSquareSum(int c) { int limit = sqrt(c); for(int i=0; i<=limit; i++){ ...
2018-09-28 14:59:27 1743
原创 leetcode628+ array中取三个数乘积最大
https://leetcode.com/problems/maximum-product-of-three-numbers/description/class Solution {public: int maximumProduct(vector<int>& nums) { sort(nums.begin(), nums.end()); ...
2018-09-20 22:12:33 176
原创 leetcode617+两个二叉树合并,DP
https://leetcode.com/problems/merge-two-binary-trees/description/struct TreeNode { int val; TreeNode *left; TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) {}};...
2018-09-19 20:23:57 98
原创 leetcode606+二叉树的形式化输出,递归
https://leetcode.com/problems/construct-string-from-binary-tree/description/struct TreeNode { int val; TreeNode *left; TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(...
2018-09-09 20:39:15 247
原创 leetcode564+找到最近的回文数,改变右半边
https://leetcode.com/problems/find-the-closest-palindrome/description/class Solution {public: string nearestPalindromic(string n) { long len = n.size(), num = stol(n), res = 0, minDiff...
2018-09-05 22:03:34 546
原创 leetcde599+求出现相同单词的索sum最小,map进行hash
https://leetcode.com/problems/minimum-index-sum-of-two-lists/description/class Solution {public: vector<string> findRestaurant(vector<string>& list1, vector<string>& ...
2018-09-05 21:52:02 110
原创 leetcode605+判断是否能完全放完花,左右添加0,trick
https://leetcode.com/problems/can-place-flowers/description/class Solution {public: bool canPlaceFlowers(vector<int>& flowerbed, int n) { flowerbed.insert(flowerbed.begin(), ...
2018-09-04 23:28:05 89
原创 leetcode598+求最多的覆盖面积,是从左上角开始到(m,n),因此要求出最下的横坐标和纵坐标
https://leetcode.com/problems/range-addition-ii/description/class Solution {public: int maxCount(int m, int n, vector<vector<int>>& ops) { int minRow = m, mincol = n; ...
2018-09-04 23:02:44 152
原创 leetcode594+最长和谐子序列,使用map进行hash统计
https://leetcode.com/problems/longest-harmonious-subsequence/description/class Solution {public: int findLHS(vector<int>& nums) { map<int, int>Mp; for(int i=0; ...
2018-09-04 22:10:16 136
原创 leetcode593+判断四个点是不是组成了正方形,看所有点的距离是不是只有两种
https://leetcode.com/problems/valid-square/description/class Solution {public: bool validSquare(vector<int>& p1, vector<int>& p2, vector<int>& p3, vector<int&g...
2018-09-04 21:51:13 746
原创 leetcode592+流式计算一堆分数的结果,字符流操作
https://leetcode.com/problems/fraction-addition-and-subtraction/description/class Solution {public: int gcd(int a, int b) { return (b==0)? a:gcd(b, a%b); } string fractionA...
2018-09-03 23:36:58 305
原创 leetcode590+多叉树的后序遍历,递归
https://leetcode.com/problems/n-ary-tree-postorder-traversal/description//*// Definition for a Node.class Node {public: int val; vector<Node*> children; Node() {} Node(in...
2018-09-03 22:56:17 918
原创 leetcode589+多叉树的前序遍历,递归
https://leetcode.com/problems/n-ary-tree-preorder-traversal/description//*// Definition for a Node.class Node {public: int val; vector<Node*> children; Node() {} Node(int...
2018-09-03 22:54:57 1053
原创 leetcode583+删除元素是两string最终一样,最长公共子序列变版
https://leetcode.com/problems/delete-operation-for-two-strings/description/class Solution {public: int minDistance(string word1, string word2) { int n1 = word1.size(), n2 = word2.size(...
2018-09-03 21:52:00 309
原创 leetcode581+求最短未排序数组长度
https://leetcode.com/problems/shortest-unsorted-continuous-subarray/description/class Solution {public: int findUnsortedSubarray(vector<int>& nums) { vector<int> cpnums...
2018-09-02 17:39:34 121
原创 leetcode575+分糖果种类数尽量多,hash
https://leetcode.com/problems/distribute-candies/description/class Solution {public: int distributeCandies(vector<int>& candies) { //最多是一半 map<int, int> CandyCount; ...
2018-09-02 12:11:51 248
原创 leetcode572+判断t是否和s的某一个subtree一样,递归
https://leetcode.com/problems/subtree-of-another-tree/description//** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * ...
2018-09-02 10:30:01 94
原创 leetcode576+多少种方案出去网格,Dp
https://leetcode.com/problems/out-of-boundary-paths/description/class Solution {public: int findPaths(int m, int n, int N, int i, int j) { vector<vector<vector<int>>>...
2018-09-02 00:11:08 280
原创 leetcode567+判断s1的全排列一种是否是s1的子串,sliding window,hash
https://leetcode.com/problems/permutation-in-string/description/class Solution {public: bool checkInclusion(string s1, string s2) { int n1 = s1.size(), n2 = s2.size(); vector&l...
2018-09-01 17:34:47 334
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人