06 2018 档案

摘要:/** * 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-06-10 08:00 JTechRoad 阅读(96) 评论(0) 推荐(0) 编辑
摘要:class Solution { public: int maxProfit(vector& prices, int fee) { int n = prices.size(); if (n <= 1) return 0; // s0: max profit when not holding any stock // s1: max pro... 阅读全文
posted @ 2018-06-03 15:26 JTechRoad 阅读(75) 评论(0) 推荐(0) 编辑
摘要:class Solution { public: bool validPalindrome(string s) { int i = 0, j = s.length() - 1; while (i < j) { if (s[i] == s[j]) { i++; j--; ... 阅读全文
posted @ 2018-06-01 22:56 JTechRoad 阅读(121) 评论(0) 推荐(0) 编辑
摘要:class Solution { public: int findNumberOfLIS(vector& nums) { if (nums.size() == 0) return 0; pair res = {0, 0}; // vector> dp(nums.size(), {1,1}); // pair: length, cou... 阅读全文
posted @ 2018-06-01 15:56 JTechRoad 阅读(78) 评论(0) 推荐(0) 编辑
摘要:slow: faster: 阅读全文
posted @ 2018-06-01 15:55 JTechRoad 阅读(106) 评论(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-06-01 13:50 JTechRoad 阅读(88) 评论(0) 推荐(0) 编辑
摘要:class Solution { public: int numDecodings(string s) { int n = s.length(); if (n == 0) return 0; vector dp(n+1, 0); dp[0] = 1; for (int i = 0; i 0) { ... 阅读全文
posted @ 2018-06-01 13:33 JTechRoad 阅读(153) 评论(0) 推荐(0) 编辑