上一页 1 2 3 4 5 6 ··· 17 下一页
摘要: /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ cla... 阅读全文
posted @ 2018-12-03 13:43 JTechRoad 阅读(73) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: vector path; unordered_map> m; vector findItinerary(vector> tickets) { for (auto &p : tickets) m[p.first].insert(p.second); dfs("JFK")... 阅读全文
posted @ 2018-12-02 07:41 JTechRoad 阅读(90) 评论(0) 推荐(0) 编辑
摘要: /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ cla... 阅读全文
posted @ 2018-12-02 07:40 JTechRoad 阅读(68) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: int calPoints(vector& ops) { vector v; for (auto &s : ops) { if (s == "+") { v.push_back(v[v.size()-1] + v[v.size()-2]); ... 阅读全文
posted @ 2018-12-01 17:06 JTechRoad 阅读(82) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: string solveEquation(string equation) { int idx = equation.find('='); int x1 = 0, v1 = 0, x2 = 0, v2 = 0, idx1 = 0, idx2 = 0; helper(equa... 阅读全文
posted @ 2018-12-01 15:07 JTechRoad 阅读(95) 评论(0) 推荐(0) 编辑
摘要: // Double points, or we can use DP (2 vectors to maintain left-max and right-max of each point.) class Solution { public: int trap(vector& height) { int res = 0, i = 0, j = height.size()-... 阅读全文
posted @ 2018-11-30 16:37 JTechRoad 阅读(88) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) { int res = (C-A) * (D-B) + (G-E) * (H-F); long x1 = max(A,E), y1 = max(B,F), x2 =... 阅读全文
posted @ 2018-11-30 15:44 JTechRoad 阅读(91) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: vector findErrorNums(vector& nums) { for (int i = 0; i ({nums[res], res+1}); } }; 阅读全文
posted @ 2018-11-30 15:16 JTechRoad 阅读(94) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: string reverseStr(string s, int k) { for (size_t i = 0; i < s.length(); i += 2 * k) { int start = i; int end = min(i+k, s.length()) - 1; ... 阅读全文
posted @ 2018-11-30 14:43 JTechRoad 阅读(102) 评论(0) 推荐(0) 编辑
摘要: huge perf improve from 1000+ ms to 300 ms: 阅读全文
posted @ 2018-11-29 23:39 JTechRoad 阅读(116) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 17 下一页