摘要:
题意理解有误,看了网上答案才弄出来 1 class Solution { 2 public: 3 string countAndSay(int n) { 4 // Start typing your C/C++ solution below 5 // DO N... 阅读全文
摘要:
第一次想用懒汉方法把list弄成vector再照前一题的方法,结果被判Memory exceed了。。然后只好再写次 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 *... 阅读全文
摘要:
一次过 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * TreeNod... 阅读全文
摘要:
第一次用了个O(n^2)的算法large没过,就仔细想了想,少数次过吧 1 class Solution { 2 public: 3 int maxArea(vector &height) { 4 // Start typing your C/C++ solution bel... 阅读全文
摘要:
跟inorder and postorder基本一样,一次过吧 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeN... 阅读全文
摘要:
第一次只用4个系数写dfs怎么写都不对,后来看了网上的答案发现写右子树的时候开始点不一样的。。。所以要用5个系数 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeN... 阅读全文
摘要:
初始系数没弄好,改了一次 加一个iterative的方法 C# 1 public class Solution { 2 public List<List<int>> Combine(int n, int k) { 3 List<List<int>> ans = new List<List<int>> 阅读全文
摘要:
改了挺多次,不过最后还是被我搞出来了^^, 用了map的技巧勉强过了large。 1 class Solution { 2 public: 3 void dfs(vector num, int target, int sum, vector &save, map, int> &reti, i... 阅读全文
摘要:
第一次没考虑到要加个系数cur, 因为必须从小到大排序,导致答案里有[1, 2]和[2, 1],加入cur后就acm了 1 class Solution { 2 public: 3 void dfs(vector candidates, int target, int sum, vector... 阅读全文
摘要:
一开始用dfs结果large超时,马上就想到dp了。。哎,下次先得去想dp啊。。 1 class Solution { 2 public: 3 int climbStairs(int n) { 4 // Start typing your C/C++ solution bel... 阅读全文
摘要:
出错了一次,改了一次,小失误没用弄好zigzag的排序。题目还是简单的 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * T... 阅读全文
摘要:
这题比较难,没理顺关系,做了很多次还只是过了small judge,于是去看网上答案,然后再改了改,关键在于local_max和globe_max,globe_max要随时改得,而maxsum函数只是返回最大路径 1 /** 2 * Definition for binary tree 3 * ... 阅读全文