赛后个人排名
leetcode个人资料
赛题分析总结
class Solution {
public:
string removeDigit(string number, char digit) {
vector<string> unSet;
for(int i{};i<number.size();++i){
if(number[i] == digit){
string temp = number;
temp.erase(temp.begin()+i);
unSet.push_back(temp);
}
}
sort(unSet.begin(),unSet.end());
int n = unSet.size();
return unSet[n-1];
}
};
class Solution {
public:
int minimumCardPickup(vector<int>& cards) {
int result{INT_MAX};
unordered_map<int,int> unMap;
unMap[cards[0]]++;
int left{},right{1};
for(right = 1;right < cards.size();++right){
unMap[cards[right]]++;
while(unMap[cards[right]] == 2){
result = min(right - left + 1,result);
unMap[cards[left++]]--;
}
}
return result == INT_MAX ? -1 : result;
}
};
class Solution {
public:
int countDistinct(vector<int>& nums, int k, int p) {
set<vector<int>> s;
vector<int> v;
for(int i{};i<nums.size();++i){
v.clear();
int count{};
for(int j = i;j<nums.size();++j){
v.push_back(nums[j]);
if(nums[j] %p == 0){
count++;
if(count > k) break;
}
s.insert(v);
}
}
return s.size();
}
};
第四题,直接忽视,嘿嘿
反思总结
个人情况
第26次参加leetcode竞赛;
总计得到过6次12分,11次7分,9次3分;
后续改进
- 回溯的子集问题复习以及暴力模拟+哈希表去重
|