id
int64
1
3.58k
problem_description
stringlengths
516
21.8k
instruction
int64
0
3
solution_c
dict
2,025
<p>You are given an array of strings <code>words</code> (<strong>0-indexed</strong>).</p> <p>In one operation, pick two <strong>distinct</strong> indices <code>i</code> and <code>j</code>, where <code>words[i]</code> is a non-empty string, and move <strong>any</strong> character from <code>words[i]</code> to <strong>a...
0
{ "code": "class Solution {\npublic:\n bool makeEqual(vector<string>& words) {\n int n=words.size();\n int count[26]={0};\n for(string &word:words){\n for(char &ch: word){\n count[ch-'a']++;\n }\n }\n return all_of(begin(count),end(count),[&] ...
2,025
<p>You are given an array of strings <code>words</code> (<strong>0-indexed</strong>).</p> <p>In one operation, pick two <strong>distinct</strong> indices <code>i</code> and <code>j</code>, where <code>words[i]</code> is a non-empty string, and move <strong>any</strong> character from <code>words[i]</code> to <strong>a...
0
{ "code": "class Solution {\npublic:\n bool makeEqual(vector<string>& words) {\n vector<int> v(26, 0);\n int n = words.size();\n for(int i = 0; i < n; i++){\n for(int j = 0; j < words[i].size(); j++)v[words[i][j] - 'a']++;\n }\n for(int i = 0; i < 26; i++)if(v[i] % n)r...
2,025
<p>You are given an array of strings <code>words</code> (<strong>0-indexed</strong>).</p> <p>In one operation, pick two <strong>distinct</strong> indices <code>i</code> and <code>j</code>, where <code>words[i]</code> is a non-empty string, and move <strong>any</strong> character from <code>words[i]</code> to <strong>a...
1
{ "code": "class Solution {\npublic:\n bool makeEqual(vector<string>& words) {\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n cout.tie(0);\n\n vector<int>freq(26,0);\n int n=words.size();\n\n for(string &word:words){\n\n for(char &c:word) freq[c-'a']++;...
2,025
<p>You are given an array of strings <code>words</code> (<strong>0-indexed</strong>).</p> <p>In one operation, pick two <strong>distinct</strong> indices <code>i</code> and <code>j</code>, where <code>words[i]</code> is a non-empty string, and move <strong>any</strong> character from <code>words[i]</code> to <strong>a...
1
{ "code": "class Solution {\npublic:\n bool makeEqual(vector<string>& words) {\n ios_base::sync_with_stdio(false);\n cin.tie(0);\n cout.tie(0);\n\n vector<int>freq(26,0);\n int n=words.size();\n\n for(string &word:words){\n\n for(char &c:word) freq[c-'a']++;\n ...
2,025
<p>You are given an array of strings <code>words</code> (<strong>0-indexed</strong>).</p> <p>In one operation, pick two <strong>distinct</strong> indices <code>i</code> and <code>j</code>, where <code>words[i]</code> is a non-empty string, and move <strong>any</strong> character from <code>words[i]</code> to <strong>a...
1
{ "code": "class Solution {\npublic:\n bool makeEqual(vector<string>& words) {\n ios_base::sync_with_stdio(false);\n cin.tie(0);\n cout.tie(0);\n\n vector<int>freq(26,0);\n int n=words.size();\n\n for(string &word:words){\n\n for(char &c:word) freq[c-'a']++;\n ...
2,025
<p>You are given an array of strings <code>words</code> (<strong>0-indexed</strong>).</p> <p>In one operation, pick two <strong>distinct</strong> indices <code>i</code> and <code>j</code>, where <code>words[i]</code> is a non-empty string, and move <strong>any</strong> character from <code>words[i]</code> to <strong>a...
1
{ "code": "class Solution {\npublic:\n bool makeEqual(vector<string>& words) {\n ios_base::sync_with_stdio(false);\n cin.tie(0);\n cout.tie(0);\n\n vector<int>freq(26,0);\n \n for(string &word:words){\n\n for(char &c:word) freq[c-'a']++;\n }\n\n f...
2,025
<p>You are given an array of strings <code>words</code> (<strong>0-indexed</strong>).</p> <p>In one operation, pick two <strong>distinct</strong> indices <code>i</code> and <code>j</code>, where <code>words[i]</code> is a non-empty string, and move <strong>any</strong> character from <code>words[i]</code> to <strong>a...
1
{ "code": "class Solution {\npublic:\n bool makeEqual(vector<string>& words) {\n unordered_map<char, int> mp;\n for (string& it : words) {\n for (char& ch : it) {\n mp[ch]++;\n }\n }\n int size = words.size();\n for (auto [key, value] : mp) {\...
2,025
<p>You are given an array of strings <code>words</code> (<strong>0-indexed</strong>).</p> <p>In one operation, pick two <strong>distinct</strong> indices <code>i</code> and <code>j</code>, where <code>words[i]</code> is a non-empty string, and move <strong>any</strong> character from <code>words[i]</code> to <strong>a...
1
{ "code": "class Solution {\npublic:\n bool makeEqual(vector<string>& words) {\n int n = words.size();\n unordered_map<char,int> mp;\n for(int i=0; i<words.size(); i++){\n for(int j=0; j<words[i].size(); j++){\n mp[words[i][j]]++;\n }\n }\n fo...
2,025
<p>You are given an array of strings <code>words</code> (<strong>0-indexed</strong>).</p> <p>In one operation, pick two <strong>distinct</strong> indices <code>i</code> and <code>j</code>, where <code>words[i]</code> is a non-empty string, and move <strong>any</strong> character from <code>words[i]</code> to <strong>a...
1
{ "code": "class Solution {\npublic:\n bool makeEqual(vector<string>& words) {\n unordered_map<char,int> mpp;\n int n=words.size();\n for(int i=0;i<n;i++)\n {\n for(int j=0;j<words[i].size();j++)\n {\n mpp[words[i][j]]++;\n }\n }\n ...
2,025
<p>You are given an array of strings <code>words</code> (<strong>0-indexed</strong>).</p> <p>In one operation, pick two <strong>distinct</strong> indices <code>i</code> and <code>j</code>, where <code>words[i]</code> is a non-empty string, and move <strong>any</strong> character from <code>words[i]</code> to <strong>a...
2
{ "code": "class Solution {\npublic:\n bool makeEqual(vector<string>& words) {\n unordered_map<char, int> freqmp ;\n \n for(const string &word: words){\n for(char c: word){\n freqmp[c]=freqmp[c]+1 ;\n }\n }\n\n int n=words.size();\n for...
2,025
<p>You are given an array of strings <code>words</code> (<strong>0-indexed</strong>).</p> <p>In one operation, pick two <strong>distinct</strong> indices <code>i</code> and <code>j</code>, where <code>words[i]</code> is a non-empty string, and move <strong>any</strong> character from <code>words[i]</code> to <strong>a...
2
{ "code": "class Solution {\npublic:\n bool makeEqual(vector<string>& words) {\n \n unordered_map<char,int>mp;\n for(int i=0;i<words.size();i++)\n {\n for(int j=0;j<words[i].size();j++)\n {\n mp[words[i][j]]++;\n }\n }\n int ...
2,025
<p>You are given an array of strings <code>words</code> (<strong>0-indexed</strong>).</p> <p>In one operation, pick two <strong>distinct</strong> indices <code>i</code> and <code>j</code>, where <code>words[i]</code> is a non-empty string, and move <strong>any</strong> character from <code>words[i]</code> to <strong>a...
2
{ "code": "class Solution {\npublic:\n bool makeEqual(vector<string>& words) {\n map<char,int> mpp;\n string str = \"\";\n for(int i=0;i<words.size();i++){\n for(int j=0;j<words[i].size();j++){\n if(mpp[words[i][j]]<=0){\n str+=words[i][j];\n ...
2,025
<p>You are given an array of strings <code>words</code> (<strong>0-indexed</strong>).</p> <p>In one operation, pick two <strong>distinct</strong> indices <code>i</code> and <code>j</code>, where <code>words[i]</code> is a non-empty string, and move <strong>any</strong> character from <code>words[i]</code> to <strong>a...
2
{ "code": "class Solution {\npublic:\n bool makeEqual(vector<string>& words) {\n int n = words.size();\n vector<int> chars(26, 0);\n for(string s:words){\n for(char c:s){\n chars[c-'a']++;\n }\n }\n for(int i:chars){\n if(i%n!=0)\n ...
2,025
<p>You are given an array of strings <code>words</code> (<strong>0-indexed</strong>).</p> <p>In one operation, pick two <strong>distinct</strong> indices <code>i</code> and <code>j</code>, where <code>words[i]</code> is a non-empty string, and move <strong>any</strong> character from <code>words[i]</code> to <strong>a...
2
{ "code": "class Solution {\npublic:\n bool makeEqual(vector<string>& words) {\n vector<int> counts(26, 0);\n for (string word : words) {\n for (char c : word) {\n counts[c - 'a']++;\n }\n }\n \n int n = words.size();\n for (int val : c...
2,025
<p>You are given an array of strings <code>words</code> (<strong>0-indexed</strong>).</p> <p>In one operation, pick two <strong>distinct</strong> indices <code>i</code> and <code>j</code>, where <code>words[i]</code> is a non-empty string, and move <strong>any</strong> character from <code>words[i]</code> to <strong>a...
2
{ "code": "class Solution {\npublic:\n bool makeEqual(vector<string>& words) {\n vector<int>freq(26);\n \n for(int i=0;i<words.size();i++){\n string w=words[i];\n \n for(int j=0;j<w.size();j++){\n char ch=w[j];\n int index=(int)(ch-'a'...
2,025
<p>You are given an array of strings <code>words</code> (<strong>0-indexed</strong>).</p> <p>In one operation, pick two <strong>distinct</strong> indices <code>i</code> and <code>j</code>, where <code>words[i]</code> is a non-empty string, and move <strong>any</strong> character from <code>words[i]</code> to <strong>a...
2
{ "code": "class Solution {\npublic:\n bool makeEqual(vector<string>& words) {\n if (words.size() == 1) return true;\n unordered_map<char, int> mp;\n for(string w : words){\n for(char c : w){\n mp[c]++;\n }\n }\n for(auto& pair : mp){\n ...
2,025
<p>You are given an array of strings <code>words</code> (<strong>0-indexed</strong>).</p> <p>In one operation, pick two <strong>distinct</strong> indices <code>i</code> and <code>j</code>, where <code>words[i]</code> is a non-empty string, and move <strong>any</strong> character from <code>words[i]</code> to <strong>a...
2
{ "code": "class Solution {\npublic:\n bool makeEqual(vector<string>& words) {\n unordered_map<char, int> mp;\n\n for (auto w: words)\n {\n for (auto c: w)\n {\n mp[c]++;\n }\n }\n\n int n = words.size();\n for (auto count : ...
2,025
<p>You are given an array of strings <code>words</code> (<strong>0-indexed</strong>).</p> <p>In one operation, pick two <strong>distinct</strong> indices <code>i</code> and <code>j</code>, where <code>words[i]</code> is a non-empty string, and move <strong>any</strong> character from <code>words[i]</code> to <strong>a...
2
{ "code": "class Solution {\npublic:\n bool makeEqual(vector<string>& words) {\n int n=words.size();\n unordered_map<char,int>mp;\n\n for(const string word:words)\n {\n for(char x:word)\n {\n mp[x]++;\n }\n }\n for(auto x:mp)...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
0
{ "code": "class Solution {\nprivate:\n void append(string& s, const char *opnd, const char *&fs) {\n s += fs;\n fs = \" \";\n\n s += opnd;\n }\n\npublic:\n string numberToWords(int num) {\n bool zf;\n const char *fs;\n const char *const *ones_tbl;\n int exp;\...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
0
{ "code": "constexpr array<char*, 27> english_numbers = {\n \"One\", \"Two\", \"Three\", \"Four\", \"Five\", \"Six\",\n \"Seven\", \"Eight\", \"Nine\", \"Ten\", \"Eleven\", \"Twelve\",\n \"Thirteen\", \"Fourteen\", \"Fifteen\", \"Sixteen\", \"Seventeen\", \"Eighteen\",\n ...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
0
{ "code": "class Solution {\n static constexpr string_view units[]{\n \"\", \"One \", \"Two \", \"Three \", \"Four \",\n \"Five \", \"Six \", \"Seven \", \"Eight \", \"Nine \",\n \"Ten \", \"Eleven \", \"Twelve \", \"Thirteen \", \"Fourteen \",\n \"Fifteen \", \"Sixteen \", \"Seventeen ...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
0
{ "code": "static constexpr std::string_view start_nums[]{\n \"One \", \"Two \", \"Three \", \"Four \", \"Five \",\n \"Six \", \"Seven \", \"Eight \", \"Nine \", \"Ten \",\n \"Eleven \", \"Twelve \", \"Thirteen \", \"Fourteen \", \"Fifteen \",\n \"Sixteen \", \"Seventee...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
0
{ "code": "static constexpr std::string_view start_nums[]{\n \"\", \"One \", \"Two \", \"Three \", \"Four \",\n \"Five \", \"Six \", \"Seven \", \"Eight \", \"Nine \",\n \"Ten \", \"Eleven \", \"Twelve \", \"Thirteen \", \"Fourteen \",\n \"Fifteen \", \"Sixteen \...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
0
{ "code": "static constexpr std::string_view start_nums[]{\n \"One\", \"Two\", \"Three\", \"Four\", \"Five\",\n \"Six\", \"Seven\", \"Eight\", \"Nine\", \"Ten\",\n \"Eleven\", \"Twelve\", \"Thirteen\", \"Fourteen\", \"Fifteen\",\n \"Sixteen\", \"Seventeen\", \"Eighteen\...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
0
{ "code": "class Solution {\npublic:\n string ntw(int num){\n string ans;\n int x=num/100;\n int y=(num/10)%10;\n int z=num%10;\n if(x!=0){\n if(x==1) ans+=\"One \";\n else if(x==2) ans+=\"Two \";\n else if(x==3) ans+=\"Three \";\n else...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
0
{ "code": "class Solution {\nprivate:\nvoid parseDigits(std::string& result, int digit)\n{\n switch(digit)\n {\n case 1:\n result += \" One\";\n break;\n case 2:\n result += \" Two\";\n break;\n case 3:\n result += \" Three\";\n break;\n case 4:\n result += \" Four\";\n break;\n case 5:...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
0
{ "code": "class Solution {\npublic:\n string numberToWords(int num) { \n string ans;\n //zero\n if(num == 0)\n return \"Zero\";\n\n //billions \n ans += thousands(num/1000000000);\n if(num/1000000000 != 0)\n ans+= \"Billion \";\n\n //millions\n ...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
0
{ "code": "const string digits[] = { \"-\", \"One\", \"Two\", \"Three\", \"Four\", \"Five\", \"Six\", \"Seven\", \"Eight\", \"Nine\" };\nconst string specialTwoDigitsNames[] = { \"Eleven\", \"Twelve\", \"Thirteen\", \"Fourteen\", \"Fifteen\", \"Sixteen\", \"Seventeen\", \"Eighteen\", \"Nineteen\" };\nconst string ten...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
0
{ "code": "class Solution {\npublic:\n void Print1(int x, stringstream &ss){\n switch (x) {\n case 1 : ss << \"One \"; break;\n case 2 : ss << \"Two \"; break;\n case 3 : ss << \"Three \"; break;\n case 4 : ss << \"Four \"; break;\n ...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
0
{ "code": "string eng[] = {\"\", \"One\", \"Two\", \"Three\", \"Four\",\n \"Five\", \"Six\", \"Seven\", \"Eight\", \"Nine\",\n \"Ten\", \"Eleven\", \"Twelve\", \"Thirteen\", \"Fourteen\",\n \"Fifteen\", \"Sixteen\", \"Seventeen\", ...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
0
{ "code": "string eng[] = {\"\", \"One\", \"Two\", \"Three\", \"Four\",\n \"Five\", \"Six\", \"Seven\", \"Eight\", \"Nine\",\n \"Ten\", \"Eleven\", \"Twelve\", \"Thirteen\", \"Fourteen\",\n \"Fifteen\", \"Sixteen\", \"Seventeen\", ...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
0
{ "code": "string eng[] = { \"\", \"One\", \"Two\", \"Three\",\n \"Four\", \"Five\", \"Six\", \"Seven\",\n \"Eight\", \"Nine\", \"Ten\", \"Eleven\",\n \"Twelve\", \"Thirteen\", \"Fourteen\", \"Fifteen\",\n...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
0
{ "code": "class Solution {\npublic:\n string numberToWords(const int num) const {\n if(num == 0) {\n return \"Zero\";\n }\n std::stringstream str;\n\n const auto single = [&](const auto n) {\n static constexpr std::array<std::string_view, 10> lookup{\n ...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
0
{ "code": "class Solution {\npublic:\n string numberToWords(const int num) const {\n if(num == 0) {\n return \"Zero\";\n }\n std::stringstream str;\n\n const auto single = [&](const auto n) {\n static constexpr std::array<const char*, 10> lookup{\n \...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
0
{ "code": "class Solution {\npublic:\n\n // 1-9 , 1 digit\n string one(int num) {\n switch(num) {\n case 1: return \"One\";\n case 2: return \"Two\";\n case 3: return \"Three\";\n case 4: return \"Four\";\n case 5: return \"Five\";\n case 6: return \"Six\";\n case 7: return...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
0
{ "code": "constexpr int thousand = 1000;\nconstexpr int million = thousand * thousand;\nconstexpr int billion = million * thousand;\n\nconstexpr char* a[10] = {\n \"\", \"One\", \"Two\", \"Three\", \"Four\", \"Five\", \"Six\", \"Seven\", \"Eight\", \"Nine\"\n};\nconstexpr char* b[10] = {\n \"\", \"\", \"\", \"...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
0
{ "code": "class Solution {\npublic:\n string getSingle(int num) {\n switch (num) {\n case 1:\n return \"One\";\n case 2:\n return \"Two\";\n case 3: \n return \"Three\";\n case 4:\n return \"Four\";\n ...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
0
{ "code": "class Solution {\npublic:\n string hundred(int num) {\n int hundred = num / 100;\n int rest = num - hundred * 100;\n string res = \"\";\n if (hundred*rest != 0)\n res = one(hundred) + \" Hundred \" + two(rest);\n else if ((hundred == 0) && (rest != 0))\n res = two(rest);\n el...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
0
{ "code": "string eng[] = {\"\", \"One\", \"Two\", \"Three\", \"Four\",\n \"Five\", \"Six\", \"Seven\", \"Eight\", \"Nine\",\n \"Ten\", \"Eleven\", \"Twelve\", \"Thirteen\", \"Fourteen\",\n \"Fifteen\", \"Sixteen\", \"Seventeen\", ...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
0
{ "code": "string eng[] = {\"\", \"One\", \"Two\", \"Three\", \"Four\",\n \"Five\", \"Six\", \"Seven\", \"Eight\", \"Nine\",\n \"Ten\", \"Eleven\", \"Twelve\", \"Thirteen\", \"Fourteen\",\n \"Fifteen\", \"Sixteen\", \"Seventeen\", ...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
0
{ "code": "string eng[] = {\"\", \"One\", \"Two\", \"Three\", \"Four\",\n \"Five\", \"Six\", \"Seven\", \"Eight\", \"Nine\",\n \"Ten\", \"Eleven\", \"Twelve\", \"Thirteen\", \"Fourteen\",\n \"Fifteen\", \"Sixteen\", \"Seventeen\", ...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
0
{ "code": "#include <string>\n\nclass Solution {\npublic:\nstd::string classes[4] = {\"\", \"Thousand\", \"Million\", \"Billion\"};\n\nstd::string digits[10] = {\"Zero\", \"One\", \"Two\", \"Three\", \"Four\", \"Five\", \"Six\", \"Seven\", \"Eight\", \"Nine\"};\n\nstd::string numbers[10] = {\"Zero\", \"Ten\", \"Twent...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
0
{ "code": " // Create and initialize map<int, string> m1\n map<int, string>below10= {\n {1, \"One \"},\n {2, \"Two \"},\n {3, \"Three \"},\n {4, \"Four \"},\n {5, \"Five \"},\n {6, \"Six \"},\n {7, \"Seven \"},\n {8, \"Eight \"},\n {9, \"Nine \"}\n ...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
0
{ "code": "#include <string>\n\nclass Solution {\npublic:\nstd::string classes[4] = {\"\", \"Thousand\", \"Million\", \"Billion\"};\n\nstd::string digits[10] = {\"Zero\", \"One\", \"Two\", \"Three\", \"Four\", \"Five\", \"Six\", \"Seven\", \"Eight\", \"Nine\"};\n\nstd::string numbers[10] = {\"Zero\", \"Ten\", \"Twent...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
0
{ "code": "class Solution {\npublic:\n string numberToWords(int num) {\n if(num == 0) return \"Zero\";\n\n std::string number_words[] {\n \"\", \"One \", \"Two \", \"Three \", \"Four \", \"Five \", \"Six \", \"Seven \", \"Eight \", \"Nine \",\n \"Ten \", \"Eleven \", \"Twelve \", \"Thirteen \",...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
0
{ "code": "class Solution {\npublic:\n string numberToWords(int num) {\n if(num == 0) return \"Zero\";\n\n std::string number_words[] {\n \"\", \"One \", \"Two \", \"Three \", \"Four \", \"Five \", \"Six \", \"Seven \", \"Eight \", \"Nine \",\n \"Ten \", \"Eleven \", \"Twelve \", \"Thirteen \",...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
0
{ "code": "#include <string>\nusing namespace std;\n\nclass Solution {\n string belowten[10] = {\"\", \"One\", \"Two\", \"Three\", \"Four\", \"Five\", \"Six\", \"Seven\", \"Eight\", \"Nine\"};\n string belowtwenty[10] = {\"Ten\", \"Eleven\", \"Twelve\", \"Thirteen\", \"Fourteen\", \"Fifteen\", \"Sixteen\", \"Se...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
0
{ "code": "class Solution {\npublic:\n string f(int a,int b,int c){\n // a=0th, b=1st, c=2nh index\n \n string ans;\n if(c==1) ans=ans+ \"One \";\n if(c==2) ans=ans+ \"Two \";\n if(c==3) ans=ans+ \"Three \";\n if(c==4) ans=ans+ \"Four \";\n if(c=...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
0
{ "code": "class Solution {\npublic:\n string numberToWords(int num) {\n if(num == 0) return \"Zero\";\n\n std::string number_words[] {\n \"\", \"One \", \"Two \", \"Three \", \"Four \", \"Five \", \"Six \", \"Seven \", \"Eight \", \"Nine \",\n \"Ten \", \"Eleven \", \"Twelve \", \"Thirteen \",...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
0
{ "code": "class Solution {\npublic:\n string numberToWords(int num) {\n if (num == 0) return \"Zero\";\n \n string bigString[] = {\"Thousand\", \"Million\", \"Billion\"};\n string result = numberToWordsHelper(num % 1000);\n num /= 1000;\n\n for (int i = 0; i < 3; ++i) {\n...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
0
{ "code": "class Solution {\npublic:\n string numberToWords(int num) {\n if (num == 0) return \"Zero\";\n \n string bigString[] = {\"Thousand\", \"Million\", \"Billion\"};\n string result = numberToWordsHelper(num % 1000);\n num /= 1000;\n\n for (int i = 0; i < 3; ++i) {\n...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
0
{ "code": "class Solution {\npublic:\n string numberToWords(int num) {\n if (num == 0) return \"Zero\";\n \n string bigString[] = {\"Thousand\", \"Million\", \"Billion\"};\n string result = numberToWordsHelper(num % 1000);\n num /= 1000;\n\n for (int i = 0; i < 3; ++i) {\n...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
0
{ "code": "class Solution {\npublic:\n string numberToWords(int num) {\n if (num == 0) return \"Zero\";\n \n string bigString[] = {\"Thousand\", \"Million\", \"Billion\"};\n string result = numberToWordsHelper(num % 1000);\n num /= 1000;\n\n for (int i = 0; i < 3; ++i) {\n...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
0
{ "code": "class Solution {\npublic:\n string numberToWords(int num) {\n if (num == 0) return \"Zero\";\n \n string bigString[] = {\"Thousand\", \"Million\", \"Billion\"};\n string result = numberToWordsHelper(num % 1000);\n num /= 1000;\n\n for (int i = 0; i < 3; ++i) {\n...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
1
{ "code": "class Solution {\npublic:\n string ones[20]={\"\", \" One\", \" Two\", \" Three\", \" Four\", \" Five\", \" Six\", \" Seven\", \" Eight\", \" Nine\", \" Ten\", \" Eleven\", \" Twelve\", \" Thirteen\", \" Fourteen\", \" Fifteen\", \" Sixteen\", \" Seventeen\", \" Eighteen\", \" Nineteen\"};\n string t...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
1
{ "code": "class Solution {\npublic:\n string numberToWords(int n) {\n if (!n)\n return \"Zero\";\n\n const vector<string> a = {\"\", \"One\", \"Two\", \"Three\", \"Four\", \"Five\", \"Six\", \"Seven\", \"Eight\", \"Nine\", \"Ten\", \"Eleven\", \"Twelve\", \"Thirteen\", \"Fourteen\", \"Fif...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
1
{ "code": "class Solution {\npublic:\n void appendOneToNineteen(int num, vector<string> &fragments) {\n switch(num) {\n case 1:\n fragments.push_back(\"One\");\n num -= 1;\n break;\n case 2:\n fragments.push_back(\"Two\");\n ...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
1
{ "code": "class Solution {\n public:\n string numberToWords(int num) {\n if (num == 0)\n return \"Zero\";\n return helper(num);\n }\n\n private:\n const vector<string> belowTwenty{\n \"\", \"One\", \"Two\", \"Three\", \"Four\",\n \"Five\", \"Six\", \"Seven\", \"...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
1
{ "code": "class Solution {\npublic:\n string numberToWords(int n) {\n if (!n)\n return \"Zero\";\n\n const vector<string> a = {\"\", \"One\", \"Two\", \"Three\", \"Four\", \"Five\", \"Six\", \"Seven\", \"Eight\", \"Nine\", \"Ten\", \"Eleven\", \"Twelve\", \"Thirteen\", \"Fourteen\", \"Fif...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
1
{ "code": "class Solution {\n public:\n string numberToWords(int num) {\n if (num == 0)\n return \"Zero\";\n return helper(num);\n }\n\n private:\n const vector<string> belowTwenty{\n \"\", \"One\", \"Two\", \"Three\", \"Four\",\n \"Five\", \"Six\", \"Seven\", \"...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
1
{ "code": "class Solution {\npublic:\n // Arrays to store words for numbers less than 10, 20, and 100\n const vector<string> belowTen = { \"\", \"One\", \"Two\", \"Three\", \"Four\", \"Five\", \"Six\", \"Seven\", \"Eight\", \"Nine\" };\n const vector<string> belowTwenty = { \"Ten\", \"Eleven\", \"Twelve\", \...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
1
{ "code": "class Solution {\npublic:\n // Arrays to store words for numbers less than 10, 20, and 100\n const vector<string> belowTen = { \"\", \"One\", \"Two\", \"Three\", \"Four\", \"Five\", \"Six\", \"Seven\", \"Eight\", \"Nine\" };\n const vector<string> belowTwenty = { \"Ten\", \"Eleven\", \"Twelve\", \...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
1
{ "code": "class Solution {\n\npublic:\n\n // Arrays to store words for numbers less than 10, 20, and 100\n\n const vector<string> belowTen = { \"\", \"One\", \"Two\", \"Three\", \"Four\", \"Five\", \"Six\", \"Seven\", \"Eight\", \"Nine\" };\n\n const vector<string> belowTwenty = { \"Ten\", \"Eleven\", \"Twe...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
1
{ "code": "class Solution {\n\npublic:\n\n // Arrays to store words for numbers less than 10, 20, and 100\n\n const vector<string> belowTen = { \"\", \"One\", \"Two\", \"Three\", \"Four\", \"Five\", \"Six\", \"Seven\", \"Eight\", \"Nine\" };\n\n const vector<string> belowTwenty = { \"Ten\", \"Eleven\", \"Twe...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
2
{ "code": "class Solution {\npublic:\n string numberToWords(int num) {\n if (num == 0){\n return \"Zero\";\n }\n vector<string> ones_hundreds = {\"\", \"One\", \"Two\", \"Three\", \"Four\", \"Five\", \"Six\", \"Seven\", \"Eight\", \"Nine\"};\n vector<string> tens_m1 = {\"\", ...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
2
{ "code": "class Solution {\npublic:\n vector<string> one = {\"\", \"One\", \"Two\", \"Three\", \"Four\", \"Five\", \"Six\", \"Seven\", \"Eight\", \"Nine\", \"Ten\", \"Eleven\", \"Twelve\", \"Thirteen\", \"Fourteen\", \"Fifteen\", \"Sixteen\", \"Seventeen\", \"Eighteen\", \"Nineteen\"};\n vector<string> zer...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
2
{ "code": "class Solution {\npublic:\n string numberToWords(int num) {\n if (num == 0)\n return \"Zero\";\n\n string result;\n\n // Process billions\n int billion = num / 1000000000;\n if (billion) {\n result += threeDigitsToWords(billion) + \" Billion\";\n ...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
2
{ "code": "class Solution {\npublic:\n string num2word(int num) {\n string ans;\n if (num >= 100) {\n ans.append(digit1[num / 100]);\n ans.append(\"Hundred \");\n num %= 100;\n }\n if (num >= 10) {\n if (num >= 11 && num <= 19) {\n ...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
2
{ "code": "class Solution {\npublic:\n unordered_map<int,string> below_ten={{0,\"\"},{1,\"One\"},{2,\"Two\"},{3,\"Three\"},{4,\"Four\"},\n {5,\"Five\"},{6,\"Six\"},{7,\"Seven\"},{8,\"Eight\"},{9,\"Nine\"}};\n unordered_map<int,string> below_twenty={{10,\"Ten\"},{11,\"Eleven\"},{12,\"Twelve\"},{13,\"Thirt...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
2
{ "code": "class Solution {\nprivate:\n vector<string> ones = {\"\", \"One\", \"Two\", \"Three\", \"Four\", \"Five\", \"Six\", \"Seven\", \"Eight\", \"Nine\", \"Ten\", \n \"Eleven\", \"Twelve\", \"Thirteen\", \"Fourteen\", \"Fifteen\", \"Sixteen\", \"Seventeen\", \"Eighteen\", \"Nineteen\...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
2
{ "code": "class Solution {\npublic:\nvector<pair<int, string>> mp = {\n {1000000000, \"Billion\"}, {1000000, \"Million\"}, {1000, \"Thousand\"}, {100, \"Hundred\"},\n {90, \"Ninety\"}, {80, \"Eighty\"}, {70, \"Seventy\"}, {60, \"Sixty\"}, {50, \"Fifty\"},\n {40, \"Forty\"}, {30, \"Thirty\"}, {20, \"Twenty\"...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
2
{ "code": "class Solution {\npublic:\n string numberToWords(int num) {\n unordered_map<int, string> numToStr {{1, \"One\"}, {2, \"Two\"}, {3, \"Three\"}, {4, \"Four\"}, {5, \"Five\"}, {6, \"Six\"}, {7, \"Seven\"}, {8, \"Eight\"}, {9, \"Nine\"}, {10, \"Ten\"}, {11, \"Eleven\"}, {12, \"Twelve\"}, {13, \"Thirt...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
2
{ "code": "class Solution {\npublic:\n const vector<string> belowTwenty{\"\", \"One\", \"Two\", \"Three\", \"Four\",\"Five\", \"Six\", \"Seven\", \"Eight\", \"Nine\", \"Ten\", \"Eleven\", \"Twelve\", \"Thirteen\", \"Fourteen\", \"Fifteen\", \"Sixteen\", \"Seventeen\", \"Eighteen\", \"Nineteen\"};\n const vector...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
2
{ "code": "class Solution {\npublic:\n string numberToWords(int num) {\n if(num == 0) return \"Zero\";\n\n std::unordered_map<int, std::string> word_map = {\n {0, \"\"},\n {1, \"One \"},\n {2, \"Two \"},\n {3, \"Three \"},\n {4, \"Four \"},\n {5, \"Five \"},\n ...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
2
{ "code": "class Solution {\npublic:\n string numberToWords(int num) {\n if(num == 0) return \"Zero\";\n\n std::unordered_map<int, std::string> word_map = {\n {0, \"\"},\n {1, \"One \"},\n {2, \"Two \"},\n {3, \"Three \"},\n {4, \"Four \"},\n {5, \"Five \"},\n ...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
2
{ "code": "class Solution {\npublic:\n vector<string> lessThan20 = {\n \"Zero\",\n \"One\",\n \"Two\",\n \"Three\",\n \"Four\",\n \"Five\",\n \"Six\",\n \"Seven\",\n \"Eight\",\n \"Nine\",\n \"Ten\",\n \"Eleven\",\n \"Twelve...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
3
{ "code": "class Solution {\npublic:\n string numberToWords(int num) {\n vector<int> numbers = {\n 1000000000, 1000000, 1000, 100, 90, 80, 70, 60, 50, 40, 30, 20,\n 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1\n }; \n\n vector<string> words = {\n ...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
3
{ "code": "class Solution {\n public:\n string numberToWords(int num) {\n vector<int> numbers = {\n 1000000000, 1000000, 1000, 100, 90, 80, 70, 60, 50, 40, 30, 20,\n 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, ...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
3
{ "code": "class Solution {\nprivate:\nstring convertLessThanThousand(int num){\n vector<string>belowTwenty={\"\",\"One\",\"Two\",\"Three\",\"Four\",\"Five\",\"Six\",\"Seven\", \"Eight\", \"Nine\", \"Ten\",\n \"Eleven\", \"Twelve\", \"Thirteen\", \"Fourteen\", \"Fifteen\", \"Sixtee...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
3
{ "code": "class Solution {\npublic:\n string numberToWords(int num) {\n if(num == 0) return \"Zero\";\n\n std::vector<std::string> number_words {\n \"\", \"One \", \"Two \", \"Three \", \"Four \", \"Five \", \"Six \", \"Seven \", \"Eight \", \"Nine \",\n \"Ten \", \"Eleven \", \"Twelve \", \"T...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
3
{ "code": "class Solution {\npublic:\n string numberToWords(int num) {\n if(num == 0) return \"Zero\";\n\n std::vector<std::string> number_words {\n \"\", \"One \", \"Two \", \"Three \", \"Four \", \"Five \", \"Six \", \"Seven \", \"Eight \", \"Nine \",\n \"Ten \", \"Eleven \", \"Twelve \", \"T...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
3
{ "code": "class Solution {\n string powers[4] = {\"\",\"Thousand\",\"Million\", \"Billion\"}; \n unordered_map<int,string>conversion_map; //single and two digits\npublic:\n string get_english(vector<int>& digits, int idx1, int idx2, int idx3)\n {\n string converted = \"\";\n if(idx1 >=0 && ...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
3
{ "code": "class Solution {\npublic:\n vector<string> ones = {\"One\", \"Two\",\"Three\",\"Four\",\"Five\",\"Six\",\"Seven\",\"Eight\",\"Nine\"};\n vector<string> teens = {\"Eleven\",\"Twelve\",\"Thirteen\",\"Fourteen\",\"Fifteen\",\"Sixteen\",\"Seventeen\",\"Eighteen\",\"Nineteen\"};\n vector<string> tens =...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
3
{ "code": "class Solution {\npublic:\n unordered_map<int, string> belowTen = {{0, \"\"}, {1, \"One \"}, {2, \"Two \"}, {3, \"Three \"}, {4, \"Four \"}, {5, \"Five \"}, {6, \"Six \"}, {7, \"Seven \"}, {8, \"Eight \"}, {9, \"Nine \"}};\n unordered_map<int, string> belowTwenty = {{11, \"Eleven \"}, {12, \"Twelve \...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
3
{ "code": "class Solution {\n string oneDigit(int a0) {\n const vector<string> result{\n \"\", \"One\", \"Two\", \"Three\", \"Four\", \"Five\",\n \"Six\", \"Seven\", \"Eight\", \"Nine\"\n };\n\n return result[a0];\n }\n\n string twoDigit(int a1, int a0) {\n c...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
3
{ "code": "class Solution {\npublic:\n vector<string> ones = {\"One \",\"Two \",\"Three \",\"Four \",\"Five \",\"Six \",\"Seven \",\"Eight \",\"Nine \"};\n vector<string> teens = {\"Ten \",\"Eleven \",\"Twelve \",\"Thirteen \",\"Fourteen \",\"Fifteen \",\"Sixteen \",\"Seventeen \",\"Eighteen \",\"Nineteen \"};\...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
3
{ "code": "class Solution \n{\n\n map<int, string> number {{1, \"One\"}, {2, \"Two\"}, {3, \"Three\"}, {4, \"Four\"}, {5, \"Five\"}, {6, \"Six\"}, {7, \"Seven\"}, {8, \"Eight\"}, {9, \"Nine\"}};\n map<int, string> teens {{1, \"Eleven\"}, {2, \"Twelve\"}, {3, \"Thirteen\"}, {4, \"Fourteen\"}, {5, \"Fifteen\"}, {...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
3
{ "code": "class Solution \n{\n\n map<int, string> number {{1, \"One\"}, {2, \"Two\"}, {3, \"Three\"}, {4, \"Four\"}, {5, \"Five\"}, {6, \"Six\"}, {7, \"Seven\"}, {8, \"Eight\"}, {9, \"Nine\"}};\n map<int, string> teens {{1, \"Eleven\"}, {2, \"Twelve\"}, {3, \"Thirteen\"}, {4, \"Fourteen\"}, {5, \"Fifteen\"}, {...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
3
{ "code": "class Solution {\npublic:\n string trim(const string& str) {\n string result = str;\n\n result.erase(result.begin(), find_if(result.begin(), result.end(), [](unsigned char ch) {\n return !isspace(ch);\n }));\n\n result.erase(find_if(result.rbegin(), result.rend(), [](unsigned char ch)...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
3
{ "code": "class Solution {\npublic:\n map<int, string> createMap() {\n map<int, string> mp;\n\n // Numbers 1 to 19\n mp[1] = \"One\"; mp[2] = \"Two\"; mp[3] = \"Three\";\n mp[4] = \"Four\"; mp[5] = \"Five\"; mp[6] = \"Six\";\n mp[7] = \"Seven\"; mp[8] = \"Eight\"; mp[9] = \"Nine\";\n mp[10] = \"T...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
3
{ "code": "class Solution {\npublic:\n string findDigit( vector<int> digits, int st, int end ){\n\n // cout<<\"Attempting for \"<<st<<\" to \"<<end<<\" \"<<digits[st]<<digits[st+1]<<digits[st+2]<<endl;\n // int num = 0;\n\n vector<string> digitStr = { \"\", \"One\", \"Two\", \"Three\",\"Four\"...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
3
{ "code": "class Solution {\npublic:\n string findDigit( vector<int> digits, int st, int end ){\n\n // cout<<\"Attempting for \"<<st<<\" to \"<<end<<\" \"<<digits[st]<<digits[st+1]<<digits[st+2]<<endl;\n // int num = 0;\n\n vector<string> digitStr = { \"\", \"One\", \"Two\", \"Three\",\"Four\"...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
3
{ "code": "class Solution {\npublic:\n string numberToWords(int num) {\n if(num==0)return \"Zero\";\n map<int,string>p;\n \n p[1]=\"One \";\n p[2]=\"Two \";\n p[3]=\"Three \";\n p[4]=\"Four \";\n p[5]=\"Five \";\n p[6]=\"Six \";\n p[7]=\"Seven \";...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
3
{ "code": "class Solution {\n\nprivate:\n unordered_map<int, string> integer_to_word_map;\n string getWordsForSegment(string input) {\n if (input.length() == 1) {\n int value = input[0] - '0';\n return integer_to_word_map[value];\n } else if (input.length() == 2) {\n ...
273
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
3
{ "code": "class Solution {\n\nprivate:\n unordered_map<int, string> integer_to_word_map;\n string getWordsForSegment(string input) {\n if (input.length() == 1) {\n int value = input[0] - '0';\n return integer_to_word_map[value];\n } else if (input.length() == 2) {\n ...
274
<p>Given an array of integers <code>citations</code> where <code>citations[i]</code> is the number of citations a researcher received for their <code>i<sup>th</sup></code> paper, return <em>the researcher&#39;s h-index</em>.</p> <p>According to the <a href="https://en.wikipedia.org/wiki/H-index" target="_blank">defini...
0
{ "code": "class Solution {\npublic:\n int hIndex(vector<int>& citations) {\n int n = citations.size();\n sort(citations.begin(), citations.end());\n int h = n;\n while (h > 0) {\n if (citations[n - h] >= h) break;\n h--;\n }\n return h;\n }\n};", ...
274
<p>Given an array of integers <code>citations</code> where <code>citations[i]</code> is the number of citations a researcher received for their <code>i<sup>th</sup></code> paper, return <em>the researcher&#39;s h-index</em>.</p> <p>According to the <a href="https://en.wikipedia.org/wiki/H-index" target="_blank">defini...
0
{ "code": "class Solution {\npublic:\n int hIndex(vector<int>& arr) {\n sort(arr.begin(),arr.end(),greater<int>());\n int ans=0,n=arr.size(),curr=0;\n for(int i=0;i<n;i++){\n curr++;\n if(arr[i]>=curr){\n ans=max(ans,curr);\n }\n }\n ...
274
<p>Given an array of integers <code>citations</code> where <code>citations[i]</code> is the number of citations a researcher received for their <code>i<sup>th</sup></code> paper, return <em>the researcher&#39;s h-index</em>.</p> <p>According to the <a href="https://en.wikipedia.org/wiki/H-index" target="_blank">defini...
0
{ "code": "class Solution {\npublic:\n int hIndex(vector<int>& cits) {\n int n = cits.size();\n \n int left = 1;\n int right = n;\n\n while(left <= right){\n int mid = left+(right-left>>1);\n\n int cnt = 0;\n\n for(auto& c : cits){\n ...
274
<p>Given an array of integers <code>citations</code> where <code>citations[i]</code> is the number of citations a researcher received for their <code>i<sup>th</sup></code> paper, return <em>the researcher&#39;s h-index</em>.</p> <p>According to the <a href="https://en.wikipedia.org/wiki/H-index" target="_blank">defini...
0
{ "code": "class Solution {\npublic:\n int hIndex(vector<int>& citations) {\n \n int n= citations.size();\n\n \n for(int h=n;h >= 0; h-- ){\n int count = 0;\n\n for(auto citation : citations){\n if(citation >= h){\n count++;\n ...
274
<p>Given an array of integers <code>citations</code> where <code>citations[i]</code> is the number of citations a researcher received for their <code>i<sup>th</sup></code> paper, return <em>the researcher&#39;s h-index</em>.</p> <p>According to the <a href="https://en.wikipedia.org/wiki/H-index" target="_blank">defini...
0
{ "code": "class Solution {\npublic:\n void sort(vector<int>& arr,int n) {\n for(int i = 0; i < n - 1; i++){\n int maxIndex = i;\n\n for(int j = i + 1; j < n; j++){\n if(arr[j] > arr[maxIndex]){\n maxIndex = j;\n }\n\n }\n int temp = arr[maxIndex];...