上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 23 下一页
摘要: class Solution { public: int maxAreaOfIsland(vector<vector<int>>& grid) { int maxarea = 0; int m = grid.size(); int n = grid[0].size(); if(m==0||n==0) 阅读全文
posted @ 2021-08-12 14:52 三一一一317 阅读(27) 评论(0) 推荐(0)
摘要: class Solution { public: void sortColors(vector<int>& nums) { int i = 0; int j = nums.size()-1; int left = 0; int right = nums.size()-1; // 遍for循环,第一遍 阅读全文
posted @ 2021-08-12 13:15 三一一一317 阅读(32) 评论(0) 推荐(0)
摘要: class Solution { public: int trap(vector<int>& height) { vector<int> left(height.size(),0); vector<int> right(height.size(),0); int lefttemp = 0; int 阅读全文
posted @ 2021-08-12 11:12 三一一一317 阅读(26) 评论(0) 推荐(0)
摘要: // // 这种方法超时了 // class Solution { // public: // static bool cmp(pair <char,int> &a, pair <char,int> &b){ // return a.second > b.second; // } // string 阅读全文
posted @ 2021-08-11 00:23 三一一一317 阅读(30) 评论(0) 推荐(0)
摘要: 变量存放的位置 C/C++程序占用的内存分为以下几部分: 程序代码区常量区存放常量。程序结束时由OS回收。全局区(静态区)存放全局变量和静态变量。初始化的全局变量和静态变量在一块区域,未初始化的全局变量和未初始化的静态变量在相邻的另一块区域。 程序结束时由OS回收。堆区存放的变量(用new,mall 阅读全文
posted @ 2021-08-10 20:34 三一一一317 阅读(94) 评论(0) 推荐(0)
摘要: class Solution { public: int findMin(vector<int>& nums) { int l = 0; int r = nums.size()-1; while(l<=r){ int mid = l + (r-l)/2; if(nums[mid]==nums[r]) 阅读全文
posted @ 2021-08-10 19:21 三一一一317 阅读(26) 评论(0) 推荐(0)
摘要: 双指针: class Solution { public: string findLongestWord(string s, vector<string>& dictionary) { string res; for(int i = 0; i < dictionary.size(); i++){ i 阅读全文
posted @ 2021-08-10 17:33 三一一一317 阅读(32) 评论(0) 推荐(0)
摘要: 这题不用双指针也挺简 class Solution { public: bool validPalindrome(string s) { int i = 0; int j = s.size()-1; int cnt = 0; while(i<j){ if(s[i]!=s[j]){ return is 阅读全文
posted @ 2021-08-10 17:00 三一一一317 阅读(22) 评论(0) 推荐(0)
摘要: 我的第一直觉是hashmap,可能受两数之和的影响 class Solution { public: bool judgeSquareSum(int c) { unordered_map<int, int> un_map; double n = sqrt(c); for(int i = 0; i < 阅读全文
posted @ 2021-08-10 16:33 三一一一317 阅读(31) 评论(0) 推荐(0)
摘要: 解析参考:非常详细 https://blog.csdn.net/weixin_45629285/article/details/118674829 class Solution { public: string minWindow(string s, string t) { unordered_ma 阅读全文
posted @ 2021-08-10 16:10 三一一一317 阅读(23) 评论(0) 推荐(0)
上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 23 下一页