上一页 1 2 3 4 5 6 7 8 9 ··· 23 下一页
摘要: /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * ListNode(int x) : 阅读全文
posted @ 2021-08-18 12:34 三一一一317 阅读(61) 评论(0) 推荐(0)
摘要: class Solution { public: int maxSubArray(vector<int>& nums) { int res = INT_MIN; int sum = 0; for(int i = 0; i < nums.size(); i++){ if(sum<=0){ sum = 阅读全文
posted @ 2021-08-18 11:53 三一一一317 阅读(43) 评论(0) 推荐(0)
摘要: class Solution { public: void moveZeroes(vector<int>& nums) { int i = 0; int j = 0; while(j<nums.size()){ if(nums[j]!=0){ swap(nums[i],nums[j]); i++; 阅读全文
posted @ 2021-08-18 11:44 三一一一317 阅读(39) 评论(0) 推荐(0)
摘要: class Solution { public: /* 小于10,1~9,9个数字,9位 小于100,10~99,90个数字,180位 小于1000,100~999,900个数字,2700位 */ int findNthDigit(int n) { long digit = 1; // 用来记录n属 阅读全文
posted @ 2021-08-18 11:33 三一一一317 阅读(60) 评论(0) 推荐(0)
摘要: 第一种dfs,用例还剩最后一个超时了 class Solution { public: int res = INT_MAX; // int m = 0; // int n = 0; int minimumTotal(vector<vector<int>>& triangle) { // m = tr 阅读全文
posted @ 2021-08-17 21:38 三一一一317 阅读(53) 评论(0) 推荐(0)
摘要: class Solution { public: vector<string> split(string str, string flag){ vector<string> res; int fd = 0; // 注意前面是赋值。fd = str.find(flag) // 后面是判断,如果fd = 阅读全文
posted @ 2021-08-17 20:39 三一一一317 阅读(49) 评论(0) 推荐(0)
摘要: 参考: https://www.bilibili.com/video/BV1Tz4y167pC?from=search&seid=6576840001001728880 class Solution { public: string removeDuplicateLetters(string s) 阅读全文
posted @ 2021-08-17 19:40 三一一一317 阅读(72) 评论(0) 推荐(0)
摘要: class Solution { public: vector<vector<int>> threeSum(vector<int>& nums) { vector<vector<int>> res; sort(nums.begin(), nums.end()); // 排序,方便后续处理 for(i 阅读全文
posted @ 2021-08-17 16:22 三一一一317 阅读(57) 评论(0) 推荐(0)
摘要: class Solution { public: vector<int> addToArrayForm(vector<int>& num, int k) { vector<int> vec; string str_k = to_string(k); // cout<<"num: "<<num.siz 阅读全文
posted @ 2021-08-17 15:32 三一一一317 阅读(48) 评论(0) 推荐(0)
摘要: /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode() : val(0), left(nullptr), rig 阅读全文
posted @ 2021-08-16 20:08 三一一一317 阅读(42) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 7 8 9 ··· 23 下一页