id int64 1 3.58k | problem_description stringlengths 516 21.8k | instruction int64 0 3 | solution_c dict |
|---|---|---|---|
3,430 | <p>You are given a positive integer <code>days</code> representing the total number of days an employee is available for work (starting from day 1). You are also given a 2D array <code>meetings</code> of size <code>n</code> where, <code>meetings[i] = [start_i, end_i]</code> represents the starting and ending days of me... | 3 | {
"code": "class Solution {\npublic:\n int countDays(int days, vector<vector<int>>& meetings) {\n vector<pair<int,int>>v;\n\n for(auto it : meetings){\n v.push_back({it[0],it[1]});\n }\n\n sort(v.begin(),v.end());\n\n // for(auto it :v){\n // cou... |
3,430 | <p>You are given a positive integer <code>days</code> representing the total number of days an employee is available for work (starting from day 1). You are also given a 2D array <code>meetings</code> of size <code>n</code> where, <code>meetings[i] = [start_i, end_i]</code> represents the starting and ending days of me... | 3 | {
"code": "class Solution {\npublic:\n int countDays(int days, vector<vector<int>>& meetings) {\n vector<pair<int,int>>v;\n\n for(auto it : meetings){\n v.push_back({it[0],it[1]});\n }\n\n sort(v.begin(),v.end());\n\n for(auto it :v){\n cout<<it.... |
3,430 | <p>You are given a positive integer <code>days</code> representing the total number of days an employee is available for work (starting from day 1). You are also given a 2D array <code>meetings</code> of size <code>n</code> where, <code>meetings[i] = [start_i, end_i]</code> represents the starting and ending days of me... | 3 | {
"code": "class Solution {\npublic:\n int countDays(int days, vector<vector<int>>& meetings) {\n vector<int> start;\n vector<int> end;\n int n = meetings.size();\n for(auto it: meetings){\n start.push_back(it[0]);\n end.push_back(it[1]);\n }\n\n sort... |
3,430 | <p>You are given a positive integer <code>days</code> representing the total number of days an employee is available for work (starting from day 1). You are also given a 2D array <code>meetings</code> of size <code>n</code> where, <code>meetings[i] = [start_i, end_i]</code> represents the starting and ending days of me... | 3 | {
"code": "class Solution {\npublic:\n int countDays(int days, vector<vector<int>>& meetings) {\n vector<vector<int>>v=meetings;\n int n=v.size();\n int ans=0;\n sort(v.begin(),v.end());\n int mx=v[0][1];\n for(int i=1;i<n;i++)\n {\n if(v[i][0]>mx+1)\n ... |
3,430 | <p>You are given a positive integer <code>days</code> representing the total number of days an employee is available for work (starting from day 1). You are also given a 2D array <code>meetings</code> of size <code>n</code> where, <code>meetings[i] = [start_i, end_i]</code> represents the starting and ending days of me... | 3 | {
"code": "class Solution {\npublic:\n int countDays(int days, vector<vector<int>>& meetings) {\n vector<vector<int>>v=meetings;\n int n=v.size();\n int ans=0;\n sort(v.begin(),v.end());\n int mx=v[0][1];\n for(int i=1;i<n;i++)\n {\n if(v[i][0]>mx+1)\n ... |
3,430 | <p>You are given a positive integer <code>days</code> representing the total number of days an employee is available for work (starting from day 1). You are also given a 2D array <code>meetings</code> of size <code>n</code> where, <code>meetings[i] = [start_i, end_i]</code> represents the starting and ending days of me... | 3 | {
"code": "class Solution {\npublic:\n int countDays(int days, vector<vector<int>>& meetings) {\n vector<vector<int>> v = meetings;\n sort(v.begin(),v.end());\n int cnt = 0 ;\n int n = meetings.size();\n int endT = v[0][1];\n cnt += v[0][1] - v[0][0] + 1;\n\n for(in... |
3,430 | <p>You are given a positive integer <code>days</code> representing the total number of days an employee is available for work (starting from day 1). You are also given a 2D array <code>meetings</code> of size <code>n</code> where, <code>meetings[i] = [start_i, end_i]</code> represents the starting and ending days of me... | 3 | {
"code": "class Solution {\npublic:\n vector<vector<int>> transform(vector<vector<int>> m){\n int l=m[0][0],r=m[0][1];\n vector<vector<int>> res;\n\n for(int i=1;i<m.size();i++){\n if(m[i][0]<=r) r=max(r,m[i][1]);\n else{\n res.push_back({l,r});\n ... |
3,430 | <p>You are given a positive integer <code>days</code> representing the total number of days an employee is available for work (starting from day 1). You are also given a 2D array <code>meetings</code> of size <code>n</code> where, <code>meetings[i] = [start_i, end_i]</code> represents the starting and ending days of me... | 3 | {
"code": "class Solution {\n vector<vector<int>> overlap(vector<vector<int>> meetings)\n {\n vector<vector<int>> merged;\n sort(meetings.begin(), meetings.end());\n merged.push_back(meetings[0]);\n\n for(auto& interval : meetings)\n {\n if(interval[0] <= merged.bac... |
3,430 | <p>You are given a positive integer <code>days</code> representing the total number of days an employee is available for work (starting from day 1). You are also given a 2D array <code>meetings</code> of size <code>n</code> where, <code>meetings[i] = [start_i, end_i]</code> represents the starting and ending days of me... | 3 | {
"code": "#include <bits/stdc++.h>\nusing namespace std;\n\nclass Solution {\npublic:\n int countDays(int days, vector<vector<int>>& meetings) {\n multimap<int, int> mpp;\n for(int i = 0; i < meetings.size(); i++){\n mpp.insert({meetings[i][0], meetings[i][1]});\n }\n \n ... |
3,430 | <p>You are given a positive integer <code>days</code> representing the total number of days an employee is available for work (starting from day 1). You are also given a 2D array <code>meetings</code> of size <code>n</code> where, <code>meetings[i] = [start_i, end_i]</code> represents the starting and ending days of me... | 3 | {
"code": "#include <bits/stdc++.h>\n#include <ext/pb_ds/assoc_container.hpp>\nusing namespace __gnu_pbds;\nusing namespace std;\nusing ll=long long;\ntypedef tree <pair<ll,ll>, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;\n/*\n order_of_key (k)\n find_by_order(k)\n*/\ntemplat... |
3,430 | <p>You are given a positive integer <code>days</code> representing the total number of days an employee is available for work (starting from day 1). You are also given a 2D array <code>meetings</code> of size <code>n</code> where, <code>meetings[i] = [start_i, end_i]</code> represents the starting and ending days of me... | 3 | {
"code": "class Solution {\npublic:\n int countDays(int days, vector<vector<int>>& meetings) {\n priority_queue<pair<int,char>, vector<pair<int,char>>, greater<pair<int,char>>> pq;\n for(auto m:meetings){\n pq.push({m[0],'A'});\n pq.push({m[1],'D'});\n }\n int arr... |
3,430 | <p>You are given a positive integer <code>days</code> representing the total number of days an employee is available for work (starting from day 1). You are also given a 2D array <code>meetings</code> of size <code>n</code> where, <code>meetings[i] = [start_i, end_i]</code> represents the starting and ending days of me... | 3 | {
"code": "/*\n\nhow many days a person is available for work\nmeetings array\n\ndays is 10^9 so you cant overlap\n\nbasically you need to know when he is free\n\n2 solutions come to my mind\neither sort and merge intervals\n\nor push events in priority queue\nthis sounds easier \n\nlets attempt\n\n4 4 \n\n4 6\n\n*/\... |
3,430 | <p>You are given a positive integer <code>days</code> representing the total number of days an employee is available for work (starting from day 1). You are also given a 2D array <code>meetings</code> of size <code>n</code> where, <code>meetings[i] = [start_i, end_i]</code> represents the starting and ending days of me... | 3 | {
"code": "class Solution {\npublic:\n // merge intervals\n // sort by start time\n // [1,2], [2,3], [4,5]\n int countDays(int days, vector<vector<int>>& meetings) {\n std::sort(meetings.begin(), meetings.end());\n vector<int> prev = meetings[0];\n int res = prev[0]-1;\n\n for ... |
3,430 | <p>You are given a positive integer <code>days</code> representing the total number of days an employee is available for work (starting from day 1). You are also given a 2D array <code>meetings</code> of size <code>n</code> where, <code>meetings[i] = [start_i, end_i]</code> represents the starting and ending days of me... | 3 | {
"code": "class Solution {\npublic:\n int countDays(int days, vector<vector<int>>& meetings) {\n int n = meetings.size();\n sort(meetings.begin(), meetings.end());\n vector<vector<int>> ans;\n ans.push_back(meetings[0]);\n for(int i = 1; i < n; i++) {\n vector<int> v ... |
3,430 | <p>You are given a positive integer <code>days</code> representing the total number of days an employee is available for work (starting from day 1). You are also given a 2D array <code>meetings</code> of size <code>n</code> where, <code>meetings[i] = [start_i, end_i]</code> represents the starting and ending days of me... | 3 | {
"code": "class Solution {\npublic:\n int countDays(int days, vector<vector<int>>& meetings) {\n \n sort(meetings.begin(),meetings.end(),[](const vector<int>& a,const vector<int>& b){\n return a[0]<b[0];\n });\n\n vector<vector<int>> meet;\n meet.push_back(meetings[0]... |
3,430 | <p>You are given a positive integer <code>days</code> representing the total number of days an employee is available for work (starting from day 1). You are also given a 2D array <code>meetings</code> of size <code>n</code> where, <code>meetings[i] = [start_i, end_i]</code> represents the starting and ending days of me... | 3 | {
"code": "class Solution {\npublic:\n int countDays(int days, vector<vector<int>>& meetings) {\n sort(meetings.begin(), meetings.end());\n vector<vector<int>>merge_meetings;\n merge_meetings.push_back(meetings[0]);\n int n = meetings.size();\n for(int i = 1; i < n; ++i){\n ... |
3,430 | <p>You are given a positive integer <code>days</code> representing the total number of days an employee is available for work (starting from day 1). You are also given a 2D array <code>meetings</code> of size <code>n</code> where, <code>meetings[i] = [start_i, end_i]</code> represents the starting and ending days of me... | 3 | {
"code": "class Solution {\npublic:\n // merge intervals\n // sort by start time\n // [1,2], [2,3], [4,5]\n int countDays(int days, vector<vector<int>>& meetings) {\n std::sort(meetings.begin(), meetings.end());\n vector<int> prev = meetings[0];\n vector<vector<int>> non_overlap;\n\n... |
3,430 | <p>You are given a positive integer <code>days</code> representing the total number of days an employee is available for work (starting from day 1). You are also given a 2D array <code>meetings</code> of size <code>n</code> where, <code>meetings[i] = [start_i, end_i]</code> represents the starting and ending days of me... | 3 | {
"code": "class Solution {\npublic:\n int countDays(int days, vector<vector<int>>& meetings) {\n stack<vector<int>> withoutOverlaps;\n sort(meetings.begin(), meetings.end());\n for (const auto& item : meetings) {\n if (withoutOverlaps.empty()) {\n withoutOverlaps.push(item);\n }\n els... |
3,430 | <p>You are given a positive integer <code>days</code> representing the total number of days an employee is available for work (starting from day 1). You are also given a 2D array <code>meetings</code> of size <code>n</code> where, <code>meetings[i] = [start_i, end_i]</code> represents the starting and ending days of me... | 3 | {
"code": "class Solution {\npublic:\n int countDays(int days, vector<vector<int>>& meetings) {\n stack<vector<int>> withoutOverlaps;\n sort(meetings.begin(), meetings.end());\n for (const auto& item : meetings) {\n if (withoutOverlaps.empty()) {\n withoutOverlaps.push(item);\n }\n els... |
3,430 | <p>You are given a positive integer <code>days</code> representing the total number of days an employee is available for work (starting from day 1). You are also given a 2D array <code>meetings</code> of size <code>n</code> where, <code>meetings[i] = [start_i, end_i]</code> represents the starting and ending days of me... | 3 | {
"code": "class Solution {\npublic:\n int countDays(int days, vector<vector<int>>& meetings) \n {\n sort(meetings.begin(), meetings.end());\n stack<vector<int>> s;\n for(vector<int>& interval:meetings)\n {\n if(s.empty())\n {\n s.push(interval);\... |
3,430 | <p>You are given a positive integer <code>days</code> representing the total number of days an employee is available for work (starting from day 1). You are also given a 2D array <code>meetings</code> of size <code>n</code> where, <code>meetings[i] = [start_i, end_i]</code> represents the starting and ending days of me... | 3 | {
"code": "class Solution {\npublic:\n int countDays(int days, vector<vector<int>>& meetings) {\n map<int,int> s;\n for (auto &x: meetings) {\n int u = x[0], v = x[1];\n s[u]++, s[v]--;\n }\n\n int ans = 0, l = 0, cur = 0;\n for (auto [d, v]: s) {\n ... |
3,430 | <p>You are given a positive integer <code>days</code> representing the total number of days an employee is available for work (starting from day 1). You are also given a 2D array <code>meetings</code> of size <code>n</code> where, <code>meetings[i] = [start_i, end_i]</code> represents the starting and ending days of me... | 3 | {
"code": "class Solution {\npublic:\n int countDays(int days, vector<vector<int>>& meetings) {\n map<int, int> line;\n \n for (auto& meeting : meetings) {\n int st = meeting[0], en = meeting[1];\n line[st] += 1;\n line[en+1] -= 1;\n }\n\n int pre... |
3,430 | <p>You are given a positive integer <code>days</code> representing the total number of days an employee is available for work (starting from day 1). You are also given a 2D array <code>meetings</code> of size <code>n</code> where, <code>meetings[i] = [start_i, end_i]</code> represents the starting and ending days of me... | 3 | {
"code": "class Solution {\npublic:\n int countDays(int days, vector<vector<int>>& schedule) {\n map<int, int> meetings;\n for (auto& meet : schedule) {\n meetings[meet[0]] += 1;\n meetings[meet[1] + 1] -= 1;\n }\n int meet_count=0;\n for(auto it=meetings.b... |
3,430 | <p>You are given a positive integer <code>days</code> representing the total number of days an employee is available for work (starting from day 1). You are also given a 2D array <code>meetings</code> of size <code>n</code> where, <code>meetings[i] = [start_i, end_i]</code> represents the starting and ending days of me... | 3 | {
"code": "class Solution {\npublic:\n int countDays(int days, vector<vector<int>>& meetings) {\n map<int,int> md;\n for(vector<int> &m:meetings)\n {\n md[m[0]]+=1;\n md[m[1]+1]-=1;\n }\n int ans=0,lasti=1,cnt=0;\n for(auto [idx,diff]:md)\n {\n... |
3,430 | <p>You are given a positive integer <code>days</code> representing the total number of days an employee is available for work (starting from day 1). You are also given a 2D array <code>meetings</code> of size <code>n</code> where, <code>meetings[i] = [start_i, end_i]</code> represents the starting and ending days of me... | 3 | {
"code": "class Solution {\npublic:\n int countDays(int days, vector<vector<int>>& meetings) {\n map<int, int> mp;\n int n = meetings.size();\n for(int i=0; i<n; i++) {\n mp[meetings[i][0]] += 1;\n mp[meetings[i][1]+1] -= 1;\n }\n \n vector<int> pref... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 0 | {
"code": "class Solution {\npublic:\n string clearStars(string &s)\n {\n vector<vector<int>> pos(26,vector<int>(0));\n for(int i=0;i<s.length();i++)\n {\n if(s[i]!='*')\n pos[s[i]-'a'].push_back(i);\n \n \n if(s[i]=='*')\n ... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 0 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n if (s.find(\"*\") == string::npos)\n return s;\n\n string ans;\n vector<vector<int>> bucket(26, vector<int>(0));\n\n for (size_t charIndex = 0; charIndex < s.length(); ++charIndex) {\n if (s[cha... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 0 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n int n = s.size(), m = 0;\n vector<int> idx[26];\n for (int i = 0, j = 0; j < n; ++j) {\n if (s[j] == '*') {\n ++m;\n for (int i = 0; i < 26; ++i)\n if (idx[i].empt... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 0 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n vector<vector<int>>dp(26);\n int n = s.size();\n int i;\n for(i=0;i<n;i++){\n if(s[i]!='*'){\n dp[s[i]-'a'].push_back(i);\n }\n else{\n for(int j=0; j<26... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 0 | {
"code": "class Solution {\npublic:\n typedef pair<int, int> pii;\n struct cmp {\n bool operator() (const pii& p1, const pii& p2) {\n return p1.first != p2.first ? p1.first > p2.first : p1.second < p2.second;\n }\n };\n string clearStars(string s) {\n priority_queue<char, ... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 0 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n int n = s.size();\n map<char,vector<int>> mp;\n\n for(int i=0;i<n;i++){\n if(s[i]!='*') mp[s[i]].push_back(i);\n else{\n for(char it = 'a'; it<='z';it++){\n if(mp[it].size()){\n... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 1 | {
"code": "class Solution {\npublic:\n\n class IndexComparator {\n public:\n explicit IndexComparator(const string& str) : string_(str) {}\n \n bool operator()(int index1, int index2) const {\n if(string_[index1]==string_[index2]){\n return index1<index2;\n ... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 1 | {
"code": "class Compare {\npublic:\n bool operator()(pair<char, int>& below, pair<char, int>& above)\n {\n if (below.first > above.first) {\n return true;\n }\n else if (below.first == above.first\n && below.second < above.second) {\n return true;\n ... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 1 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n auto cmp = [](const std::pair<char, int>& a, const std::pair<char, int>& b) {\n if (a.first == b.first)\n return a.second < b.second; // For the same character, sort by descending int\n return a.firs... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 1 | {
"code": "class Solution {\npublic:\n struct node {\n char ch;\n int idx;\n };\n \n struct compare {\n bool operator()(const node &a, const node &b) {\n if (a.ch == b.ch) return a.idx < b.idx; // max heap\n return a.ch > b.ch; // min heap\n }\n };\n ... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 2 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n unordered_map<char,int>mp;\n int n = s.size();\n vector<int>v(n+1,0);\n for(int i=0; i<n; i++){\n if(s[i]=='*'){\n v[i+1] = -1;\n for(char x='a'; x<='z'; x++){\n ... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 2 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n priority_queue<pair<int, int>> pq;\n string temp = \"\";\n for (int i = 0; i < s.length(); i++) {\n if (s[i] != '*') {\n pq.push({-(int)s[i], i});\n } else {\n pq.pop();\n... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 2 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n vector<int> mp[26];\n vector<int> include(s.size(), 1);\n for(int i = 0; i < s.size(); i++) {\n if(s[i] == '*') {\n for(int j = 0; j < 26; j++) {\n if(mp[j].size() > 0) {\n ... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 2 | {
"code": "class Solution {\npublic:\n string clearStars(string s){\n int n = s.size();\n vector<vector<int>> buckets(26);\n vector<int> removed(n , 0);\n for(int i = 0 ; i < n ; i++){\n if(s[i] == '*'){\n removed[i] = 1;\n for(int j = 0 ; j < 26... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 2 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n map <char, vector <int>>m ;\n // int lowest = -1 ;\n vector <int> vis (s.size () , 0);\n for (int i = 0 ;i < s.size () ;i++){\n if (s[i]!='*'){m[s[i]].push_back(i);}\n else {\n c... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 2 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n vector<int>v[26];\n int n = s.size();\n string ans = \"\";\n vector<int>t;\n for(int i=0;i<n;i++)\n {\n if(s[i]!='*')\n {\n v[s[i]-'a'].push_back(i);\n }\... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 2 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n int k = 0;\n priority_queue<std::pair<int, int>> mh;\n for(int i = s.size()-1 ; i>=0 ; i--)\n {\n if(s[i] == '*') k++;\n else\n {\n mh.push({s[i]-'a',s.size()-1-i});\n ... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 2 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n int n = s.length();\n \n priority_queue<pair<char, int>> pq;\n \n vector<char> ans(n, '.');\n \n int idx = 0;\n int cnt = 0;\n for(int i = n-1;i >= 0;i--) {\n if(s[i] == ... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 2 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n int n= s.size();\n // make store every character index in stack\n vector<stack<int>> arr(26);\n vector<int> map(n+1,0);\n for(int i=0;i<n;i++)\n {\n if(s[i]!='*')\n {\n ... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 2 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n int n = s.length();\n vector<stack<int>>v(26);\n vector<int>del(n,0);\n for(int i = 0;i < n;i++){\n if(s[i] != '*'){\n //cout << s[i] << endl;\n //cout << s[i] -'a' << endl;\n... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 2 | {
"code": "class Solution {\npublic:\n struct cmp{\n bool operator()(pair<char,int> &a, pair<char,int> &b)\n {\n if(a.first < b.first)\n return false;\n if(a.first == b.first)\n {\n return a.second < b.second;\n }\n return true;\n }\n };\n string clearS... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 2 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n vector<stack<int>> temp(26);\n vector<int> del;\n for(int i=0;i<s.length();i++){\n if(s[i]!='*') temp[s[i]-'a'].push(i);\n else {\n for(int j=0;j<26;j++){\n if(temp[j].size()){\... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 2 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n vector<vector<int>> idx(26);\n vector<int> remove;\n for(int i = 0; i < s.size(); i++)\n {\n if( s[i] == '*')\n {\n remove.push_back(i);\n for(int i = 0; i <26; i++... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 2 | {
"code": "class Solution {\npublic:\n // Custom comparator to prioritize lexicographical order\n struct Cmp {\n bool operator()(const pair<char, int>& a, const pair<char, int>& b) const {\n if (a.first != b.first) {\n return a.first > b.first; // Lexicographically smaller chara... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 2 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n priority_queue<pair<char,int>, vector<pair<char,int>>, greater<pair<char,int>> > pq;\n queue<int> q;\n int n=s.length();\n vector<int> dump;\n int i=0;\n while(i<n && s[i]=='*'){\n dump.push_back(i);\n ... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 2 | {
"code": "class Solution {\npublic:\n typedef pair<char,int> PAIR;\n\n class Compare {\n public:\n bool operator()(PAIR a, PAIR b){\n if (a.first == b.first) return a.second > b.second;\n return a.first < b.first;\n }\n };\n\n string clearStars(string s) {\n ... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 2 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n int n = s.size();\n map<char, vector<int>> mp;\n set<char> st;\n \n vector<int> v(n, 1);\n st.insert(s[0]);\n mp[s[0]].push_back(0);\n \n for(int i=1; i<n; i++) {\n if(s[... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 2 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n string ans = \"\";\n unordered_map<char, vector<int>> m;\n unordered_set<int> indices;\n bool found = false;\n for (int i = 0; i < s.size(); ++i)\n {\n if (s[i] != '*')\n {\n ... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 2 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n int n = s.size();\n vector<bool> bdel(n, false);\n\n priority_queue<vector<int>> mq;\n\n string ans;\n\n for (int i = 0; i < n; i++) {\n if (s[i] == '*') {\n bdel[i] = true;\n ... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 2 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n unordered_map<int,vector<int>> m;\n for(int i=0;i<s.size();i++){\n if(s[i]=='*'){\n for(int i=0;i<26;i++){\n if(m.find(i)!=m.end()){\n int a=m[i][m[i].size()-1];\n... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 2 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n unordered_map<char,vector<int>>mapping;\n string ans;\n for(int i=0;i<s.size();i++){\n if(s[i]=='*'){\n for(int j=0;j<26;j++){\n if(mapping.find('a'+j)!=mapping.end()){\n ... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 2 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n map<char, priority_queue <int>> mp;\n int n = s.size();\n\n for(int i = 0; i < n; i++) {\n if(s[i] != '*') {\n mp[s[i]].push(i);\n } else {\n while(!mp.empty() && mp.begin... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 2 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n std::list<char> str;\n std::vector<std::vector<list<char>::iterator>> posMap(26);\n\n for (const auto& c : s) {\n if (c == '*') {\n for (int i = 0; i < 26; ++i) {\n if (posMap[i]... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 2 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n std::list<char> str;\n std::vector<std::vector<list<char>::iterator>> posMap(26);\n\n for (const auto& c : s) {\n if (c == '*') {\n for (int i = 0; i < 26; ++i) {\n if (posMap[i]... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 2 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n std::list<char> str;\n std::vector<std::vector<list<char>::iterator>> posMap(26);\n\n for (const auto& c : s) {\n if (c == '*') {\n for (int i = 0; i < 26; ++i) {\n if (posMap[i]... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 2 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n std::list<char> str;\n std::vector<std::vector<list<char>::iterator>> posMap(26);\n\n for (const auto& c : s) {\n if (c == '*') {\n for (int i = 0; i < 26; ++i) {\n if (posMap[i]... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 2 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n std::list<char> str;\n std::vector<std::vector<list<char>::iterator>> posMap(26);\n\n for (const auto& c : s) {\n if (c == '*') {\n for (int i = 0; i < 26; ++i) {\n if (posMap[i]... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 2 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n std::list<char> str;\n std::vector<std::vector<list<char>::iterator>> posMap(26);\n\n for (const auto& c : s) {\n if (c == '*') {\n for (int i = 0; i < 26; ++i) {\n if (posMap[i]... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 2 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n unordered_map<int , vector<int>> mp;\n unordered_set<int> indices;\n int n = s.size();\n for(int i=0; i<n; i++){\n if (s[i]=='*'){\n for(int j=0; j<26; j++){\n if(mp[j].si... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 2 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n unordered_map<int,int>visited;\n map<char,vector<int>>mp;\n priority_queue <char, vector<char>, greater<char>> pq;\n for(int i=0;i<s.size();i++){\n if(s[i]=='*'){\n visited[mp[pq.top()].back... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 2 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n int n=s.size();\n stack<int> st;\n unordered_map<int,vector<int>> mp;\n unordered_map<int,int> del;\n vector<int> v(26,0);\n for(int i=0;i<n;i++){\n if(s[i]!='*'){\n mp[s[i]-'a... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 2 | {
"code": "class Solution {\npublic:\n struct cmp{\n bool operator()(pair<char,int> a, pair<char,int> b){\n if(a.first == b.first)\n return a.second < b.second;\n else\n return a.first > b.first;\n }\n };\n string clearStars(string s) {\n ... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 2 | {
"code": "class Solution {\npublic:\n struct cmp{\n bool operator()(pair<char,int>&a,pair<char,int>&b){\n if(a.first==b.first) return a.second<b.second;\n return a.first>b.first;\n }\n };\n string clearStars(string s) {\n priority_queue<pair<char,int>,vector<pair<c... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 2 | {
"code": "class Solution {\npublic:\nstruct Compare {\n bool operator()(const pair<char, int>& p1, const pair<char, int>& p2) {\n if (p1.first == p2.first) {\n // If first characters are the same, sort by second element in descending order\n return p1.second < p2.second;\n }\n ... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 2 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n int n = s.length();\n unordered_set<int> removedIdx;\n \n priority_queue<pair<int, int>> pq; \n for (int i = 0; i < n; i ++) {\n if (s[i] == '*') {\n removedIdx.insert(pq.top().second... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 3 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n vector<vector<int>>ok(26);\n set<int>st;\n for(int i = 0;i<s.size();i++){\n if(s[i]=='*'){\n for(int j=0;j<26;j++){\n if(ok[j].size()>0){\n st.insert(ok[j].... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 3 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\nint n=s.size();\n set<int>st;\nvector<vector<int>>mp(26);\n for(int i=0;i<s.size();i++){\n if(s[i]!='*') mp[s[i]-'a'].push_back(i);\n else{\n char ref='a';\n for(int i=0;i<26;i++){... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 3 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n vector<vector<int>>ok(26);\n set<int>st;\n for(int i = 0;i<s.size();i++){\n if(s[i]=='*'){\n for(int j=0;j<26;j++){\n if(ok[j].size()>0){\n st.insert(ok[j]... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 3 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n vector<vector<int > > hash(26);\n set<int > remove;\n\n for(int i = 0; i < s.size(); i++) {\n if(s[i] == '*')\n {\n for(int j = 0; j < 26; j++)\n {\n if... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 3 | {
"code": "class Solution { \npublic:\n string clearStars(string s) {\n map<char,vector<int>> mp;\n for(int i=0;i<s.size();i++){\n if(s[i]=='*'){\n int index = mp.begin()->second.back();\n mp.begin()->second.pop_back();\n s[index]='*';\n ... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 3 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n string output = \"\";\n map<char, vector<int>> lastseen; // < char, lastseen index >\n \n int l = 0; int r = 0;\n \n while(r < s.length()){\n if(s[r] == '*'){\n s[r] = '$';\n ... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 3 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n int n=s.size();\n map<char,vector<int>> mcv;\n for(int i=0;i<n;++i)\n {\n if(s[i]=='*')\n {\n auto it=mcv.begin();\n s[it->second.back()]='*';\n it->... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 3 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n int n=s.length();\n int mini=-1,ind=-1;\n map<char,vector<int>> mp;\n vector<int> v(26);\n\n for(int i=0;i<n;i++)\n {\n if(s[i]=='*')\n {\n if(mp.size())\n ... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 3 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n int n=s.length();\n int mini=-1,ind=-1;\n map<char,vector<int>> mp;\n vector<int> v(26);\n\n for(int i=0;i<n;i++)\n {\n if(s[i]=='*')\n {\n if(mp.size())\n ... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 3 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n map<int,vector<int>> mp;\n for(int i=0;i<s.size();i++)\n {\n if(s[i]!='*') {mp[s[i]-'a'].push_back(i); continue;}\n if(mp.begin()->second.size()==1) {s[mp.begin()->second[0]]='.';mp.erase(mp.begin());}... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 3 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n \n map<char,vector<int>> char_idx_map;\n vector<bool> del(s.size(),false);\n\n for(int i=0;i<s.size();i++)\n {\n if(s[i] == '*')\n {\n vector<int>& min_ch_idxs = char_idx_m... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 3 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n map<char, vector<int>> mp;\n int n = s.length();\n \n for(int i = 0; i < n; i++) {\n if(s[i] == '*') {\n auto it = mp.begin();\n if(it == mp.end()) {\n cont... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 3 | {
"code": "class cmp{\n public:\n bool operator()(pair<char,int> a , pair<char,int> b){\n if(a.first==b.first){\n return a.second<b.second;\n }\n return a.first>b.first;\n }\n\n};\nclass Solution {\npublic:\n string clearStars(string s) {\n\n priority_queue<pair<char... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 3 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n int n=s.size();\n string ans=\"\",an=\"\";\n map<char,vector<int>>mp;\n for(int i=0;i<n;i++)\n {\n if(s[i]=='*')\n {\n auto it=mp.begin();\n ans[(*it).second... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 3 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n set<pair<char,int>> st;\n string res;\n for(int i=0;i<s.length();i++)\n {\n if(s[i]=='*')\n {\n pair<char,int>p =*st.begin();\n int del=-(p.second);\n s[del-1]='*';\n s... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 3 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n set<pair<char,int>> st;\n string res;\n for(int i=0;i<s.length();i++)\n {\n if(s[i]=='*')\n {\n pair<char,int>p =*st.begin();\n int del=-(p.second);\n s[del-1]='*';\n s... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 3 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n int n=s.length();\n map<char,priority_queue<int>>m;\n for(int i=0;i<n;i++)\n {\n if(s[i]!='*') m[s[i]].push(i);\n else\n {\n auto x=m.begin();\n s[x->sec... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 3 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n map<char, priority_queue<int>>mp;\n for(int i = 0; i < s.length(); i++)\n {\n if(s[i] == '*')\n {\n auto it = mp.begin();\n s[it->second.top()] = '*';\n it-... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 3 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n map<char,vector<int>> mp;\n int n= s.size();\n vector<int> v(n,0);\n for(int i =0 ;i <s.size(); i++){\n if(s[i]!='*'){\n mp[s[i]].push_back(i);\n }\n else{\n ... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 3 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n map<char, vector<int>> mp;\n int n = s.size();\n vector<int> blocked(n + 1, 0);\n for(int i = 0; i < s.size(); i ++) {\n if(s[i] == '*') {\n blocked[i] = 1;\n if(mp.size()) {\... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 3 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n int n = s.size();\n map<char,vector<int>> mp;\n\n vector<int> del;\n for(int i = 0 ; i < n ; i++){\n if(s[i] != '*') mp[s[i]].push_back(i);\n else{\n auto it = mp.begin();\n ... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 3 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n int n = s.length();\n multiset<char> ms;\n unordered_map<char,vector<int>> hashmap;\n for(int i=0;i<n;i++) {\n char c = s[i];\n if(c == '*') {\n if(!ms.empty()) {\n ... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 3 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n unordered_map<char,set<int>> pos;\n unordered_map<char,int> mp;\n\n for(int i=0;i<s.size();i++){\n if(s[i]!='*'){\n mp[s[i]]++;\n pos[s[i]].insert(i);\n }\n els... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 3 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n int n = s.size();\n vector<int> vs(n, 0);\n set<pair<char, int>> st;\n for(int i = 0; i < n; i++) {\n if(s[i] == '*') {\n if(!st.empty()) {\n pair<char, int> p = *st.begin... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 3 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n set<pair<int,int>> st;\n int n=s.size();\n vector<int> mi(s.size(),0);\n for(int i=0;i<s.size();i++){\n if(s[i]=='*'){\n if(!st.empty()){\n pair<int,int> cur=*st.begin();\... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 3 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n int n = s.size();\n vector<int> v(n,0);\n map<int,priority_queue<int>> mp;\n for(int i=0; i<n; i++){\n if(s[i] == '*'){\n v[i] = 1;\n auto x = mp.begin();\n v[(... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 3 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n int n = s.size();\n vector<int> v(n,0);\n map<int,priority_queue<int>> mp;\n string res = \"\";\n for(int i=0; i<n; i++){\n if(s[i] != '*'){\n mp[s[i]-'a'].push(i);\n c... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 3 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n vector<set<int>> alphaIndicesMap(26);\n int iter = 0, n = s.length();\n vector<int> arrIndicesAsterisk;\n for(char& c : s)\n {\n if(isalpha(c)) alphaIndicesMap[c-'a'].insert(iter++);\n el... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 3 | {
"code": "class Solution {\npublic:\n string clearStars(string s) {\n stack<int>st[26];\n map<int,int>has;\n for (int i=0; i<s.length(); i++) {\n if (s[i]!='*') {\n st[s[i] - 'a'].push(i);\n }\n else {\n bool flag = 0;\n ... |
3,445 | <p>You are given a string <code>s</code>. It may contain any number of <code>'*'</code> characters. Your task is to remove all <code>'*'</code> characters.</p>
<p>While there is a <code>'*'</code>, do the following operation:</p>
<ul>
<li>Delete the leftmost <code>'*'</code> and the <... | 3 | {
"code": "class Comparator {\n public:\n bool operator()(const vector<int>&a, const vector<int>&b){\n return a[0] == b[0] ? a[1] < b[1] : a[0] > b[0];\n }\n};\nclass Solution {\npublic:\n string clearStars(string s) {\n int n = s.length();\n vector<bool>toDiscard(n, false);\n ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.