id int64 1 3.58k | problem_description stringlengths 516 21.8k | instruction int64 0 3 | solution_c dict |
|---|---|---|---|
3,396 | <p>A word is considered <strong>valid</strong> if:</p>
<ul>
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
<li>It includes <strong>at l... | 3 | {
"code": "class Solution {\npublic:\n bool isValid(string word) {\n if(word.length()<3){\n return false;\n }\n int countv=0;\n int countc=0;\n \n \n set<char> vowel;\n set<char> cons;\n for(char c='a';c<='z';c++){\n if(c=... |
3,396 | <p>A word is considered <strong>valid</strong> if:</p>
<ul>
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
<li>It includes <strong>at l... | 3 | {
"code": "class Solution {\npublic:\n bool isValid(string word) \n {\n map<char,int> vow;\n vow['a'] = 1;\n vow['e'] = 1;\n vow['i'] = 1;\n vow['o'] = 1;\n vow['u'] = 1;\n vow['A'] = 1;\n vow['E'] = 1;\n vow['I'] = 1;\n vow['O'] = 1;\n ... |
3,396 | <p>A word is considered <strong>valid</strong> if:</p>
<ul>
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
<li>It includes <strong>at l... | 3 | {
"code": "class Solution {\npublic:\n bool check_letter(char c) {\n return (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') ||\n (c >= 'A' && c <= 'Z');\n}\nbool check_vowel(char c) {\n return c == 'a' || c == 'e' || c == 'o' || c == 'u' || c == 'i' || c == 'A' ||\n c == 'E' || c == 'O' || c == ... |
3,396 | <p>A word is considered <strong>valid</strong> if:</p>
<ul>
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
<li>It includes <strong>at l... | 3 | {
"code": "class Solution {\npublic:\n bool isValid(string word) {\n bool isConsonant = false;\n bool isVowel = false;\n\n vector<string> vowels = {\"a\", \"e\", \"i\", \"o\", \"u\", \"A\", \"E\", \"I\", \"O\", \"U\"};\n vector<string> consonants= { \"b\", \"c\", \"d\", \"f\", \"g\", \"... |
3,396 | <p>A word is considered <strong>valid</strong> if:</p>
<ul>
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
<li>It includes <strong>at l... | 3 | {
"code": "class Solution {\npublic:\n bool isValid(string word) {\n bool isConsonant = false;\n bool isVowel = false;\n\n vector<string> vowels = {\"a\", \"e\", \"i\", \"o\", \"u\", \"A\", \"E\", \"I\", \"O\", \"U\"};\n vector<string> consonants= { \"b\", \"c\", \"d\", \"f\", \"g\", \"... |
3,396 | <p>A word is considered <strong>valid</strong> if:</p>
<ul>
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
<li>It includes <strong>at l... | 3 | {
"code": "class Solution {\npublic:\n bool isValid(string word) {\n bool isConsonant = false;\n bool isVowel = false;\n\n vector<string> vowels = {\"a\", \"e\", \"i\", \"o\", \"u\", \"A\", \"E\", \"I\", \"O\", \"U\"};\n vector<string> consonants= { \"b\", \"c\", \"d\", \"f\", \"g\", \"... |
3,396 | <p>A word is considered <strong>valid</strong> if:</p>
<ul>
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
<li>It includes <strong>at l... | 3 | {
"code": "class Solution {\npublic:\n bool isValid(string word) {\n bool isConsonant = false;\n bool isVowel = false;\n\n vector<string> vowels = {\"a\", \"e\", \"i\", \"o\", \"u\", \"A\", \"E\", \"I\", \"O\", \"U\"};\n vector<string> consonants= { \"b\", \"c\", \"d\", \"f\", \"g\", \"... |
3,396 | <p>A word is considered <strong>valid</strong> if:</p>
<ul>
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
<li>It includes <strong>at l... | 3 | {
"code": "class Solution {\npublic:\n bool isValid(string word) {\n bool isConsonant = false;\n bool isVowel = false;\n\n vector<string> vowels = {\"a\", \"e\", \"i\", \"o\", \"u\", \"A\", \"E\", \"I\", \"O\", \"U\"};\n vector<string> consonants= { \"b\", \"c\", \"d\", \"f\", \"g\", \"... |
3,396 | <p>A word is considered <strong>valid</strong> if:</p>
<ul>
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
<li>It includes <strong>at l... | 3 | {
"code": "class Solution {\npublic:\n bool isValid(string word) {\n unordered_set<char> vowels = {'a', 'e', 'i', 'o', 'u'};\n unordered_set<char> consonents;\n \n for(char ch='a'; ch<='z'; ch++){\n if(vowels.count(ch)==0){\n consonents.insert(ch);\n ... |
3,396 | <p>A word is considered <strong>valid</strong> if:</p>
<ul>
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
<li>It includes <strong>at l... | 3 | {
"code": "class Solution {\npublic:\n bool isValid(string word) {\n unordered_set<char> consonant;\n string con=\"bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ\";\n for(int i=0;i<con.length();i++)\n {\n consonant.insert(con[i]);\n }\n unordered_set<char> st;\n string a=\"aeiouAEIOU\";\... |
3,396 | <p>A word is considered <strong>valid</strong> if:</p>
<ul>
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
<li>It includes <strong>at l... | 3 | {
"code": "class Solution {\npublic:\n bool isValid(string word) {\n unordered_set<char> consonant;\n string con=\"bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ\";\n for(int i=0;i<con.length();i++)\n {\n consonant.insert(con[i]);\n }\n unordered_set<char> st;\n string a=\"aeiouAEIOU\";\... |
3,396 | <p>A word is considered <strong>valid</strong> if:</p>
<ul>
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
<li>It includes <strong>at l... | 3 | {
"code": "#pragma GCC optimize(\"03\", \"unroll-loops\")\nclass Solution {\npublic:\n bool isValid(string word) {\n unordered_set<char> vowels = {'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'};\n unordered_set<char> consonants;\n for (char c = 'A'; c <= 'Z'; ++c) {\n if (vowels.f... |
3,396 | <p>A word is considered <strong>valid</strong> if:</p>
<ul>
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
<li>It includes <strong>at l... | 3 | {
"code": "class Solution {\npublic:\n bool isValid(std::string_view word) {\n if (word.size() < 3) {\n return false;\n }\n\n bool has_vowel = false;\n bool has_consonant = false;\n\n auto is_vowel = [] (char c) {\n return std::set{'a','e','i','o','u'}.conta... |
3,396 | <p>A word is considered <strong>valid</strong> if:</p>
<ul>
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
<li>It includes <strong>at l... | 3 | {
"code": "class Solution {\npublic:\n bool isValid(string word) {\n if (word.length() < 3) {\n return false;\n }\n\n unordered_set<char> vowels = {'a', 'e', 'i', 'o', 'u',\n 'A', 'E', 'I', 'O', 'U'};\n\n unordered_set<char> consonants = {... |
3,396 | <p>A word is considered <strong>valid</strong> if:</p>
<ul>
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
<li>It includes <strong>at l... | 3 | {
"code": "class Solution {\npublic:\n bool isValid(string word) {\n if (word.length() < 3) {\n return false;\n }\n\n unordered_set<char> vowels = {'a', 'e', 'i', 'o', 'u',\n 'A', 'E', 'I', 'O', 'U'};\n\n unordered_set<char> consonants = {... |
3,396 | <p>A word is considered <strong>valid</strong> if:</p>
<ul>
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
<li>It includes <strong>at l... | 3 | {
"code": "class Solution {\npublic:\n bool isValid(string word) {\n if (word.length() < 3) {\n return false;\n }\n\n unordered_set<char> vowels = {'a', 'e', 'i', 'o', 'u',\n 'A', 'E', 'I', 'O', 'U'};\n\n unordered_set<char> consonants = {... |
3,396 | <p>A word is considered <strong>valid</strong> if:</p>
<ul>
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
<li>It includes <strong>at l... | 3 | {
"code": "class Solution {\npublic:\n bool isValid(string word) {\n if(word.size()<3){\n return false;\n }\n string vowel=\"aeiouAEIOU\";\n string consonant=\"qwrtyplkjhgfdszxcvbnmQWRTYPLKJHGFDZSXCVBNM\";\n unordered_set<char> allowed;\n allowed.insert(vowel.be... |
3,396 | <p>A word is considered <strong>valid</strong> if:</p>
<ul>
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
<li>It includes <strong>at l... | 3 | {
"code": "class Solution {\npublic:\n bool isValid(string w) {\n unordered_set<char> n{'1','2','3','4','5','6','7','7','8','9','0'};\n unordered_set<char> v{'A', 'E', 'I', 'O', 'U','a', 'e', 'i', 'o', 'u'};\n unordered_set<char> c{'B','C','D','F','G','H','J','K','L','M','N','P','Q','R','S','T... |
3,396 | <p>A word is considered <strong>valid</strong> if:</p>
<ul>
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
<li>It includes <strong>at l... | 3 | {
"code": "class Solution {\npublic:\n bool isValid(string word) {\n if(word.length() < 3){\n return false;\n }\n string vowels = \"aeiouAEIOU\";\n // string uvowels = \"\";\n // for(char c : vowels){\n // uvowels += toupper(c);\n // }\n string... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 0 | {
"code": "template <int mod = 998'244'353> class mint {\n // obtaining inverse\n void exgcd(int a, int b, int& x, int& y) {\n if(1ll * a * b == 0) { x = 1, y = 0; return; }\n exgcd(b, a % b, x, y); int tmp = y; y = x - a / b * y; x = tmp; \n }\npublic:\n int v;\n explicit operator int() ... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 0 | {
"code": "#pragma GCC optimize(\"O3,unroll-loops\") \nconst auto flag = ios::sync_with_stdio(false);\n\nstatic uint64_t wymix(uint64_t A, uint64_t B)\n{\n#if defined(__SIZEOF_INT128__)\n __uint128_t r = A; r *= B;\n#if WYHASH_CONDOM2\n A ^= (uint64_t)r; B ^= (uint64_t)(r >> 64);\n#else\n A = (uint64_t)r; B ... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 0 | {
"code": "class Solution {\npublic:int mod=1e9;\n int minimumOperationsToMakeKPeriodic(string word, int k) {\n map<int,int>mp;int n=word.size();\n int ans=0;long long nik=1,mul=1;\n for(int i=0;i<n;i++){\n if( i!=0&&i%k==0){\n\n mp[nik]++;\n ans=max(an... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 0 | {
"code": "class Solution {\npublic:\n int minimumOperationsToMakeKPeriodic(string word, int k) {\n std::unordered_map<std::string_view, int> substrCnt;\n std::string_view wordView{word};\n int maxCnt = 0;\n for (int pos = 0; pos < word.size(); pos += k) {\n int& cnt = substr... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 0 | {
"code": "class Solution {\npublic:\n int minimumOperationsToMakeKPeriodic(string word, int k) {\n int n = word.size();\n string_view sv {word};\n unordered_map<string_view, int> cnt;\n \n for(int i=0; i<n; i+=k) {\n cnt[sv.substr(i, k)]++;\n }\n int mx ... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 0 | {
"code": "class Solution {\npublic:\n int minimumOperationsToMakeKPeriodic(const string& word, int k) const {\n unordered_map<string, int> um;\n const int n = size(word);\n int maxi = 0;\n\n for (int i = 0; i < n; i += k) {\n maxi = max(maxi, ++um[word.substr(i, k)]);\n ... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 0 | {
"code": "class Solution {\npublic:\n int minimumOperationsToMakeKPeriodic(string word, int k) {\n map<string, int> mp;\n int ans = 0;\n\n for(int i = 0; i < word.size(); i += k) {\n ans = max(ans, ++mp[word.substr(i, k)]);\n }\n\n return (word.size()/k - ans);\n }... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 0 | {
"code": "class Solution {\npublic:\n int minimumOperationsToMakeKPeriodic(string word, int k) {\n map<string,int> msi;\n int n=word.size();\n for(int i=0;i<n;i+=k)\n {\n msi[word.substr(i,k)]+=1;\n }\n int ans=n;\n for(auto &[_,cnt]:msi)\n {\n ... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 0 | {
"code": "class Solution {\npublic:\n int minimumOperationsToMakeKPeriodic(string a, int k) {\n\n map<string,int> h;\n\n string temp;\n\n int n = a.size();\n\n int i = 0;\n\n int ans = 0;\n\n while(i < a.size()){\n\n if(i%k == 0 && (i != 0)){\n h... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 0 | {
"code": "class Solution {\npublic:\n int minimumOperationsToMakeKPeriodic(string word, int k) {\n int n = word.length();\n string st = \"\";\n for (int i = 0; i < k; i++)\n st += '*';\n map<string, int> mp;\n int mx = 0;\n for (int i = 0; i < n; i++)\n ... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 0 | {
"code": "class Solution {\npublic:\n int minimumOperationsToMakeKPeriodic(string s, int k) {\n map<string, int> mp;\n string temp;\n\n int n = s.size();\n for (int i = 0; i < n; i++) {\n if (!temp.empty() && i % k == 0)\n mp[temp]++, temp.clear();\n ... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 0 | {
"code": "class Solution {\npublic:\n int minimumOperationsToMakeKPeriodic(std::string word, int k) {\n int n = word.length();\n \n // Step 1: Check if the length of the word is divisible by k\n if (n % k != 0) {\n return -1;\n }\n\n // Step 2: Create a map to ... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 0 | {
"code": "class Solution {\npublic:\n int minimumOperationsToMakeKPeriodic(std::string word, int k) {\n int n = word.length();\n \n // Step 1: Check if the length of the word is divisible by k\n if (n % k != 0) {\n return -1;\n }\n\n // Step 2: Create a map to ... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 0 | {
"code": "class Solution {\npublic:\n int minimumOperationsToMakeKPeriodic(std::string word, int k) {\n int n = word.length();\n \n // Step 1: Check if the length of the word is divisible by k\n if (n % k != 0) {\n return -1;\n }\n\n // Step 2: Create a map to ... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 0 | {
"code": "class Solution {\npublic:\n int minimumOperationsToMakeKPeriodic(string s, int k) {\n int n=s.size();\n map<string,int>mp;\n int maxFreq=0;\n int Totalcount=0;\n for(int i=0;i<n;i=i+k){\n string t=s.substr(i,k);\n mp[t]++;\n maxFreq=max... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 0 | {
"code": "class Solution {\npublic:\n int minimumOperationsToMakeKPeriodic(string s, int k) {\n int n = s.size();\n map<string,int> mp ;\n int maxFreq = 0;\n int Totalcount = 0;\n for(int i=0;i<n;i=i+k) {\n string t = s.substr(i,k);\n mp[t]++;\n ... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 0 | {
"code": "class Solution {\npublic:\n int minimumOperationsToMakeKPeriodic(string word, int k) {\n int n = word.size();\n map<string,int> mp ;\n int maxFreq = 0;\n int Totalcount = 0;\n \n for(int i=0;i<n;i=i+k) {\n string t = word.substr(i,k);\n mp[... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 0 | {
"code": "class Solution {\npublic:\n int minimumOperationsToMakeKPeriodic(string word, int k) {\n\n map<string,int> mp;\n for(int i=0;i<word.size();i+=k){\n mp[word.substr(i,k)]++;\n }\n\n vector<int> freq;\n for(auto it =mp.begin();it!=mp.end();it++){\n f... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 0 | {
"code": "class Solution {\npublic:\n int minimumOperationsToMakeKPeriodic(string word, int k) {\n map<string, int> counts;\n int highest = 0;\n for (int i = 0; i < word.length(); i += k) {\n counts[word.substr(i, k)]++;\n highest = max(highest, counts[word.substr(i, k)]... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 1 | {
"code": "class Solution {\npublic:\n int minimumOperationsToMakeKPeriodic(string word, int k) {\n int n=word.size();\n map<string,int>mp;\n int ans=0;\n for(int i=0;i<=word.size()-k;i=i+k){\n mp[word.substr(i,k)]++;\n ans=max(ans,mp[word.substr(i,k)]);\n }... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 1 | {
"code": "class Solution {\npublic:\n int minimumOperationsToMakeKPeriodic(string word, int k) {\n int n = word.length();\n if(n == k) return 0;\n unordered_map<string, int> freqMap;\n // all the substrings should be made equal to the largest freq. word\n for(int j = 0; j < n; j... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 1 | {
"code": "#include<iostream>\n#include<vector>\n#include<unordered_map>\n#include<algorithm>\nusing namespace std;\nclass Solution {\npublic:\n int minimumOperationsToMakeKPeriodic(string word, int k) {\n int n = word.size();\n int num_substr = n/k;\n unordered_map<string, int> freq;\n ... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 1 | {
"code": "class Solution {\npublic:\n int minimumOperationsToMakeKPeriodic(string word, int k) {\n unordered_map<string, int> MAP;\n int N = word.size();\n int maxCnt = 0;\n for (int i = 0 ; i < N ; i+=k) {\n string s = word.substr(i,k);\n MAP[s]++;\n m... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 1 | {
"code": "class Solution {\npublic:\n int minimumOperationsToMakeKPeriodic(string word, int k) {\n int op=0,n=word.size();\n unordered_map<string,int>cnt;\n for(int i=0;i<n;i+=k){\n string s=word.substr(i,k);\n op=max(op,++cnt[s]);\n } \n return n/k-op;\n ... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 2 | {
"code": "class Solution {\npublic:\n int minimumOperationsToMakeKPeriodic(string s, int k) {\n map<string,int>m;\n int n = s.length();\n for(int i=0;i<n;i+=k){\n string s1 = s.substr(i,k);\n m[s1]++;\n }\n int ans = 0;\n for(auto val:m){\n ... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 2 | {
"code": "class Solution {\npublic:\n int minimumOperationsToMakeKPeriodic(string word, int k) {\n \n unordered_map<string ,int>mp;\n for(int i =0;i<word.size();i+=k)\n {\n mp[word.substr(i,k)]++;\n }\n int maxi=INT_MIN;\n for(auto it:mp){\n max... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 2 | {
"code": "class Solution {\npublic:\n int minimumOperationsToMakeKPeriodic(string word, int k) {\n // 1. Declare state variables\n int length = word.size();\n \n // 2. Maintain a count of the no. of substring of type 'x'\n std::unordered_map<std::string, int> substringCount;\n ... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 2 | {
"code": "class Solution {\npublic:\n int minimumOperationsToMakeKPeriodic(string word, int k) {\n // 1. Declare state variables\n int length = word.size();\n \n // 2. Maintain a count of the no. of substring of type 'x'\n std::unordered_map<std::string, int> substringCount;\n ... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 2 | {
"code": "class Solution {\npublic:\n int minimumOperationsToMakeKPeriodic(string word, int k) {\n // int n = word.size();\n size_t n = word.size();\n unordered_map<string, int> freq;\n // int mxFreq = 0;\n string which = \"\";\n for(int i =0;i<n;i+=k){\n // st... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 2 | {
"code": "class Solution {\npublic:\n int minimumOperationsToMakeKPeriodic(string word, int k) {\n int n = word.size();\n string s = \"\";\n unordered_map<string,int>mpp;\n \n for(int i=0;i<n;i++){\n s += word[i];\n \n if(s.size()==k){\n ... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 2 | {
"code": "class Solution {\npublic:\n int minimumOperationsToMakeKPeriodic(string a, int k) {\n unordered_map<string,int>mp;\n int l=0;\n int n =a.size();\n string s=\"\";\n s+=a[0];\n for(int i=0;i<n;i++){\n if(i!=l) s+=a[i];\n \n ... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 2 | {
"code": "class Solution {\npublic:\n int minimumOperationsToMakeKPeriodic(string word, int k) {\n unordered_map<string, int> mp;\n int i=0, n = word.size();\n for(i; i<n; i+=k){\n string tmp = word.substr(i, k);\n mp[tmp]++;\n }\n int mx = 0;\n for(... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 2 | {
"code": "class Solution {\npublic:\n int minimumOperationsToMakeKPeriodic(string word, int k) {\n int n=word.size(),changes=n;\n unordered_map<string,int> mpp;\n\n for(int i=0;i<n;i+=k){\n string str=word.substr(i,k);\n mpp[str]++;\n }\n\n for(auto [str,fr... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 2 | {
"code": "class Solution {\npublic:\n int minimumOperationsToMakeKPeriodic(string word, int k) {\n int n = word.size();\n map<string,int> mp;\n int ans = 0;\n for(int i = 0; i < n; i += k){\n string s = \"\";\n for(int j = i; j < i+k; j++){\n s += w... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 2 | {
"code": "class Solution {\npublic:\n int minimumOperationsToMakeKPeriodic(string word, int k) {\n int n=word.size();\n unordered_map<string,int> mp;\n int i=0;\n while(i<n){\n if(i%k==0){\n string sub=word.substr(i,k);\n mp[sub]++;\n i+=k;\n ... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 3 | {
"code": "class Solution {\npublic:\n int minimumOperationsToMakeKPeriodic(string word, int k) {\n int n =word.size();\n unordered_map<string,int> umap;\n for(int i=0; i<n; i+=k){\n string str = word.substr(i, k);\n umap[str]++;\n }\n int len = n/k;\n ... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 3 | {
"code": "class Solution {\npublic:\n int minimumOperationsToMakeKPeriodic(string word, int k){\n \n int n = word.size();\n map<string,int> mp;\n \n for(int i = 0; i < n;)\n {\n string str = \"\";\n for(int j = i; j < i + k;j++)\n {\n ... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 3 | {
"code": "class Solution {\npublic:\n int minimumOperationsToMakeKPeriodic(string word, int k) {\n map<string,int> m;\n\n for(int i =0;i<word.size();i++){\n string g = \"\";\n g+=word.substr(i,k);\n m[g]++;\n i+= k-1;\n }\n int maxi =0;\n ... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 3 | {
"code": "class Solution {\npublic:\n int minimumOperationsToMakeKPeriodic(string words, int k) {\n // Edge Case\n if (words.size() % k != 0) { return 0; }\n unordered_map<string, int> maps;\n int count = 0;\n string temp = string();\n string majorityString = string();\n ... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 3 | {
"code": "class Solution {\npublic:\n int minimumOperationsToMakeKPeriodic(string word, int k) {\n int n = word.length();\n unordered_map<string,int>mp;\n for(int i=0;i<n;i+=k)\n {\n mp[word.substr(i,k)]++;\n }\n string ref = \"\";int maxi = 0;\n for(aut... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 3 | {
"code": "class Solution {\npublic:\n int minimumOperationsToMakeKPeriodic(string word, int k) \n {\n int n=word.size();\n int ans=0;\n unordered_map<string, int> mp;\n for(int i=0;i<n;i+=k)\n {\n string s=\"\";\n for(int j=i;j<i+k;j++)\n {\n ... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 3 | {
"code": "class Solution {\npublic:\n int minimumOperationsToMakeKPeriodic(string word, int k) \n {\n int n=word.size();\n int ans=0;\n unordered_map<string, int> mp;\n for(int i=0;i<n;i+=k)\n {\n string s=\"\";\n for(int j=i;j<i+k;j++)\n {\n ... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 3 | {
"code": "class Solution {\npublic:\n int minimumOperationsToMakeKPeriodic(string word, int k) \n {\n int n=word.size();\n int ans=0;\n unordered_map<string, int> mp;\n for(int i=0;i<n;i+=k)\n {\n string s=\"\";\n for(int j=i;j<i+k;j++)\n {\n ... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 3 | {
"code": "class Solution {\npublic:\n int minimumOperationsToMakeKPeriodic(string word, int k) \n {\n int n=word.size();\n int ans=0;\n unordered_map<string, int> mp;\n for(int i=0;i<n;i+=k)\n {\n string s=\"\";\n for(int j=i;j<i+k;j++)\n {\n ... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 3 | {
"code": "class Solution {\npublic:\n int minimumOperationsToMakeKPeriodic(string word, int k) \n {\n int n=word.size();\n int ans=0;\n unordered_map<string, int> mp;\n for(int i=0;i<n;i+=k)\n {\n string s=\"\";\n for(int j=i;j<i+k;j++)\n {\n ... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 3 | {
"code": "class Solution {\npublic:\n int minimumOperationsToMakeKPeriodic(string word, int k) {\n int op=0,n=word.size();\n unordered_map<string,int>cnt;\n for(int i=0;i<n;i+=k){\n string s=\"\";\n for(int j=i;j<i+k;j++) s+=word[j];\n op=max(op,++cnt[s]);\n ... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 3 | {
"code": "class Solution {\npublic:\n int minimumOperationsToMakeKPeriodic(string word, int k) {\n int op=0,n=word.size();\n unordered_map<string,int>cnt;\n for(int i=0;i<n;i+=k){\n string s=\"\";\n for(int j=i;j<i+k;j++) s+=word[j];\n op=max(op,++cnt[s]);\n ... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 3 | {
"code": "class Solution {\npublic:\n int minimumOperationsToMakeKPeriodic(string word, int k) {\n unordered_map<string,int> m;\n int n=word.size();\n int i=0,j=0;\n while(j<n){\n while(j<i+k){\n j++;\n }\n string temp=word.substr(i,j-i);... |
3,384 | <p>You are given a string <code>word</code> of size <code>n</code>, and an integer <code>k</code> such that <code>k</code> divides <code>n</code>.</p>
<p>In one operation, you can pick any two indices <code>i</code> and <code>j</code>, that are divisible by <code>k</code>, then replace the <span data-keyword="substrin... | 3 | {
"code": "class Solution {\npublic:\n int minimumOperationsToMakeKPeriodic(string word, int k) {\n unordered_map<string,int> m;\n int n=word.size();\n int i=0,j=0;\n while(j<n){\n while(j<i+k){\n j++;\n }\n string temp=word.substr(i,j-i);... |
3,395 | <p>You are given a string <code>s</code>, which is known to be a concatenation of <strong>anagrams</strong> of some string <code>t</code>.</p>
<p>Return the <strong>minimum</strong> possible length of the string <code>t</code>.</p>
<p>An <strong>anagram</strong> is formed by rearranging the letters of a string. For e... | 0 | {
"code": "#pragma GCC optimize(\"O3\", \"unroll-loops\")\nclass Solution {\npublic:\n int n, d=0;\n bool test(string& s, int len){\n int k=n/len;\n array<int, 26> freq0, freq1;\n freq1.fill(0);\n for(int i=0; i<len; i++) \n freq1[s[i]-'a']++;\n for(int i=1; i<k; i+... |
3,395 | <p>You are given a string <code>s</code>, which is known to be a concatenation of <strong>anagrams</strong> of some string <code>t</code>.</p>
<p>Return the <strong>minimum</strong> possible length of the string <code>t</code>.</p>
<p>An <strong>anagram</strong> is formed by rearranging the letters of a string. For e... | 0 | {
"code": "class Solution\n{\npublic:\n int minAnagramLength(const std::string& s)\n {\n const auto n = std::size(s);\n\n std::vector<int> div;\n\n for (auto i = 1; i * i <= n; i++)\n {\n if (n % i == 0)\n {\n div.push_back(i);\n di... |
3,395 | <p>You are given a string <code>s</code>, which is known to be a concatenation of <strong>anagrams</strong> of some string <code>t</code>.</p>
<p>Return the <strong>minimum</strong> possible length of the string <code>t</code>.</p>
<p>An <strong>anagram</strong> is formed by rearranging the letters of a string. For e... | 0 | {
"code": "class Solution {\npublic:\n int minAnagramLength(string s) {\n unordered_map<char ,int> freq ;\n unordered_set<char > unique ;\n int max_freq {} ;\n for(auto ch : s){\n freq[ch]++ ;\n max_freq = max(max_freq , freq[ch]) ;\n }\n\n int gcd = ... |
3,395 | <p>You are given a string <code>s</code>, which is known to be a concatenation of <strong>anagrams</strong> of some string <code>t</code>.</p>
<p>Return the <strong>minimum</strong> possible length of the string <code>t</code>.</p>
<p>An <strong>anagram</strong> is formed by rearranging the letters of a string. For e... | 0 | {
"code": "class Solution {\npublic:\n int check(string& s, unordered_map<char, int>& m, int start, int length){\n if(s.size() % length) return start;\n int i = start;\n unordered_map<char, int> _m = m;\n int _len = length;\n while(i < s.size()){\n if(_len == 0){\n ... |
3,395 | <p>You are given a string <code>s</code>, which is known to be a concatenation of <strong>anagrams</strong> of some string <code>t</code>.</p>
<p>Return the <strong>minimum</strong> possible length of the string <code>t</code>.</p>
<p>An <strong>anagram</strong> is formed by rearranging the letters of a string. For e... | 0 | {
"code": "class Solution {\npublic:\n int minAnagramLength(string s) {\n int n=s.length();\n for(int i=0;i<n;i++){\n int idx=s[i]-'a';\n if(i==0) c[i][idx]=1;\n else{\n for(int j=0;j<26;j++) c[i][j]=c[i-1][j];\n c[i][idx]++;\n ... |
3,395 | <p>You are given a string <code>s</code>, which is known to be a concatenation of <strong>anagrams</strong> of some string <code>t</code>.</p>
<p>Return the <strong>minimum</strong> possible length of the string <code>t</code>.</p>
<p>An <strong>anagram</strong> is formed by rearranging the letters of a string. For e... | 0 | {
"code": "class Solution {\npublic:\n int minAnagramLength(string s) {\n int n=s.length();\n for(int i=0;i<n;i++){\n int idx=s[i]-'a';\n if(i==0) c[i][idx]=1;\n else{\n for(int j=0;j<26;j++) c[i][j]=c[i-1][j];\n c[i][idx]++;\n ... |
3,395 | <p>You are given a string <code>s</code>, which is known to be a concatenation of <strong>anagrams</strong> of some string <code>t</code>.</p>
<p>Return the <strong>minimum</strong> possible length of the string <code>t</code>.</p>
<p>An <strong>anagram</strong> is formed by rearranging the letters of a string. For e... | 0 | {
"code": "class Solution {\npublic:\n int minAnagramLength(string s) {\n int n=s.length();\n for(int i=0;i<n;i++){\n int idx=s[i]-'a';\n if(i==0) c[i][idx]=1;\n else{\n for(int j=0;j<26;j++) c[i][j]=c[i-1][j];\n c[i][idx]++;\n ... |
3,395 | <p>You are given a string <code>s</code>, which is known to be a concatenation of <strong>anagrams</strong> of some string <code>t</code>.</p>
<p>Return the <strong>minimum</strong> possible length of the string <code>t</code>.</p>
<p>An <strong>anagram</strong> is formed by rearranging the letters of a string. For e... | 0 | {
"code": "class Solution {\npublic:\n int minAnagramLength(string s) {\n int f[100005][26], i, j, k, n = s.size();\n for (j = 0; j < 26; ++j) f[0][j] = 0;\n for (i = 1; i <= n; ++i){\n for (j = 0; j < 26; ++j) f[i][j] = f[i - 1][j];\n f[i][s[i - 1] - 'a']++;\n }\n... |
3,395 | <p>You are given a string <code>s</code>, which is known to be a concatenation of <strong>anagrams</strong> of some string <code>t</code>.</p>
<p>Return the <strong>minimum</strong> possible length of the string <code>t</code>.</p>
<p>An <strong>anagram</strong> is formed by rearranging the letters of a string. For e... | 0 | {
"code": "class Solution {\npublic:\n int minAnagramLength(string s) {\n int n=s.size();\n for(int i=1;i<n;++i)\n {\n if(n%i!=0) continue;\n string s0=s.substr(0,i);\n sort(s0.begin(),s0.end());\n bool found=true;\n for(int j=i;j<n;j+=i)\... |
3,395 | <p>You are given a string <code>s</code>, which is known to be a concatenation of <strong>anagrams</strong> of some string <code>t</code>.</p>
<p>Return the <strong>minimum</strong> possible length of the string <code>t</code>.</p>
<p>An <strong>anagram</strong> is formed by rearranging the letters of a string. For e... | 0 | {
"code": "class Solution {\npublic:\n int minAnagramLength(string s) {\n unordered_set<char> arr(s.begin(), s.end());\n if(arr.size()==1) return 1;\n for(int i=2;i<s.length();i++){\n if(s.length()%i==0){\n string n=s.substr(0,i);\n sort(n.begin(),n.end... |
3,395 | <p>You are given a string <code>s</code>, which is known to be a concatenation of <strong>anagrams</strong> of some string <code>t</code>.</p>
<p>Return the <strong>minimum</strong> possible length of the string <code>t</code>.</p>
<p>An <strong>anagram</strong> is formed by rearranging the letters of a string. For e... | 0 | {
"code": "class Solution {\npublic:\n int minAnagramLength(string s) {\n unordered_set<char> arr(s.begin(), s.end());\n if(arr.size()==1) return 1;\n for(int i=2;i<s.length();i++){\n if(s.length()%i==0){\n string n=s.substr(0,i);\n sort(n.begin(),n.end... |
3,395 | <p>You are given a string <code>s</code>, which is known to be a concatenation of <strong>anagrams</strong> of some string <code>t</code>.</p>
<p>Return the <strong>minimum</strong> possible length of the string <code>t</code>.</p>
<p>An <strong>anagram</strong> is formed by rearranging the letters of a string. For e... | 0 | {
"code": "class Solution {\npublic:\n int minAnagramLength(string s) {\n int n=s.size();\n int size=1;\n int ans=n;\n while(size<=n){\n if(n%size!=0){\n size++;\n continue;\n }\n string temp=s.substr(0,size);\n s... |
3,395 | <p>You are given a string <code>s</code>, which is known to be a concatenation of <strong>anagrams</strong> of some string <code>t</code>.</p>
<p>Return the <strong>minimum</strong> possible length of the string <code>t</code>.</p>
<p>An <strong>anagram</strong> is formed by rearranging the letters of a string. For e... | 0 | {
"code": "class Solution {\npublic:\n bool check(string& s, int w){\n set<string> st;\n for(int i=0;i<s.length();){\n string x = s.substr(i,w);\n sort(x.begin(),x.end());\n // cout<<\"string is \"<<x<<endl;\n st.insert(x);\n if(st.size()>1) ret... |
3,395 | <p>You are given a string <code>s</code>, which is known to be a concatenation of <strong>anagrams</strong> of some string <code>t</code>.</p>
<p>Return the <strong>minimum</strong> possible length of the string <code>t</code>.</p>
<p>An <strong>anagram</strong> is formed by rearranging the letters of a string. For e... | 1 | {
"code": "\nclass Solution {\npublic:\n bool check(int l, int &n, string &s)\n {\n unordered_map<string, bool> mp;\n for(int i = 0; i + l <= n; i += l)\n {\n string curr = s.substr(i, l);\n sort(curr.begin(), curr.end());\n mp[curr] = true;\n if(... |
3,395 | <p>You are given a string <code>s</code>, which is known to be a concatenation of <strong>anagrams</strong> of some string <code>t</code>.</p>
<p>Return the <strong>minimum</strong> possible length of the string <code>t</code>.</p>
<p>An <strong>anagram</strong> is formed by rearranging the letters of a string. For e... | 1 | {
"code": "class Solution {\npublic:\n bool check(string &s , int k)\n {\n map<string,int>m;\n for(int i=0;i<s.size();i+=k)\n {\n string p=s.substr(i,k);\n sort(p.begin(),p.end());\n m[p]++;\n if(m.size()>1)\n return 0;\n }\n ... |
3,395 | <p>You are given a string <code>s</code>, which is known to be a concatenation of <strong>anagrams</strong> of some string <code>t</code>.</p>
<p>Return the <strong>minimum</strong> possible length of the string <code>t</code>.</p>
<p>An <strong>anagram</strong> is formed by rearranging the letters of a string. For e... | 1 | {
"code": "class Solution {\npublic:\n int minAnagramLength(string s) {\n int n=s.size(),minLen=n;\n vector<int> factors;\n\n for(int i=1;i*i<=n;i++){\n if(n%i==0){\n factors.push_back(i);\n if(n/i!=i)\n factors.push_back(n/i);\n ... |
3,395 | <p>You are given a string <code>s</code>, which is known to be a concatenation of <strong>anagrams</strong> of some string <code>t</code>.</p>
<p>Return the <strong>minimum</strong> possible length of the string <code>t</code>.</p>
<p>An <strong>anagram</strong> is formed by rearranging the letters of a string. For e... | 1 | {
"code": "#include <string>\n#include <map>\n#include <algorithm>\n\nclass Solution {\npublic:\n int minAnagramLength(std::string s) {\n // Step 1: Calculate frequency of each character in the string\n std::map<char, int> freq;\n for (char c : s) {\n freq[c]++;\n }\n\n ... |
3,395 | <p>You are given a string <code>s</code>, which is known to be a concatenation of <strong>anagrams</strong> of some string <code>t</code>.</p>
<p>Return the <strong>minimum</strong> possible length of the string <code>t</code>.</p>
<p>An <strong>anagram</strong> is formed by rearranging the letters of a string. For e... | 1 | {
"code": "class Solution {\npublic:\n int ans = INT_MAX;\n\n bool check(string& s, int mid) {\n if (s.length() % mid != 0)\n return false;\n string t = s.substr(0, mid);\n sort(t.begin(), t.end());\n\n for (int i = 0; i < s.length(); i += mid) {\n string r = s.... |
3,395 | <p>You are given a string <code>s</code>, which is known to be a concatenation of <strong>anagrams</strong> of some string <code>t</code>.</p>
<p>Return the <strong>minimum</strong> possible length of the string <code>t</code>.</p>
<p>An <strong>anagram</strong> is formed by rearranging the letters of a string. For e... | 1 | {
"code": "class Solution {\npublic:\n bool check(string &s,int &mid)\n {\n int n=s.size();\n string r=s.substr(0, mid);\n sort(r.begin(),r.end());\n for(int i=0;i<n;i=i+mid)\n {\n string t=s.substr(i, mid);\n sort(t.begin(),t.end());\n if(t!=r... |
3,395 | <p>You are given a string <code>s</code>, which is known to be a concatenation of <strong>anagrams</strong> of some string <code>t</code>.</p>
<p>Return the <strong>minimum</strong> possible length of the string <code>t</code>.</p>
<p>An <strong>anagram</strong> is formed by rearranging the letters of a string. For e... | 1 | {
"code": "#include <iostream>\n#include <vector>\n#include <algorithm>\n#include <string>\nusing namespace std;\n\nclass Solution {\n bool checkSame(const string& a, const string& b) {\n if (a.length() != b.length()) return false;\n\n int hash[26] = {0};\n\n for (char c : a) {\n ha... |
3,395 | <p>You are given a string <code>s</code>, which is known to be a concatenation of <strong>anagrams</strong> of some string <code>t</code>.</p>
<p>Return the <strong>minimum</strong> possible length of the string <code>t</code>.</p>
<p>An <strong>anagram</strong> is formed by rearranging the letters of a string. For e... | 1 | {
"code": "class Solution {\npublic:\n bool solve(string s, int k) \n {\n int n = s.size();\n string a = s.substr(0, k);\n sort(a.begin(), a.end());\n for(int i=k;i<n;i=i+k)\n {\n string b = s.substr(i, k);\n sort(b.begin(), b.end());\n if(a!=b... |
3,395 | <p>You are given a string <code>s</code>, which is known to be a concatenation of <strong>anagrams</strong> of some string <code>t</code>.</p>
<p>Return the <strong>minimum</strong> possible length of the string <code>t</code>.</p>
<p>An <strong>anagram</strong> is formed by rearranging the letters of a string. For e... | 1 | {
"code": "class Solution {\npublic:\n bool solve(string s, int n)\n {\n cout<<n<<\" \";\n string temp = s.substr(0, n);\n sort(temp.begin(), temp.end());\n\n for(int i = n; i<s.length(); i +=n)\n {\n string curr = s.substr(i, n);\n sort(curr.begin(), cur... |
3,395 | <p>You are given a string <code>s</code>, which is known to be a concatenation of <strong>anagrams</strong> of some string <code>t</code>.</p>
<p>Return the <strong>minimum</strong> possible length of the string <code>t</code>.</p>
<p>An <strong>anagram</strong> is formed by rearranging the letters of a string. For e... | 1 | {
"code": "class Solution {\npublic:\n bool solve(string s, int k)\n {\n string sub=s.substr(0,k);\n sort(sub.begin(), sub.end());\n int n=s.size();\n for(int i=k;i<n;i+=k)\n {\n string sub_cur=s.substr(i,k);\n sort(sub_cur.begin(), sub_cur.end());\n ... |
3,395 | <p>You are given a string <code>s</code>, which is known to be a concatenation of <strong>anagrams</strong> of some string <code>t</code>.</p>
<p>Return the <strong>minimum</strong> possible length of the string <code>t</code>.</p>
<p>An <strong>anagram</strong> is formed by rearranging the letters of a string. For e... | 1 | {
"code": "class Solution {\npublic:\n bool solve(string s, int k)\n {\n string sub=s.substr(0,k);\n sort(sub.begin(), sub.end());\n int n=s.size();\n for(int i=k;i<n;i+=k)\n {\n string sub_cur=s.substr(i,k);\n sort(sub_cur.begin(), sub_cur.end());\n ... |
3,395 | <p>You are given a string <code>s</code>, which is known to be a concatenation of <strong>anagrams</strong> of some string <code>t</code>.</p>
<p>Return the <strong>minimum</strong> possible length of the string <code>t</code>.</p>
<p>An <strong>anagram</strong> is formed by rearranging the letters of a string. For e... | 1 | {
"code": "class Solution {\npublic:\n bool checkIfAnagramPossible(string& s, int len) {\n int n = s.length();\n\n if(n%len != 0)\n return false;\n\n string target = \"\";\n for(int i = 0; i < len; ++i) {\n target.push_back(s[i]);\n }\n sort(target.be... |
3,395 | <p>You are given a string <code>s</code>, which is known to be a concatenation of <strong>anagrams</strong> of some string <code>t</code>.</p>
<p>Return the <strong>minimum</strong> possible length of the string <code>t</code>.</p>
<p>An <strong>anagram</strong> is formed by rearranging the letters of a string. For e... | 1 | {
"code": "class Solution {\npublic:\n // bool checkAnagram(int n,int d,string s,map<char,int> m ){\n // map<char,int> ds;\n // for(int i=0;i<n;i++){\n // ds[s[i]]++;\n // }\n // bool flag = true;\n // for(auto i : m){\n // if(ds.find(i.first) == ds.end()){\... |
3,395 | <p>You are given a string <code>s</code>, which is known to be a concatenation of <strong>anagrams</strong> of some string <code>t</code>.</p>
<p>Return the <strong>minimum</strong> possible length of the string <code>t</code>.</p>
<p>An <strong>anagram</strong> is formed by rearranging the letters of a string. For e... | 1 | {
"code": "class Solution {\npublic:\n int func(string &s, int n, int len, string& st){\n if(n>=s.size()) return 1;\n string temp = \"\";\n for(int i = n; i < n + len; i++){\n temp += s[i];\n }\n sort(temp.begin(), temp.end());\n if(st!=temp) return 0;\n ... |
3,395 | <p>You are given a string <code>s</code>, which is known to be a concatenation of <strong>anagrams</strong> of some string <code>t</code>.</p>
<p>Return the <strong>minimum</strong> possible length of the string <code>t</code>.</p>
<p>An <strong>anagram</strong> is formed by rearranging the letters of a string. For e... | 1 | {
"code": "class Solution {\npublic:\n bool isValid(string &s, int winSize){\n int n = size(s);\n unordered_map<char, int> cFrq, tmp;\n if(winSize == n) return true;\n \n for(int i = 0; i < winSize; ++i) cFrq[s[i]]++;\n for(int i = winSize; i <= n-winSize; i+=winSize) {\n ... |
3,395 | <p>You are given a string <code>s</code>, which is known to be a concatenation of <strong>anagrams</strong> of some string <code>t</code>.</p>
<p>Return the <strong>minimum</strong> possible length of the string <code>t</code>.</p>
<p>An <strong>anagram</strong> is formed by rearranging the letters of a string. For e... | 1 | {
"code": "class Solution {\npublic:\n int gcd(int a, int b) {\n int temp;\n while (b != 0) {\n temp = b;\n b = a % b;\n a = temp;\n }\n return a;\n }\n\n int minAnagramLength(string s) {\n vector<int> v_cnt(26, 0);\n int max_ana_cnt ... |
3,395 | <p>You are given a string <code>s</code>, which is known to be a concatenation of <strong>anagrams</strong> of some string <code>t</code>.</p>
<p>Return the <strong>minimum</strong> possible length of the string <code>t</code>.</p>
<p>An <strong>anagram</strong> is formed by rearranging the letters of a string. For e... | 1 | {
"code": "class Solution {\npublic:\n bool check(int len,string &s)\n {\n unordered_map<char,int> mCompare,mCrt;\n for(int i=0;i<len;i++)\n {\n mCompare[s[i]]+=1;\n }\n for(int i=len;i<s.size();i++)\n {\n mCrt[s[i]]+=1;\n if((i+1)%len==... |
3,395 | <p>You are given a string <code>s</code>, which is known to be a concatenation of <strong>anagrams</strong> of some string <code>t</code>.</p>
<p>Return the <strong>minimum</strong> possible length of the string <code>t</code>.</p>
<p>An <strong>anagram</strong> is formed by rearranging the letters of a string. For e... | 1 | {
"code": "class Solution {\npublic:\n\n bool check(string s,int len)\n {\n map<string,int>mp;\n\n for(int i = 0;i<s.length();i += len)\n {\n string k = s.substr(i,len);\n sort(k.begin(),k.end());\n mp[k]++;\n }\n\n if(mp.size()>1)\n {\n... |
3,395 | <p>You are given a string <code>s</code>, which is known to be a concatenation of <strong>anagrams</strong> of some string <code>t</code>.</p>
<p>Return the <strong>minimum</strong> possible length of the string <code>t</code>.</p>
<p>An <strong>anagram</strong> is formed by rearranging the letters of a string. For e... | 1 | {
"code": "class Solution {\npublic:\n int minAnagramLength(string s) {\n int n = s.length();\n \n for (int i = 1; i <= n/2; ++i) {\n if(n%i!=0) continue;\n set<string> substrings;\n for (int j = 0; j <= n - i; j += i) {\n string temp = s.substr(... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.