摘要: class Solution { public: string replaceSpaces(string &str) { int len=0; for(auto c:str) { if(c==' ') len+=3; else len++; } int i=str.size()-1,j=len-1; 阅读全文
posted @ 2023-03-13 10:53 穿过雾的阴霾 阅读(18) 评论(0) 推荐(0)
摘要: class Solution { public: bool searchArray(vector<vector<int>> array, int target) { if(array.empty()||array[0].empty()) return false; int i=0,j=array[0 阅读全文
posted @ 2023-03-13 10:51 穿过雾的阴霾 阅读(15) 评论(0) 推荐(0)
摘要: class Solution { public: int duplicateInArray(vector<int>& nums) { int l=1,r=nums.size()-1;//注意r是n-1 while(l<r) { int cnt=0;//记录≤mid的个数 int mid=l+r>>1 阅读全文
posted @ 2023-03-13 10:51 穿过雾的阴霾 阅读(20) 评论(0) 推荐(0)
摘要: class Solution { public: int duplicateInArray(vector<int>& nums) { int n=nums.size(); for (int i = 0; i < n; i ++ ) if(nums[i]<0||nums[i]>=n) //防止遇到重复 阅读全文
posted @ 2023-03-13 10:50 穿过雾的阴霾 阅读(25) 评论(0) 推荐(0)
摘要: /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), r 阅读全文
posted @ 2023-03-13 10:49 穿过雾的阴霾 阅读(19) 评论(0) 推荐(0)
摘要: /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode *father; * TreeNode(int x) : v 阅读全文
posted @ 2023-03-13 10:48 穿过雾的阴霾 阅读(22) 评论(0) 推荐(0)
摘要: class Solution { public: int reverse(int x) { long long res=0; while(x) { int t=x%10; x/=10; res=res*10+t; } if(res<INT_MIN||res>INT_MAX) return 0; re 阅读全文
posted @ 2023-03-13 09:19 穿过雾的阴霾 阅读(14) 评论(0) 推荐(0)