id int64 1 3.58k | problem_description stringlengths 516 21.8k | instruction int64 0 3 | solution_c dict |
|---|---|---|---|
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 0 | {
"code": "class Solution {\npublic:\n // a 1, a 2, a 3, a 4, a 5, b 1\n vector<string> findHighAccessEmployees(vector<vector<string>>& vec) {\n if (vec.size() < 3) {\n return vector<string>();\n }\n sort(vec.begin(), vec.end());\n unordered_set<string> ans;\n for (... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 0 | {
"code": "class Solution {\npublic:\n vector<string> findHighAccessEmployees(vector<vector<string>>& v) {\n vector<string> ans;\n\n // Helper function to convert \"HHMM\" to minutes since midnight\n auto toMinutes = [](const string& time) {\n int hours = stoi(time.substr(0, 2));\n ... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 0 | {
"code": "class Solution {\npublic:\n int gap(string t1,string t2){\n int t2m=stoi(t2.substr(0,2))*60+stoi(t2.substr(2,2));\n int t1m=stoi(t1.substr(0,2))*60+stoi(t1.substr(2,2));\n return abs(t1m-t2m);\n }\n vector<string> findHighAccessEmployees(vector<vector<string>>& arr) {\n ... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 0 | {
"code": "class Solution {\npublic:\n struct Stats {\n bool high{};\n array<int, 2> t{-1, -1};\n };\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) {\n sort(begin(access_times), end(access_times), [](const auto& lhs, const auto& rhs) { return lhs[1] < rhs[... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 0 | {
"code": "class Solution {\npublic:\n vector<string>\n findHighAccessEmployees(vector<vector<string>>& access_times) {\n map<string, vector<int>> mp;\n\n for (auto& it : access_times) {\n int time = stoi(it[1]);\n mp[it[0]].push_back(time);\n }\n\n for (auto& i... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 0 | {
"code": "class Solution {\npublic:\n int timeToInt(const string& time) {\n return stoi(time.substr(0, 2)) * 100 + stoi(time.substr(2, 2));\n}\n\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) {\n map<string, vector<int>> access_map;\n \n // Step 1: Group access t... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 0 | {
"code": "// Solution1:\n// hashmap + sort + sliding window\n// O(M*logM+M*N*logN+M*N*N)\n\nclass Solution {\npublic:\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) {\n unordered_map<string, vector<int>> times;\n\n // transform the time format\n for (auto& empT... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 0 | {
"code": "// Notation: M is the number of unique person, N is the average length of time sequence of a person\n// Solution1: brute force, first sort, then use sliding window to check the high-accessibility, Time: O(PlogP+M*N*10), Space: O(1)\n// we can directly use std::sort in vector<vector<string>>, it works\n\n//... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 0 | {
"code": "class Solution {\npublic:\n bool check(vector<string> V) {\n if(V.size() < 3)\n return false;\n for(int i=0; i<V.size()-2;i++){\n int a = stoi(V[i]);\n int b = stoi(V[i+2]);\n if(b-a<100) return true;\n }\n return false;\n }\n\n v... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 1 | {
"code": "class Solution {\npublic:\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) {\n // intervals for each person\n unordered_map<string, vector<int>> intervals;\n vector<string> names;\n\n for (auto& times : access_times) {\n // convert eve... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 1 | {
"code": "class Solution {\npublic:\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) {\n sort(access_times.begin(), access_times.end(), [](auto const & a, auto const & b){\n assert(a.size() == 2);\n assert(b.size() == 2);\n return stoi(a.back()... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 1 | {
"code": "#include <vector>\n#include <string>\n#include <unordered_map>\n#include <algorithm>\n\nusing namespace std;\n\nclass Solution {\npublic:\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) {\n unordered_map<string, vector<int>> employee_times;\n vector<string> r... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 1 | {
"code": "class Solution {\npublic:\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) {\n unordered_map<string,vector<int>>mp;\n for(int i=0;i<access_times.size();i++){\n int num=stoi(access_times[i][1]);\n mp[access_times[i][0]].push_back(num);\n ... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 1 | {
"code": "class Solution {\npublic:\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) {\n unordered_map<string,vector<int>>mp;\n for(int i=0;i<access_times.size();i++){\n int num=stoi(access_times[i][1]);\n mp[access_times[i][0]].push_back(num);\n ... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 1 | {
"code": "class Solution \n{\npublic:\n vector<string> findHighAccessEmployees(vector<vector<string>>&v) \n {\n unordered_map<string,vector<int>>dp;\n unordered_map<string,int>mp;\n for(int i=0;i<v.size();i++)\n {\n string t=v[i][0];\n int t1=v[i][1][0]-'0';\n ... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 1 | {
"code": "class Solution {\npublic:\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) {\n int n = access_times.size();\n unordered_map<string, vector<int>> employess_access_times;\n\n for(int i = 0; i < n; i++){\n int hours = stoi(access_times[i][1].sub... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 1 | {
"code": "class Solution {\npublic:\n int timeToInt(const string& time) {\n return stoi(time.substr(0, 2)) * 100 + stoi(time.substr(2, 2));\n}\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) {\n map<string, vector<int>>access_map;\n\n for(auto& it:access_times)\n... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 1 | {
"code": "class Solution {\npublic:\n int calc(string s) {\n return stoi(s.substr(0, 2)) * 60 + stoi(s.substr(2));\n }\n\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) {\n vector<string> ans;\n map<string, vector<int>> mp;\n for (auto &e : access_t... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 1 | {
"code": "#include <vector>\n#include <string>\n#include <unordered_map>\n#include <algorithm>\n\nclass Solution {\npublic:\n std::vector<std::string> findHighAccessEmployees(std::vector<std::vector<std::string>>& access_times) {\n std::unordered_map<std::string, std::vector<int>> mp;\n\n // Convert... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 1 | {
"code": "class Solution {\npublic:\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) {\n sort(access_times.begin(), access_times.end());\n set<string>s;\n vector<string>ans;\n int n=access_times.size();\n\n for(auto it : access_times){\n ... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 1 | {
"code": "class Solution {\npublic:\n\n bool operator()(vector<string>& s1, vector<string>& s2) {\n int val1 = stoi(s1.at(1));\n int val2 = stoi(s2.at(1));\n\n return val1 < val2;\n }\n\n int convertToMins(string s) {\n int hrs = stoi(s.substr(0, 2));\n int mins = stoi(s.s... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 1 | {
"code": "class Solution {\npublic:\n bool cmp_access_times(string &a, string &b) {\n bool maybe_an_hour = false;\n if (a[0] != b[0]) {\n if (b[0] - a[0] == 1 && a[1] == '9' && b[1] == '0') {\n maybe_an_hour = true;\n } else {\n return false;\n }\n }\n\n if (a[1] == b[1]) {\... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 1 | {
"code": "class Solution {\npublic:\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) {\n unordered_map<string,vector<int>>mpp;\n for(int i=0;i<access_times.size();i++)\n {\n mpp[access_times[i][0]].push_back(stoi(access_times[i][1]));\n }\n ... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 1 | {
"code": "class Solution {\npublic:\n vector<string> findHighAccessEmployees(vector<vector<string>>& ac) {\n int n=ac.size();\n unordered_map<string,vector<int>> mp;\n for(int i=0;i<n;i++){\n mp[ac[i][0]].push_back((ac[i][1][0]-'0')*1000+(ac[i][1][1]-'0')*100+(ac[i][1][2]-'0')*10+(... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 1 | {
"code": "class Solution {\npublic:\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) {\n int n=access_times.size();\n unordered_map<string,vector<int>>mp;\n for(int i=0;i<n;i++){\n mp[access_times[i][0]].push_back(stoi(access_times[i][1]));\n }\... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 1 | {
"code": "class Solution {\npublic:\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) {\n unordered_map<string, vector<string>> map;\n for(auto &vec: access_times){\n map[vec[0]].push_back(vec[1]);\n }\n vector<string> emps;\n for(auto &[n... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 2 | {
"code": "class Solution {\nprivate:\n static bool compare(const vector<string>& a, const vector<string>& b) {\n if (a[0] != b[0]) return a[0] < b[0];\n return a[1] < b[1];\n }\n\n int timeDiff(const string& t1, const string& t2) {\n int time1 = stoi(t1);\n int time2 = stoi(t2);\... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 2 | {
"code": "class Solution {\npublic:\n int time(string& a) {\n return stoi(a.substr(0, 2)) * 60 + stoi(a.substr(2));\n }\n int df(string& a, string& b) {\n // cout << a << ' ' << b << ' ' << (time(b)-time(a)) << endl;\n return time(b) - time(a);\n }\n vector<string> findHighAccessE... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 2 | {
"code": "class Solution {\npublic:\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) {\n unordered_map<string, vector<string>> times;\n for(auto const& line : access_times){\n times[line.front()].push_back(line.back());\n }\n vector<string> ret;... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 2 | {
"code": "class Solution {\npublic:\n vector<string> findHighAccessEmployees(vector<vector<string>>& a) {\n sort(a.begin(), a.end());\n set<string> ans;\n map<string, vector<string>> m;\n for (int i = 0; i < a.size(); i++) {\n m[a[i][0]].push_back(a[i][1]);\n }\n ... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 2 | {
"code": "class Solution {\npublic:\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) {\n map<string, vector<string>> mpp; \n \n for (const auto& entry : access_times) {\n string employee = entry[0];\n string time = entry[1];\n mpp... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 2 | {
"code": "#include <vector>\n#include <string>\n#include <unordered_map>\n#include <algorithm>\n\nusing namespace std;\n\nclass Solution \n{\nprivate:\n bool check(vector<string>& a)\n {\n int n = a.size();\n vector<int> times;\n\n for (const string& time : a)\n {\n int h... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 2 | {
"code": "class Solution {\npublic:\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) {\n std::unordered_map<std::string, std::vector<std::string>> mp;\n for (const auto& time : access_times) \n mp[time[0]].push_back(time[1]);\n\n std::vector<std::strin... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 2 | {
"code": "#include <vector>\n#include <string>\n#include <unordered_map>\n#include <unordered_set>\n#include <algorithm>\n\nusing namespace std;\n\nclass Solution {\npublic:\n static bool comp(const vector<string> &s1, const vector<string> &s2) {\n return s1[1] < s2[1];\n }\n\n bool isWithinOneHour(c... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 2 | {
"code": "class Solution {\npublic:\n int diff(string s1,string s2){\n return abs(stoi(s1)-stoi(s2));\n }\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) {\n unordered_map<string,vector<string>>rec;\n for(int i=0;i<access_times.size();i++){\n re... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 2 | {
"code": "class Solution {\npublic:\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) {\n int n = access_times.size();\n vector<string>ans;\n unordered_map<string,vector<int>>mpp;\n unordered_map<string,int>digits{{\"0\",0},{\"1\",1},{\"2\",2},{\"3\",3},{\"... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 2 | {
"code": "class Solution {\npublic:\nint calc(string s){\n int k=0,time=0;\n if(s[k]=='0') k++;\n if(s[k]=='0') k++;\n if(s[k]=='0') k++;if(s[k]=='0') k++;\n if(k>=4) return time;\n else{\n time=stoi(s.substr(k));\n return time;\n }\n}\nbool func(int i,vector<int>& v){\n if(abs(... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 2 | {
"code": "class Solution {\npublic:\n // Function to find high-access employees based on access times.\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) {\n // Create a map to store access times for each employee.\n map<string, vector<int>> when;\n\n // Populat... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 2 | {
"code": "\n\nclass Solution {\npublic:\n // Function to find high-access employees based on access times.\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) {\n // Create a map to store access times for each employee.\n map<string, vector<int>> when;\n\n // Pop... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 2 | {
"code": "class Solution {\npublic:\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) {\n\n unordered_map<string, vector<int>> aTimes;\n for (auto x : access_times) {\n string& aTimeInStr = x[1];\n int hours = atoi(aTimeInStr.substr(0, 2).c_str());\... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 2 | {
"code": "class Solution {\npublic:\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) {\n unordered_map<string, vector<int>> employeeToTimes;\n vector<string> ret;\n for(auto strs: access_times){\n string employee = strs[0], time = strs[1];\n ... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 2 | {
"code": "class Solution {\npublic:\n\n int convert(string s){\n string temp (s.begin(),s.begin()+2);\n int hours= stoi(temp);\n string temp2 (s.begin()+2,s.begin()+4);\n int min= stoi(temp2);\n min += hours*60;\n return min;\n }\n\n vector<string> findHighAccessEmp... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 2 | {
"code": "class Solution {\npublic:\n\n int convert(string s){\n string temp (s.begin(),s.begin()+2);\n int hours= stoi(temp);\n string temp2 (s.begin()+2,s.begin()+4);\n int min= stoi(temp2);\n min += hours*60;\n return min;\n }\n\n vector<string> findHighAccessEmp... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 2 | {
"code": "class Solution {\npublic:\n int getTime(string time) {\n int intTime = stoi(time);\n return (intTime%100 * 60) + ((intTime/100)%100)*3600 ;\n }\n void print(string name, vector<int> times) {\n cout<<\"Debug \"<<name<<\" -> \"; \n for(auto i: times)\n cout<<i<... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 2 | {
"code": "class Solution {\npublic:\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) {\n vector<string> ans;\n unordered_map<string, vector<string>> M;\n for(int i = 0; i < access_times.size(); i++){\n M[access_times[i][0]].push_back(access_times[i][1]... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 2 | {
"code": "class Solution {\npublic:\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) {\n unordered_map<string, vector<int>> mp;\n for(auto vec : access_times) {\n string person = vec[0];\n int time = stoi(vec[1].substr(0, 2)) * 60 + stoi(vec[1].sub... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 2 | {
"code": "class Solution {\npublic:\n vector<string> findHighAccessEmployees(vector<vector<string>>& at) {\n vector<string> res;\n sort(at.begin(),at.end());\n unordered_map<string,vector<int>> m;\n for (auto x:at){\n if (m.find(x[0])==m.end()){\n m[x[0]]= {};... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 2 | {
"code": "class Solution {\npublic:\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) {\n map<string, vector<int>> mp; \n for(auto it: access_times){\n mp[it[0]].push_back(stoi(it[1])); \n }\n //0002 1410 1444 1508 \n vector<string> ans; \... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 2 | {
"code": "class Time {\npublic:\n int min;\n int hour;\n\n Time(int hour, int min)\n {\n this->hour = hour;\n this->min = min;\n }\n};\n\nclass TimeComparator {\npublic:\n bool operator()(const Time& t1, const Time& t2)\n {\n if(t1.hour != t2.hour)\n {\n re... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 2 | {
"code": "class Solution {\n int getMinutes(string time){\n int hours = stoi(time.substr(0, 2));\n int minutes = stoi(time.substr(2));\n return hours * 60 + minutes;\n }\npublic:\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) {\n unordered_map<stri... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 2 | {
"code": "class Solution {\npublic:\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) {\n int a = 0;\n // string s = \"011\";\n // int num = stoi(s);\n // // a+=int(s[0]);\n // cout<<num<<endl;\n // return {};\n vector<string>res;\n ... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 2 | {
"code": "class Solution {\npublic:\n int min_calculator(string str) {\n string hr = str.substr(0, 2);\n string mini = str.substr(2, 2);\n int min = stoi(hr) * 60 + stoi(mini);\n\n return min;\n }\n\n vector<string>\n findHighAccessEmployees(vector<vector<string>>& access_time... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 2 | {
"code": "class Solution {\npublic:\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) {\n vector<pair<string,int>> v;\n for(auto x:access_times)\n {\n string s=x[1];\n int time=(s[0]-'0')*600+(s[1]-'0')*60+(s[2]-'0')*10+(s[3]-'0');\n ... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 3 | {
"code": "class Solution {\n //function for computing time\n int computeTime(string &t1, string &t2){\n int h1 = (t1[0] - '0')*10 + (t1[1] - '0');\n int h2 = (t2[0] - '0')*10 + (t2[1] - '0');\n int m1 = (t1[2] - '0')*10 + (t1[3] - '0');\n int m2 = (t2[2] - '0')*10 + (t2[3] - '0');\n... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 3 | {
"code": "class Solution {\npublic:\n\n \n bool check1(string s, string t, string p) {\n // Convert to minutes:\n int t1 = stoi(s.substr(0, 2)) * 60 + stoi(s.substr(2, 2));\n int t2 = stoi(t.substr(0, 2)) * 60 + stoi(t.substr(2, 2));\n int t3 = stoi(p.substr(0, 2)) * 60 + stoi(p.sub... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 3 | {
"code": "class Solution {\npublic:\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) {\n int n=access_times.size();\n unordered_map<string,vector<int>> mp;\n priority_queue<pair<int,string>,vector<pair<int,string>>,greater<pair<int,string>>> pq;\n unordere... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 3 | {
"code": "class Solution {\npublic:\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) {\n unordered_map<string,vector<string>>m;\n for(int i=0;i<access_times.size();i++)\n {\n m[access_times[i][0]].push_back(access_times[i][1]);\n }\n vect... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 3 | {
"code": "class Solution {\npublic:\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) {\n map<string,vector<string>>m;\n vector<string>out1;\n\n for(int i=0;i<access_times.size();i++){\n // int a=stoi(access_times[i][1]);\n m[access_times[i][... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 3 | {
"code": "class Solution {\npublic:\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) {\n map<string,vector<string>>m;\n vector<string>out1;\n\n for(int i=0;i<access_times.size();i++){\n // int a=stoi(access_times[i][1]);\n m[access_times[i][... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 3 | {
"code": "class Solution {\npublic:\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) {\n unordered_map<string, multiset<int>> employeeEntryMap;\n vector<string> result;\n\n for( auto access_time : access_times) {\n auto employee = employeeEntryMap.find... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 3 | {
"code": "class Solution {\npublic:\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) {\n unordered_map<string, multiset<int>> employeeEntryMap;\n vector<string> result;\n\n for( auto access_time : access_times) {\n auto employee = employeeEntryMap.find... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 3 | {
"code": "class Solution {\npublic:\n bool solve(int j,int k,vector<long>&t){\n if(j>k)return false;\n if(t[k]-t[j]>=60){\n return solve(j,k-1,t)||solve(j+1,k,t);\n }\n else{\n return k-j+1>=3;\n }\n }\n vector... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 3 | {
"code": "class Solution {\npublic:\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times){\n sort(access_times.begin(), access_times.end(), [](vector<string>& a, const vector<string>& b){\n if (a[0] == b[0])\n return a[1] < b[1];\n return a[0] <... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 3 | {
"code": "\n#pragma GCC optimize(\"Ofast,unroll-loops\") \nint speed_up = []{\n ios::sync_with_stdio(false);\n cin.tie(NULL);cout.tie(NULL);\n return 0;\n}();\nclass Solution {\npublic:\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times){\n sort(access_times.begin(), acc... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 3 | {
"code": "class Solution {\npublic:\n\n int computetime(string &t1, string &t2){\n int h1 = (t1[0] - '0')*10 + (t1[1] - '0');\n int h2 = (t2[0] - '0')*10 + (t2[1] - '0');\n int m1 = (t1[2] - '0')*10 + (t1[3] - '0');\n int m2 = (t2[2] - '0')*10 + (t2[3] - '0');\n\n if(h1 == h2) r... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 3 | {
"code": "// Solution1:\n// map + sort + sliding window ?\n// O(M*logM+M*N*logN+M*N*N)\n\nclass Solution {\npublic:\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) {\n unordered_map<string, vector<string>> mapper; \n for (auto name_to_time: access_times)\n mapper[n... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 3 | {
"code": "class Solution {\npublic:\n bool check(vector<string>&v){\n if(v.size()<3) return false;\n for(int i=0;i<v.size()-2;i++){\n int a=stoi(v[i]);\n int b=stoi(v[i+2]);\n if(b-a<100) return true;\n }\n return false;\n ... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 3 | {
"code": "class Solution {\npublic:\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) {\n unordered_map<string, vector<string>> mapper; \n for (auto name_to_time: access_times)\n mapper[name_to_time.front()].push_back(name_to_time.back());\n \n ... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 3 | {
"code": "class Solution {\npublic:\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) {\n unordered_map<string, multiset<int>> accessTime;\n\n for(auto t : access_times) {\n\n accessTime[t[0]].insert(60*stoi(t[1].substr(0,2))+stoi(t[1].substr(2)));\n }\... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 3 | {
"code": "class Solution {\npublic:\n bool static comp(string &s1, string &s2){\n int h1 = stoi(s1.substr(0,2));\n int m1 = stoi(s1.substr(2,2));\n \n int h2 = stoi(s2.substr(0,2));\n int m2 = stoi(s2.substr(2,2));\n \n if(h1 == h2) return m1 < m2;\n return ... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 3 | {
"code": "class Solution {\npublic:\nbool f(vector<string> temp){\n int n=temp.size();\n if(n<3)return false;\n int i=0;\n while(i<n){\n string hrs=temp[i].substr(0,2);\n string mins=temp[i].substr(2,2);\n string maxi=\"\";\n int a=stoi(hrs);\n if(a<=9){\n a... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 3 | {
"code": "class Solution {\npublic:\n // Check whehter it contains 3 times within one hour.\n bool check(vector<string> v) {\n if(v.size() < 3) return false;\n for(int i=0; i<v.size()-2; i++) {\n int a = stoi(v[i]);\n int b = stoi(v[i+2]);\n if(b-a<100) return tru... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 3 | {
"code": "class Solution {\npublic:\n // Check whehter it contains 3 times within one hour.\n bool check(vector<string> v) {\n if(v.size() < 3) return false;\n for(int i=0; i<v.size()-2; i++) {\n int a = stoi(v[i]);\n int b = stoi(v[i+2]);\n if(b-a<100) return tru... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 3 | {
"code": "class Solution {\npublic:\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) {\n map<string,vector<string>> mp;\n for(auto val: access_times){\n mp[val[0]].push_back(val[1]);\n }\n \n map<string,int> mp2;\n for(auto val : m... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 3 | {
"code": "class Solution {\npublic:\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) {\n map<string, vector<string>> times;\n for(auto time: access_times){\n times[time[0]].push_back(time[1]);\n }\n\n vector<string> ans;\n for(auto pair :... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 3 | {
"code": "class Solution {\npublic:\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) {\n \n unordered_map<string,vector<string>> m;\n for(auto i:access_times){\n m[i[0]].push_back(i[1]);\n }\n \n vector<string> ans;\n for(au... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 3 | {
"code": "class Solution {\npublic:\n static bool comp (string s1, string s2) {\n int h1 = stoi(s1.substr(0,2));\n int m1 = stoi(s1.substr(2,2));\n\n int h2 = stoi(s2.substr(0,2));\n int m2 = stoi(s2.substr(2,2));\n\n if(h1!=h2) return h1<h2;\n return m1<m2;\n } \n ... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 3 | {
"code": "class Solution {\npublic:\n int solve(vector <string> &v){\n int n=v.size();\n vector <int> v1(n);\n for(int i=0;i<v.size();i++){\n v1[i]=stoi(v[i]);\n }\n // for(int i=0;i<v.size();i++){\n // cout<<v[i]<<\" \";\n // }\n // cout<<endl;\n\n sort(v1.begin(),v1.end());\n ... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 3 | {
"code": "class Solution {\npublic:\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) {\n unordered_map<string, vector<int>> access;\n\n for (auto& it: access_times) {\n access[it[0]].push_back(stoi(it[1]));\n }\n\n vector<string> res;\n f... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 3 | {
"code": "class Solution {\npublic:\n int Convert(string& s) {\n auto a = stoi(s);\n return a / 100 * 60 + a % 100;\n }\n\n vector<string>\n findHighAccessEmployees(vector<vector<string>>& access_times) {\n\tsort(access_times.begin(), access_times.end(), [](auto& a, auto& b) { return a[1] <... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 3 | {
"code": "class Solution {\npublic:\n int t2m(const string& t)\n {\n int h = (t[0] - '0')*10 + (t[1]-'0');\n int m = (t[2] - '0')*10 + (t[3]-'0');\n\n return h*60 + m;\n }\n\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) {\n vector<string> resul... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 3 | {
"code": "class Solution {\npublic:\n\n\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) {\n vector<string> result;\n unordered_set<string> ur;\n\n unordered_map<string, priority_queue<int, vector<int>>> um;\n\n for(const auto& et : access_times)\n ... |
3,202 | <p>You are given a 2D <strong>0-indexed</strong> array of strings, <code>access_times</code>, with size <code>n</code>. For each <code>i</code> where <code>0 <= i <= n - 1</code>, <code>access_times[i][0]</code> represents the name of an employee, and <code>access_times[i][1]</code> represents the access time of ... | 3 | {
"code": "int speedUp = [] {\n std::ios::sync_with_stdio(0);\n std::cin.tie(0);\n return 0;\n}();\n\nclass Solution {\npublic:\n\n\n vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) {\n vector<string> result;\n unordered_set<string> ur;\n\n unordered_map<s... |
3,190 | <p>You are given two <strong>0-indexed</strong> integer arrays, <code>nums1</code> and <code>nums2</code>, both having length <code>n</code>.</p>
<p>You are allowed to perform a series of <strong>operations</strong> (<strong>possibly none</strong>).</p>
<p>In an operation, you select an index <code>i</code> in the ra... | 0 | {
"code": "class Solution {\npublic:\n int solve(vector<int>& nums1, vector<int>& nums2){\n int cnt=0;\n int n=nums1.size();\n for(int i=0;i<n-1;i++){\n if(nums1[i]<=nums1[n-1] && nums2[i]<=nums2[n-1]){\n continue;\n }\n if(nums2[i]<=nums1[n-1] &... |
3,190 | <p>You are given two <strong>0-indexed</strong> integer arrays, <code>nums1</code> and <code>nums2</code>, both having length <code>n</code>.</p>
<p>You are allowed to perform a series of <strong>operations</strong> (<strong>possibly none</strong>).</p>
<p>In an operation, you select an index <code>i</code> in the ra... | 0 | {
"code": "class Solution {\npublic:\n int minOperations(vector<int>& nums1, vector<int>& nums2) {\n int n = nums1.size(), m1 = 0, m2 =0, e = 0;\n int count = 0;\n for(int i = 0; i < n; i++) {\n if(nums1[i] == nums2[i] || max(nums1[i], nums2[i]) <= min(nums1[n-1], nums2[n-1])) {\n ... |
3,190 | <p>You are given two <strong>0-indexed</strong> integer arrays, <code>nums1</code> and <code>nums2</code>, both having length <code>n</code>.</p>
<p>You are allowed to perform a series of <strong>operations</strong> (<strong>possibly none</strong>).</p>
<p>In an operation, you select an index <code>i</code> in the ra... | 0 | {
"code": "class Solution {\npublic:\n int minOperations(vector<int>& a, vector<int>& b) {\n int m1=a.back(), m2=b.back(), nop=0;\n int ans = 0;\n for (int i=0; i+1<a.size(); ++i) {\n if (max(a[i], b[i])<=min(m1, m2)) ++nop;\n if (a[i] > m1 || b[i] > m2) {\n ... |
3,190 | <p>You are given two <strong>0-indexed</strong> integer arrays, <code>nums1</code> and <code>nums2</code>, both having length <code>n</code>.</p>
<p>You are allowed to perform a series of <strong>operations</strong> (<strong>possibly none</strong>).</p>
<p>In an operation, you select an index <code>i</code> in the ra... | 0 | {
"code": "class Solution {\npublic:\n int minOperations(vector<int>& nums1, vector<int>& nums2) {\n int n = nums1.size();\n int x = 0;\n int y = 1;\n for(int i = 0 ; i < n-1 ; i ++)\n {\n if(nums1[i] <= nums1[n-1] && nums2[i] <= nums2[n-1]) continue;\n if(n... |
3,190 | <p>You are given two <strong>0-indexed</strong> integer arrays, <code>nums1</code> and <code>nums2</code>, both having length <code>n</code>.</p>
<p>You are allowed to perform a series of <strong>operations</strong> (<strong>possibly none</strong>).</p>
<p>In an operation, you select an index <code>i</code> in the ra... | 2 | {
"code": "class Solution {\npublic:\n int minOperations(vector<int>& nums1, vector<int>& nums2) {\n int choice1 = calc(nums1, nums2);\n // cout << choice1 << endl;\n swap(nums1.back(), nums2.back());\n int choice2 = calc(nums1, nums2);\n // cout << choice2 << endl;\n int an... |
3,190 | <p>You are given two <strong>0-indexed</strong> integer arrays, <code>nums1</code> and <code>nums2</code>, both having length <code>n</code>.</p>
<p>You are allowed to perform a series of <strong>operations</strong> (<strong>possibly none</strong>).</p>
<p>In an operation, you select an index <code>i</code> in the ra... | 3 | {
"code": "class Solution {\npublic:\n int minOperations(vector<int>& nums1, vector<int>& nums2) {\n \n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n \n // max1 = nums1[n] or nums2[n]\n // max2 = the other one\n\n int max1 = nums1[nums1.size()-1]; \n ... |
3,190 | <p>You are given two <strong>0-indexed</strong> integer arrays, <code>nums1</code> and <code>nums2</code>, both having length <code>n</code>.</p>
<p>You are allowed to perform a series of <strong>operations</strong> (<strong>possibly none</strong>).</p>
<p>In an operation, you select an index <code>i</code> in the ra... | 3 | {
"code": "class Solution {\npublic:\n\n int n; vector<int> dp;\n int rec(int i, vector<int> &a1, vector<int> &a2)\n {\n // basecase\n if (i==n-1) return 0;\n int &ans = dp[i];\n if (ans != -1) return ans;\n\n ans = 1e8;\n // don't do the swap op but only if its ok\n... |
3,190 | <p>You are given two <strong>0-indexed</strong> integer arrays, <code>nums1</code> and <code>nums2</code>, both having length <code>n</code>.</p>
<p>You are allowed to perform a series of <strong>operations</strong> (<strong>possibly none</strong>).</p>
<p>In an operation, you select an index <code>i</code> in the ra... | 3 | {
"code": "class Solution {\npublic:\n int minOperations(vector<int>& nums1, vector<int>& nums2) {\n int m1=0,m2=0,n=nums1.size();\n vector<int> v1,v2;\n int a=nums1[n-1], b=nums2[n-1];\n for(int i=0;i<n-1;i++){\n m1=max(m1,nums1[i]);\n m2=max(m2,nums2[i]);\n ... |
3,190 | <p>You are given two <strong>0-indexed</strong> integer arrays, <code>nums1</code> and <code>nums2</code>, both having length <code>n</code>.</p>
<p>You are allowed to perform a series of <strong>operations</strong> (<strong>possibly none</strong>).</p>
<p>In an operation, you select an index <code>i</code> in the ra... | 3 | {
"code": "class Solution {\npublic:\n // Function to calculate the minimum number of operations to make two arrays non-decreasing.\n int minOperations(vector<int>& nums1, vector<int>& nums2) {\n int n = nums1.size();\n\n // dp[i][0]: Minimum operations if we make nums1[i:] and nums2[i:] non-decre... |
3,190 | <p>You are given two <strong>0-indexed</strong> integer arrays, <code>nums1</code> and <code>nums2</code>, both having length <code>n</code>.</p>
<p>You are allowed to perform a series of <strong>operations</strong> (<strong>possibly none</strong>).</p>
<p>In an operation, you select an index <code>i</code> in the ra... | 3 | {
"code": "class Solution {\npublic:\n int minOperations(vector<int>& nums1, vector<int>& nums2) {\n int n=nums1.size();\n int maxi1=nums1[n-1];\n int maxi2=nums2[n-1];\n int count1=0;\n int count2=0;\n int ans=-1;\n vector<int>temp1(nums1.begin(),nums1.end());\n ... |
3,190 | <p>You are given two <strong>0-indexed</strong> integer arrays, <code>nums1</code> and <code>nums2</code>, both having length <code>n</code>.</p>
<p>You are allowed to perform a series of <strong>operations</strong> (<strong>possibly none</strong>).</p>
<p>In an operation, you select an index <code>i</code> in the ra... | 3 | {
"code": "class Solution {\npublic:\n int helper(vector<int>& nums1, vector<int>& nums2){\n int res = 0;\n int n = nums1.size();\n for (int i = 0; i < n; i++){\n if (nums1[i] > nums1[n-1]){\n if (nums2[i] <= nums1[n-1] and nums1[i] <= nums2[n-1]){\n ... |
3,190 | <p>You are given two <strong>0-indexed</strong> integer arrays, <code>nums1</code> and <code>nums2</code>, both having length <code>n</code>.</p>
<p>You are allowed to perform a series of <strong>operations</strong> (<strong>possibly none</strong>).</p>
<p>In an operation, you select an index <code>i</code> in the ra... | 3 | {
"code": "#define ll long long\n\nclass Solution {\npublic:\n int n;\n vector<ll> dp;\n ll f(ll i, vector<int> &arr1, vector<int> &arr2) {\n if(i>=n) return 0;\n\n if(dp[i]!=-1) return dp[i];\n\n ll l = 1e8;\n \n if(arr1[i]<=arr1[n-1] && arr2[i]<=arr2[n-1]) l = min(l, f(i+... |
3,190 | <p>You are given two <strong>0-indexed</strong> integer arrays, <code>nums1</code> and <code>nums2</code>, both having length <code>n</code>.</p>
<p>You are allowed to perform a series of <strong>operations</strong> (<strong>possibly none</strong>).</p>
<p>In an operation, you select an index <code>i</code> in the ra... | 3 | {
"code": "class Solution {\n int getMoves(vector<int> nums1, vector<int> nums2) {\n int n = nums1.size();\n //cout << \"for end elements = \" << nums1[n-1] << \" and \" << nums2[n-1] << endl;\n int ans = 0;\n for(int i=0;i<n;i++) {\n if(nums1[i]<=nums1[n-1] && nums2[i]<=nums... |
3,197 | <p>You are given a <strong>0-indexed</strong> integer array <code>nums</code>. A pair of integers <code>x</code> and <code>y</code> is called a <strong>strong</strong> pair if it satisfies the condition:</p>
<ul>
<li><code>|x - y| <= min(x, y)</code></li>
</ul>
<p>You need to select two integers from <code>nums</... | 0 | {
"code": "#include <vector>\n#include <algorithm>\n#include <iostream>\n\nusing namespace std;\n\nclass Solution {\npublic:\n\n // Find number b in nums in range [l,r] most similar to complement of x\n int findBest(vector<int>& nums, int l, int r, int x) {\n const int n = nums.size();\n int inv =... |
3,197 | <p>You are given a <strong>0-indexed</strong> integer array <code>nums</code>. A pair of integers <code>x</code> and <code>y</code> is called a <strong>strong</strong> pair if it satisfies the condition:</p>
<ul>
<li><code>|x - y| <= min(x, y)</code></li>
</ul>
<p>You need to select two integers from <code>nums</... | 0 | {
"code": "\nclass Solution {\npublic:\n#define ll int\n ll search(ll l,ll r,ll msk, vector<int>& a)\n {\n r--;\n ll rr=l;\n while(l<=r)\n {\n ll m=l+r;\n m>>=1;\n if(a[m]&msk)\n r=m-1,rr=m;\n else\n l=m+1;\n }\... |
3,197 | <p>You are given a <strong>0-indexed</strong> integer array <code>nums</code>. A pair of integers <code>x</code> and <code>y</code> is called a <strong>strong</strong> pair if it satisfies the condition:</p>
<ul>
<li><code>|x - y| <= min(x, y)</code></li>
</ul>
<p>You need to select two integers from <code>nums</... | 0 | {
"code": "// #define ll long long\n\n// const ll M = 31;\n// const ll W = 2e7 + 7;\n\nconst int N = 1e6;\n// int trie[2][W];\n// int cnt[W];\n// int node_cnt = 1;\n\n// void add(int k){\n// int x = 0; // root\n// for(int i=M;i>=0;i--){\n// int bit = 0;\n// if(k & (1LL << i))bit = 1;\n// ... |
3,197 | <p>You are given a <strong>0-indexed</strong> integer array <code>nums</code>. A pair of integers <code>x</code> and <code>y</code> is called a <strong>strong</strong> pair if it satisfies the condition:</p>
<ul>
<li><code>|x - y| <= min(x, y)</code></li>
</ul>
<p>You need to select two integers from <code>nums</... | 0 | {
"code": "const int N = 1e6;\nclass Solution {\npublic:\n\n int go[N][2];\n int cnt[N];\n int timer = 1;\n\n void add(int x) {\n int v = 0;\n for (int i = 19; i >= 0; i--) {\n bool bit = (x >> i) & 1;\n if (go[v][bit] == -1) {\n go[v][bit] = timer;\n ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.