上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 20 下一页
摘要: class Solution { public: int getMissingNumber(vector<int>& nums) { if(!nums.size()) return 0; int l=0,r=nums.size()-1; while(l<r)//找到第一个满足nums[i]=i+1的 阅读全文
posted @ 2023-05-05 11:27 穿过雾的阴霾 阅读(40) 评论(0) 推荐(0)
摘要: class Solution { public: //二分找出k第一次,最后一个k后面的下标,相减就是答案 int getNumberOfK(vector<int>& nums , int k) { int n=nums.size(); if(!n) return 0; //找到第一个≥k的下标 i 阅读全文
posted @ 2023-04-28 15:19 穿过雾的阴霾 阅读(17) 评论(0) 推荐(0)
摘要: 使用空间存储节点的解法 class Solution { public: set<ListNode*> s; ListNode *findFirstCommonNode(ListNode *headA, ListNode *headB) { for (auto i = headA; i ; i=i- 阅读全文
posted @ 2023-04-28 14:47 穿过雾的阴霾 阅读(15) 评论(0) 推荐(0)
摘要: class Solution{ public: string str; int i=0; int cnt[256]={0}; //Insert one char from stringstream void insert(char c){ str+=c; cnt[c]++; } //return t 阅读全文
posted @ 2023-04-27 15:00 穿过雾的阴霾 阅读(18) 评论(0) 推荐(0)
摘要: class Solution { public: int longestSubstringWithoutDuplication(string s) { int len=0,n=s.size(),cnt[30]; memset(cnt,0,sizeof cnt); for (int i = 0,j = 阅读全文
posted @ 2023-04-27 14:06 穿过雾的阴霾 阅读(14) 评论(0) 推荐(0)
摘要: class Solution { public: int f[510][510];//f[i][j]表示将s1前i个字符和s2前j个字符的最长公共子序列长度 int minDistance(string word1, string word2) { int n=word1.size(),m=word 阅读全文
posted @ 2023-04-26 17:13 穿过雾的阴霾 阅读(15) 评论(0) 推荐(0)
摘要: class Solution { public: bool check(char a,char b) { int num=(a-'0')*10+(b-'0'); if(num>=10&&num<=25) return true; return false; } int getTranslationC 阅读全文
posted @ 2023-04-26 16:37 穿过雾的阴霾 阅读(21) 评论(0) 推荐(0)
摘要: class Solution { public: int res; priority_queue<int,vector<int>,greater<int>> minheap; unordered_set<int> s;//所有出现过的丑数放在集合中 int getUglyNumber(int n) 阅读全文
posted @ 2023-04-25 15:08 穿过雾的阴霾 阅读(15) 评论(0) 推荐(0)
摘要: class Solution { public: int f[60];//f[i]记录i能拆出的最大乘积 int integerBreak(int n) { for(int i=2;i<=n;i++) for(int j=1;j<i;j++)//枚举最后一个拆出的数字,这里不能只循环到i/2 f[i 阅读全文
posted @ 2023-04-24 16:28 穿过雾的阴霾 阅读(16) 评论(0) 推荐(0)
摘要: class Solution { public: long long f[1010];//f[i]表示总和为i的选法个数 int combinationSum4(vector<int>& nums, int target) { int n=nums.size(); f[0]=1; for(int i 阅读全文
posted @ 2023-04-24 15:43 穿过雾的阴霾 阅读(16) 评论(0) 推荐(0)
上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 20 下一页