id
int64
1
3.58k
problem_description
stringlengths
516
21.8k
instruction
int64
0
3
solution_c
dict
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n vector<int> ret;\n int sLen = s.size();\n\n unordered_map<string, int> wordCnt;\n int totalLen = 0;\n for (int i = 0; i < words.size(); ++i) {\n ++wordCnt[words[i]];\n...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n unordered_map<string,int>mp[10001];\n unordered_map<string,int>pref[10001];\n vector<int> findSubstring(string s, vector<string>& words) {\n unordered_map<string,int>cnt;\n int n = s.size(), m = words.size(), len = words[0].size();\n int size = len ...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n unordered_map<string,int>mp[10001];\n unordered_map<string,int>pref[10001];\n vector<int> findSubstring(string s, vector<string>& words) {\n unordered_map<string,int>cnt;\n int n = s.size(), m = words.size(), len = words[0].size();\n int size = len ...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n\n unordered_map<string, int> wordsMap;\n vector<int> ans;\n bool match;\n string word;\n int wordsCount;\n\n int numWords = words.size();\n int wordLen = words[0].s...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n vector<int> result;\n int wordLength = words[0].length();\n int wordCount = words.size();\n int substringLength = wordLength * wordCount;\n \n if (s.length() < substringLe...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\n bool check(string s, map<string, int>& freq, int word_len,\n int num_words) {\n int l = s.length();\n unordered_map<string,int> temp_freq;\n int same_freq_words = 0;\n for (int i = 0; i < l - word_len + 1; i += word_len) {\n string window = s....
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string_view s, vector<string>& words) {\n std::string_view sv = s;\n std::vector<int> indexes;\n\n size_t wordSize = words[0].size();\n size_t sizeLeft = wordSize * words.size();\n std::unordered_map<uint16_t, uint1...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n // create a hashmap to store the frequency of each word in words\n unordered_map<string, int> hash;\n for (auto word : words) {\n if (hash.find(word) == hash.end()) {\n ...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n // create a hashmap to store the frequency of each word in words\n unordered_map<string, int> hash;\n for (auto word : words) {\n if (hash.find(word) == hash.end()) {\n ...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n // create a hashmap to store the frequency of each word in words\n unordered_map<string, int> hash;\n for (auto word : words) {\n if (hash.find(word) == hash.end()) {\n ...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n vector<int> ans;\n int N = s.length();\n int words_length = words.size();\n int L = words[0].length();\n int nums = L;\n map<string, int> count_ori, count;\n for (s...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n vector<int> ans;\n unordered_map<string, int> wordSet;\n for(auto i: words){\n wordSet[i]++;\n }\n unordered_map<string, int> tempSet;\n int ind = 0;\n i...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n vector<int> ans;\n unordered_map<string, int> wordSet;\n for(auto i: words){\n wordSet[i]++;\n }\n unordered_map<string, int> tempSet;\n int ind = 0;\n i...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n map<int,map<string,int>>mp;\n map<int,map<string,int>>pref;\n vector<int> findSubstring(string s, vector<string>& words) {\n map<string,int>cnt;\n int n = s.size(), m = words.size(), len = words[0].size();\n int size = len * m;\n for(string x...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) \n {\n unordered_map<string,int> words_map;\n vector<int> answer;\n \n for(int i{}; i< words.size(); i++)\n {\n words_map[words[i]]++;\n }\n \n int...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string> &words) {\n vector<int> ans;\n string_view sView(s);\n long len = words.size() * words[0].size();\n\n unordered_map<string_view, long> wordMap;\n for (long i = 0; i < words.size(); i++) {\n wordMap[words[i]]...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string> &words) {\n vector<int> ans;\n string_view sView(s);\n long len = words.size() * words[0].size();\n\n unordered_map<string_view, long> wordMap;\n for (long i = 0; i < words.size(); i++) {\n wordMap[words[i]]...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\n\n long long int hashed_val(string& s)\n {\n long long int val=0;\n for(int i=0;i<s.size();i++)\n {\n val=val+pow((i*i)+pow((s[i]-'a'),3),2);\n }\n return val;\n }\n\n bool check(deque<char>& dq,unordered_map<long long int,int> mp,...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "#define ll long long\nll p1 = 31;\nll mod = 1e9 + 7;\n\nclass Solution {\n vector<ll> precompute_powers(int length) {\n vector<ll> powers(length);\n powers[0] = 1;\n for (int i = 1; i < length; ++i) {\n powers[i] = (powers[i-1] * p1) % mod;\n }\n return powe...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n unordered_map<int,unordered_map<string,int>>mp;\n unordered_map<int,unordered_map<string,int>>pref;\n vector<int> findSubstring(string s, vector<string>& words) {\n unordered_map<string,int>cnt;\n int n = s.size(), m = words.size(), len = words[0].size();\...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n unordered_map<int,unordered_map<string,int>>mp;\n unordered_map<int,unordered_map<string,int>>pref;\n vector<int> findSubstring(string s, vector<string>& words) {\n unordered_map<string,int>cnt;\n int n = s.size(), m = words.size(), len = words[0].size();\...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n unordered_map<int,unordered_map<string,int>>mp;\n unordered_map<int,unordered_map<string,int>>pref;\n vector<int> findSubstring(string s, vector<string>& words) {\n unordered_map<string,int>cnt;\n int n = s.size(), m = words.size(), len = words[0].size();\...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n int size = words[0].size();\n vector<int> indices;\n set<string> used;\n if(size*words.size() > s.size()) return indices;\n int num = 0; \n \n int start;\n b...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n using WordsMap = std::unordered_map<std::string_view, int>;\n\n bool isPermutation(std::string_view sv, const WordsMap& words_count) {\n size_t word_size = words_count.begin()->first.size();\n WordsMap matches;\n for (size_t i = 0; i < sv.size(); i += ...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n vector<int> ans;\n \n unordered_map<string, int> pattern;\n string sPattern = \"\";\n for(string& word : words){\n ++pattern[word];\n sPattern += word;\n ...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n vector<int> ans;\n \n unordered_map<string, int> pattern;\n string sPattern = \"\";\n for(string& word : words){\n ++pattern[word];\n sPattern += word;\n ...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n\n bool isCandidate( const string& _str, const string& _refStr)\n {\n return _str == _refStr;\n }\n \n bool isCandidate( const string& _str, unordered_map<string, int>& wordMap )\n {\n unordered_map<string, int> seen;\n\n int i = 0;\n ...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n unordered_map<string, int> m;\n vector<int> ans;\n for(string str : words)\n {\n m[str]++;\n }\n\n int wordLen = words[0].length();\n int numWords = word...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n unordered_map<string, int> m;\n vector<int> ans;\n for(string str : words)\n {\n m[str]++;\n }\n\n int wordLen = words[0].length();\n int numWords = word...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\n unordered_map<string_view, uint32_t> wordCounter;\n uint32_t numWords;\n uint32_t atomSize;\n\n int check(string_view s) {\n unordered_map<string_view, uint32_t> wordCounter = this->wordCounter;\n\n for (uint32_t i = 0, E = s.size(); i < E; i += atomSize) {\n ...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string_view s, vector<string>& words) {\n std::string_view sv = s;\n std::vector<int> indexes;\n\n size_t wordSize = words[0].size();\n size_t sizeLeft = wordSize * words.size();\n std::unordered_map<std::string_vie...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n int n=s.length(), m=words.size(), wn=words[0].length(), x=0;\n vector <int> ans;\n if(n<m*wn) return ans;\n unordered_map<string, int> temp, temp2;\n string curword=\"\";\n ...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n int n=s.length(), m=words.size(), wn=words[0].length(), x=0;\n vector <int> ans;\n if(n<m*wn) return ans;\n unordered_map<string, int> temp, temp2;\n string curword=\"\";\n ...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n vector<int> ans;\n int n = s.size();\n int w = words.size();\n int wn = words[0].size();\n unordered_map<string, int> mm, wmap;\n for(auto it:words){\n mm[it]++...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n std::string_view sv = s;\n std::vector<int> indexes;\n\n size_t wordSize = words[0].size();\n size_t sizeLeft = wordSize * words.size();\n std::map<std::string_view, size_t> word...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n std::string_view sv = s;\n std::vector<int> indexes;\n\n size_t wordSize = words[0].size();\n size_t sizeLeft = wordSize * words.size();\n std::map<std::string_view, size_t> word...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n bool isValid(int index, string& s, vector<string>& words, int wordSize, int size) {\n vector<bool> used(words.size(), false);\n int target = index + size; \n while (index < target) {\n int found = false;\n for (int i = 0; i < words.s...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n bool isValid(int index, string& s, vector<string>& words, int wordSize, int size) {\n vector<bool> used(words.size(), false);\n int target = index + size; \n while (index < target) {\n int found = false;\n for (int i = 0; i < words.s...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n unordered_map<string, int> mp;\n for (auto el : words) {\n mp[el]++;\n }\n\n vector<int> ans;\n int wordLength = words[0].size();\n int wordCount = words.size()...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\nprivate:\n size_t wi_len_;\n unordered_map<string, int> word_count_ = {};\n unordered_map<string, bool> cache_ = {};\n\n void init_wc(vector<string>& words) {\n word_count_.clear();\n for (const string& w : words) {\n word_count_[w] += 1;\n }\n ...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n int len = words.front().size();\n int total_len = len * words.size();\n unordered_multiset<string> st(words.begin(), words.end());\n vector<int> res;\n unordered_map<string, bool...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n int len = words.front().size();\n int total_len = len * words.size();\n unordered_multiset<string> st(words.begin(), words.end());\n vector<int> res;\n unordered_map<string, bool...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n\n unordered_map<string,int> word_count;\n\n for(string word : words)\n word_count[word]++;\n\n vector<int> ans;\n\n int n = s.length(), lenOfWord = words[0].size(), lenOfConc...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n\n unordered_map<string,int> word_count;\n unordered_map<string,int> concat_count;\n\n for(string word : words)\n word_count[word]++;\n\n vector<int> ans;\n\n int n = s...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "#pragma GCC optimize(\"O3,unroll-all-loops\")\n#pragma GCC target(\"avx2\")\n\nclass Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n map<string, int> cache;\n\n int sz = words[0].size();\n\n int ct = 0;\n\n map<string, int> mp, alrd;\n ...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "#pragma GCC optimize(\"O3,unroll-all-loops\")\n#pragma GCC target(\"avx2\")\n\nclass Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n map<string, int> cache;\n\n int sz = words[0].size();\n\n int ct = 0;\n\n map<string, int> mp, alrd;\n ...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n\n bool equal(vector<string> words)\n {\n int size = words.size();\n for (int i = 1; i < size; ++i)\n if (words[i] != words[i-1])\n return false;\n return true;\n }\n\n bool check(string s, int index, int size, int word, ...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n int len = words.front().size();\n int total_len = len * words.size();\n unordered_multiset<string> st(words.begin(), words.end());\n vector<int> res;\n unordered_map<string, bool...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n//using maps and sliding window approach\n//If I dont use checker function, it will give me TLE for one case, in which substrings are repeated in whole 's'. So checker will help me to reduce that TC\n//TC is O(n)*O(word_len)*O()\n vector<int> findSubstring(string s, vector<str...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n vector<int> concatIndices;\n bool sameString = true;\n\n string accumString = words[0];\n for(int i = 1; i < words.size(); i++){\n if(words[i] != words[i-1]){\n ...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n vector<int> concatIndices;\n bool sameString = true;\n\n string accumString = words[0];\n for(int i = 1; i < words.size(); i++){\n if(words[i] != words[i-1]){\n ...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class RadixTree {\n std::vector<std::unique_ptr<RadixTree>> children;\n int count = 0;\n int used = 0;\n\npublic:\n void add(string_view&& w) {\n if (w.empty()) {\n ++count;\n return;\n }\n\n children.resize('z' - 'a' + 1);\n auto& child = child...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n vector <int> start_indexes;\n unordered_map<string,int> master;\n for (int i=0;i<words.size();i++){\n master[words[i]]++;\n }\n int num_words = words.size(); // How ma...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n bool check(string s,multiset<string> mp, int t){\n string curr=\"\";\n for(int i=0;i<t;i++) curr.push_back(s[i]);\n for(int i=0;i<=s.size()-t;i+=t){\n if(i>0){\n curr=\"\";\n for(int j=i;j<i+t;j++) curr.push_back(s...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n bool check(string s,multiset<string> mp, int t){\n string curr=\"\";\n for(int i=0;i<t;i++) curr.push_back(s[i]);\n for(int i=0;i<=s.size()-t;i+=t){\n if(i>0){\n curr=\"\";\n for(int j=i;j<i+t;j++) curr.push_back(s...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n bool check(string s,multiset<string> mp, int t){\n string curr=\"\";\n for(int i=0;i<t;i++) curr.push_back(s[i]);\n for(int i=0;i<=s.size()-t;i+=t){\n if(i>0){\n curr=\"\";\n for(int j=i;j<i+t;j++) curr.push_back(s...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "#include <vector>\n#include <string>\n#include <iostream>\n#include <algorithm>\n#include <unordered_map>\n\nusing namespace std;\n\n\n\n\n\nclass Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n if(s.length() == 1){\n if(words.size() == 1 && words[0...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "#include <vector>\n#include <string>\n#include <iostream>\n#include <algorithm>\n#include <unordered_map>\n\nusing namespace std;\n\n\n\n\n\nclass Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n if(s.length() == 1){\n if(words.size() == 1 && words[0...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n unordered_map<string, int> s_set;\n unordered_map<string, int> checkdup;\n unordered_set<int> result_set;\n vector<int> result;\n int step = words[0].size();\n if (s.size(...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n unordered_map<string, int> s_set;\n unordered_map<string, int> checkdup;\n unordered_set<int> result_set;\n vector<int> result;\n int step = words[0].size();\n //cout<<wor...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n int wordSize = words[0].size(), totalSize = words.size() * wordSize;\n vector<int> result;\n unordered_map<string, uint32_t> map, map2;\n for (string& s : words) map[s]++;\n\n fo...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string a, vector<string>& w) {\n int n = a.size();\n int m = w.size();\n int l = w[0].size();\n \n int k = m*l;\n unordered_map<string,int> um1;\n unordered_map<string,int> um2;\n vector<int> an...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string a, vector<string>& w) {\n int n = a.size();\n int m = w.size();\n int l = w[0].size();\n \n int k = m*l;\n unordered_map<string,int> um1;\n unordered_map<string,int> um2;\n vector<int> an...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n int word_size = words.front().size();\n int concat_size = word_size*words.size();\n vector<int> res;\n\n unordered_map<string, int> wordMap;\n for(auto word : words){\n ...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "struct bor {\n\tstruct node {\n\t\tmap<char, int> mp;\n\t\tint c;\n\t};\n\tvector<node> a;\n\tint sm = 0;\n\tbor() {\n\t\ta.resize(1);\n\t};\n\tvoid set(string s) {\n\t\tint p = 0;\n\t\tfor (auto i : s) {\n\t\t\tif (a[p].mp.count(i) == 0) {\n\t\t\t\ta[p].mp[i] = a.size();\n\t\t\t\ta.push_back({});\n\t\t\t}...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n \n int k= words[0].length();\n int i=0,j=0;\n vector<int> res;\n string temp=\"\";\n unordered_map<string,int> st, mp;\n for(auto it: words)\n {\n ...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n vector<int> ans;\n int n = words.size();\n int m = words[0].size();\n int l = n*m; // size of word formed word;\n if(l > s.size()) return ans;\n unordered_map<string,int> ...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n ios::sync_with_stdio(false);\n vector<int> result;\n unordered_map<string, int> map1;\n unordered_map<string, int> map2;\n unordered_set<string> found;\n unordered_set<str...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n vector<int> result;\n unordered_map<string, int> map1;\n unordered_map<string, int> map2;\n unordered_set<string> found;\n unordered_set<string> notFound;\n\n for(int i = ...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n ios::sync_with_stdio(false);\n vector<int> result;\n unordered_map<string, int> map1;\n unordered_map<string, int> map2;\n unordered_set<string> found;\n unordered_set<str...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n vector<int> result;\n unordered_map<string, int> map1;\n unordered_map<string, int> map2;\n unordered_set<string> found;\n unordered_set<string> notFound;\n\n for(int i = ...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n unordered_map<string, int > curr, freq;\n unordered_map<string, bool> memo;\n \n for (string& word: words)\n {\n freq[word]++;\n }\n int len=s.size();//...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n int word_size = words.front().size();\n int concat_size = word_size*words.size();\n vector<int> res;\n\n unordered_map<string, int> wordMap;\n for(auto word : words){\n ...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n int total_char = 0;\n int word_len = 0;\n unordered_map <string, int> umap; //words and its frequencies\n\n void index_words(vector<string> & words){\n for (int i = 0, w = words.size(); i < w; ++i) {\n if (umap.find(words[i]) == umap.end())\n ...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n int total_char = 0;\n int word_len = 0;\n unordered_map <string, int> umap;\n\n void index_words(vector<string> & words){\n for (int i = 0, w = words.size(); i < w; ++i) {\n if (umap.find(words[i]) == umap.end())\n umap[words[i]] = 0;\...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\nprivate:\n bool contains(string &s, map<string, int> words, int start, int len) {\n int N = s.length();\n for(int i = start; i + len <= N; i+=len) {\n auto itr = words.find(s.substr(i, len));\n if(itr == words.end()) {\n // not found\n...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n vector<int> ans;\n map<string,int> mpp;\n for(string s:words){\n auto itr=mpp.find(s);\n if(itr==mpp.end()){\n mpp.insert({s,1});\n }\n ...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n \n vector<int> findSubstring(string s, vector<string>& words) {\n \n vector<int>ans;\n map<string,bool>mp;\n map<string,int>hash;\n\n for(int i=0;i<words.size();i++){\n mp[words[i]]=true;\n hash[words[i]]++;\n ...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n \n vector<int> findSubstring(string s, vector<string>& words) {\n unordered_map<string,int> m;\n int ch=1;\n for(int i=1;i<words[0].length();i++)\n {\n if(words[0][i]!=words[0][i-1])\n {\n ch=0;\n break;\n }\n }\n for(auto it : word...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n vector<int> letters(26, 0);\n vector<pair<string,int>> mots;\n int num = words.size(), m = s.length();\n int total = 0;\n for (int i = 0; i < num; i++){\n for (int j =...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n vector<int> letters(26, 0);\n vector<pair<string,int>> mots;\n int num = words.size(), m = s.length();\n int total = 0;\n for (int i = 0; i < num; i++){\n for (int j =...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& v) {\n unordered_map<string,int>mp;\n for(auto i:v)\n mp[i]++;\n \n int i=0;\n int j=i;\n string temp;\n int x=v[0].size();\n int size=x*v.size();\n v...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n\t\tstd::vector<int> output;\n\t\t\n\t\tthis->word_size = words[0].length();\n\t\tint end = s.length() - this->word_size * words.size();\n\n\t\tstd::priority_queue<std::pair<int, std::string>, std::vector<std::pair...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n sort(words.begin(), words.end());\n const int wordsize = words[0].size();\n const int matchlength = words.size() * wordsize;\n\n int p = 0;\n vector<int> match;\n for (int...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n unordered_map<string, int> index;\n for (int i = 0; i < words.size(); ++i) {\n index[words[i]] = i;\n }\n\n vector<int> maxcount(words.size());\n for (auto w : words) ...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\nprivate:\n int concateSize;\n int wordSize;\n map<string, int> wordCount;\n string s;\n\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n this->s = s;\n wordSize = words[0].size();\n int wordsSize = words.size();\n concate...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\nprivate:\n int concateSize;\n int wordSize;\n map<string, int> wordCount;\n string s;\n\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n this->s = s;\n wordSize = words[0].size();\n int wordsSize = words.size();\n concate...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n \n vector<int>ans;\n\n \n map<string,int>stringVal;\n int sz=words[0].size();\n\n if(words.size()*sz>s.size()) return ans;\n\n int val = 1;\n\n vector<int> rep(...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n\n //map it to an int\n //then just compare count\n\n unordered_map<string,int> rev;\n int cur = 1;\n vector<int> freq(words.size()+1,0);\n for(auto itr:words)\n {\n...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\n vector<int> findSubstring(string s, vector<string>& words) {\n\n //map it to an int\n //then just compare count\n\n unordered_map<string,int> rev;\n int cur = 1;\n vector<int> freq(words.size()+1,0);\n for(auto itr:words)\n {\n...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\nbool solve(string s,int d,unordered_map<string,int> m){\n for(int i=0;i<s.size();i=i+d){\n string g=s.substr(i,d);\n if(m.find(g)!=m.end()){\n m[g]--;\n if(m[g]==-1){\n return false;\n }\n }\n else{\n ...
30
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p> <p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> ...
3
{ "code": "class Solution {\npublic:\nbool solve(string s,int d,unordered_map<string,int> m){\n for(int i=0;i<s.size();i=i+d){\n string g=s.substr(i,d);\n if(m.find(g)!=m.end()){\n m[g]--;\n if(m[g]==-1){\n return false;\n }\n }\n else{\n ...
31
<p>A <strong>permutation</strong> of an array of integers is an arrangement of its members into a sequence or linear order.</p> <ul> <li>For example, for <code>arr = [1,2,3]</code>, the following are all the permutations of <code>arr</code>: <code>[1,2,3], [1,3,2], [2, 1, 3], [2, 3, 1], [3,1,2], [3,2,1]</code>.</li> ...
0
{ "code": "class Solution {\npublic:\n void nextPermutation(vector<int>& nums) {\n int idx=-1;\n int n=nums.size();\n\n // Finding pivot index (jispar change ho rha hai.)\n for (int i=n-2;i>=0;i--){\n if (nums[i]<nums[i+1]) {\n idx = i;\n break;\...
31
<p>A <strong>permutation</strong> of an array of integers is an arrangement of its members into a sequence or linear order.</p> <ul> <li>For example, for <code>arr = [1,2,3]</code>, the following are all the permutations of <code>arr</code>: <code>[1,2,3], [1,3,2], [2, 1, 3], [2, 3, 1], [3,1,2], [3,2,1]</code>.</li> ...
0
{ "code": "class Solution {\npublic:\n void nextPermutation(vector<int>& nums) {\n int i = nums.size() - 2;\n while (i >= 0 && nums[i + 1] <= nums[i]) {\n i--;\n }\n if (i >= 0) {\n int j = nums.size() - 1;\n while (nums[j] <= nums[i]) {\n ...
31
<p>A <strong>permutation</strong> of an array of integers is an arrangement of its members into a sequence or linear order.</p> <ul> <li>For example, for <code>arr = [1,2,3]</code>, the following are all the permutations of <code>arr</code>: <code>[1,2,3], [1,3,2], [2, 1, 3], [2, 3, 1], [3,1,2], [3,2,1]</code>.</li> ...
0
{ "code": "class Solution {\npublic:\n void nextPermutation(vector<int>& nums) {\n int n = nums.size() - 1;\n int k = -1;\n for (int i = n; i > 0; i--) {\n if (nums[i - 1] < nums[i]) {\n k = i - 1;\n break;\n }\n }\n if (k == -1...
31
<p>A <strong>permutation</strong> of an array of integers is an arrangement of its members into a sequence or linear order.</p> <ul> <li>For example, for <code>arr = [1,2,3]</code>, the following are all the permutations of <code>arr</code>: <code>[1,2,3], [1,3,2], [2, 1, 3], [2, 3, 1], [3,1,2], [3,2,1]</code>.</li> ...
0
{ "code": "class Solution {\npublic:\n void nextPermutation(vector<int>& nums) {\n next_permutation(nums.begin(), nums.end());\n // int n = nums.size();\n // int min_ind = -1;\n // //Find the first smaller index\n // for(int i = n - 1; i > 0; i--){\n // if(nums[i - 1]...
32
<p>Given a string containing just the characters <code>&#39;(&#39;</code> and <code>&#39;)&#39;</code>, return <em>the length of the longest valid (well-formed) parentheses </em><span data-keyword="substring-nonempty"><em>substring</em></span>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre...
0
{ "code": "class Solution {\npublic:\n int longestValidParentheses(string s) {\n int left=0;\n int right=0;\n int ma=0;\n for(int i=0 ; i<s.size() ;i++)\n {\n if(s[i]=='(')\n {\n left++;\n }\n else{\n right...
32
<p>Given a string containing just the characters <code>&#39;(&#39;</code> and <code>&#39;)&#39;</code>, return <em>the length of the longest valid (well-formed) parentheses </em><span data-keyword="substring-nonempty"><em>substring</em></span>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre...
0
{ "code": "class Solution {\n\n // vector<vector<int>> dp;\n\npublic:\n int longestValidParentheses(string s) {\n int mx=0;\n int n=s.size();\n\n for(int i=0;i<n;i++){\n int c=0;\n for(int j=i;j<n;j++){\n if(s[j]=='(') c++;\n else c--;\n ...
32
<p>Given a string containing just the characters <code>&#39;(&#39;</code> and <code>&#39;)&#39;</code>, return <em>the length of the longest valid (well-formed) parentheses </em><span data-keyword="substring-nonempty"><em>substring</em></span>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre...
0
{ "code": "class Solution {\npublic:\n int longestValidParentheses(string s) {\n int left=0,right=0,ans=0;\n for(int i=0;i<s.size();i++){\n if(s[i]=='(') left++;\n else right++;\n if(left==right) ans=max(ans,left*2);\n else if(right>left) left=right=0;\n ...
32
<p>Given a string containing just the characters <code>&#39;(&#39;</code> and <code>&#39;)&#39;</code>, return <em>the length of the longest valid (well-formed) parentheses </em><span data-keyword="substring-nonempty"><em>substring</em></span>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre...
0
{ "code": "class Solution {\npublic:\n int longestValidParentheses(string s) {\n int ans=0;\n int left=0;\n int right=0;\n \n\n for(int i=0;i<s.length();i++){\n if(s[i]=='('){\n left++;\n }else{\n right++;\n }\n ...