question_slug stringlengths 3 77 | title stringlengths 1 183 | slug stringlengths 12 45 | summary stringlengths 1 160 ⌀ | author stringlengths 2 30 | certification stringclasses 2
values | created_at stringdate 2013-10-25 17:32:12 2025-04-12 09:38:24 | updated_at stringdate 2013-10-25 17:32:12 2025-04-12 09:38:24 | hit_count int64 0 10.6M | has_video bool 2
classes | content stringlengths 4 576k | upvotes int64 0 11.5k | downvotes int64 0 358 | tags stringlengths 2 193 | comments int64 0 2.56k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
count-anagrams | count Anagrams || Unordered_map || Easy to understand💯 | count-anagrams-unordered_map-easy-to-und-oi87 | \n\n# Code\n\n#define ll long long \nclass Solution {\npublic:\n int m = 1000000007;\n vector<long long > fact;\n void solve(){\n f | mikky_123 | NORMAL | 2022-12-29T09:17:46.860561+00:00 | 2022-12-29T09:17:46.860602+00:00 | 182 | false | \n\n# Code\n```\n#define ll long long \nclass Solution {\npublic:\n int m = 1000000007;\n vector<long long > fact;\n void solve(){\n fact[0] = fact[1] =1 ;\n for(int i=2;i<100001;i++){\n fact[i] = (fact[i-1]%m * i%m )%m;\n }\n }\n ll powmod(ll ... | 1 | 0 | ['Ordered Map', 'C++'] | 0 |
count-anagrams | C++ | Easy Approach after learning Binary Exponentiation and Modular Multiplicative Inverse | c-easy-approach-after-learning-binary-ex-uukj | Intuition\n Total number of permutations of a word without duplicate letters Formula: N!\n\n Total number of permutations of a word with duplicate letters | janakrish_30 | NORMAL | 2022-12-28T15:27:24.284375+00:00 | 2022-12-28T15:30:07.731291+00:00 | 99 | false | # Intuition\n Total number of permutations of a word without duplicate letters Formula: N!\n\n Total number of permutations of a word with duplicate letters Formula: N! / ma! * mb! * .... * mz! where N is the total number of letters and ma, mb are the occurrences of repetitive letters in the word\n\n# Approach\n ... | 1 | 0 | ['C++'] | 0 |
count-anagrams | JavaScript solution, need math knowledge and BigInt class | javascript-solution-need-math-knowledge-3nrid | Intuition\nThe final result is from multipling each word result.\nFor a word (splitted by space), we count the frequence of characters and calculate result for | Gang-Li | NORMAL | 2022-12-27T18:50:07.327434+00:00 | 2022-12-27T18:50:07.327468+00:00 | 284 | false | # Intuition\nThe final result is from multipling each word result.\nFor a word (splitted by space), we count the frequence of characters and calculate result for that word.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(n)\n\n# ... | 1 | 0 | ['JavaScript'] | 1 |
count-anagrams | Easy C++ || Fermat's Theorem || O(n*log(10^9)) | easy-c-fermats-theorem-onlog109-by-ahmed-ztxv | Intuition\n Describe your first thoughts on how to solve this problem. \nFermat\'s Theorem + factorial\n\n# Approach\n Describe your approach to solving the pro | ahmed786ajaz | NORMAL | 2022-12-25T10:38:15.222985+00:00 | 2022-12-25T10:38:52.599577+00:00 | 135 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nFermat\'s Theorem + factorial\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nFor every word, count no of distinct chars and equal chars freq(using HashMap), now use concept of permutations for every word and keep ... | 1 | 0 | ['Math', 'Prefix Sum', 'C++'] | 0 |
count-anagrams | Kotlin simple solution | kotlin-simple-solution-by-neo204-v77t | \nclass Solution {\n val mod: Long = (1e9+7).toLong()\n\n fun power(x: Long, y: Long): Long {\n var x: Long = x\n var y: Long = y\n v | neo204 | NORMAL | 2022-12-25T06:28:29.763435+00:00 | 2022-12-25T06:28:29.763473+00:00 | 53 | false | ```\nclass Solution {\n val mod: Long = (1e9+7).toLong()\n\n fun power(x: Long, y: Long): Long {\n var x: Long = x\n var y: Long = y\n var ans: Long = 1\n x %= mod\n while (y > 0) {\n if (y and 1 == 1L) \n ans = (ans * x) % mod\n x = (x * x) ... | 1 | 0 | ['Kotlin'] | 0 |
count-anagrams | C++ | Modular Inverse | c-modular-inverse-by-aviprit-1wcw | Here the problem is quite straightforward, go through the observation points for intuition.\nObservations:\n1) Notice our permutation depends on every word of t | Aviprit | NORMAL | 2022-12-24T18:51:06.650375+00:00 | 2022-12-24T18:51:06.650413+00:00 | 174 | false | Here the problem is quite straightforward, go through the observation points for intuition.\nObservations:\n1) Notice our permutation depends on every word of the string i.e. string between two spaces.\n2) Spaces doesn\'t contribute to our final answer.\n3) Permutation of each word is the factorial of the number of cha... | 1 | 0 | ['C'] | 0 |
count-anagrams | Rust Module Division Using Fermat's Little Theorem | rust-module-division-using-fermats-littl-7et5 | Intuition\n Describe your first thoughts on how to solve this problem. \n1) The number of ways of counstructing the solution is the multiplication of the number | xiaoping3418 | NORMAL | 2022-12-24T17:51:07.699346+00:00 | 2022-12-24T17:51:07.699391+00:00 | 432 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n1) The number of ways of counstructing the solution is the multiplication of the number of ways of constructing each unique word.\n2) Assume f_1, f_2, ,, f_k are frequencies of distinct characters in a word, where f_1 + f_2 + ... + f_k = ... | 1 | 0 | ['Rust'] | 0 |
count-anagrams | Brute Force Accepted || Formula | brute-force-accepted-formula-by-rushi_ja-xy2d | From basic math one can observe that answer is the product of the number of unique anagrams for each word in a sentence. So, we find number of anagrams of each | rushi_javiya | NORMAL | 2022-12-24T17:46:34.617353+00:00 | 2022-12-24T17:50:43.353832+00:00 | 99 | false | From basic math one can observe that answer is the product of the number of unique anagrams for each word in a sentence. So, we find number of anagrams of each word in sentence and multiple it.\n**Formula of finding number of anagrams of word:**\n```\nFactorial(length of word)/(multiple Factorial(count of each characte... | 1 | 0 | ['Python3'] | 0 |
count-anagrams | [Python] Linear-time Modular Inverse 3-liner in with Explanation, The Best | python-linear-time-modular-inverse-3-lin-b0y5 | Intuition\nThe number of permutations of word w with possible letter repetitions is given by C_w = \dfrac{n_w!}{\prod_{c\in w} n_c!}, where n_c are counts of ea | Triquetra | NORMAL | 2022-12-24T17:20:28.155476+00:00 | 2022-12-24T21:51:27.050461+00:00 | 682 | false | # Intuition\nThe number of permutations of word $$w$$ with possible letter repetitions is given by $$C_w = \\dfrac{n_w!}{\\prod_{c\\in w} n_c!}$$, where $$n_c$$ are counts of each letter $$c \\in w$$. We need to compute $$\\prod_{w\\in s} C_w$$ for words $$w\\in s$$.\n\nThus, the final result is $$\\prod_{w\\in s} \\df... | 1 | 0 | ['Python3'] | 0 |
count-anagrams | [clean code] modulo multiplicative inverse using binary exponentiation - easy to understand - c++ | clean-code-modulo-multiplicative-inverse-cvfa | concept\nhttps://cp-algorithms.com/algebra/module-inverse.html#finding-the-modular-inverse-for-array-of-numbers-modulo-m\n# Code\n\n#define ll long long\n#defin | ravishankarnitr | NORMAL | 2022-12-24T17:02:41.899315+00:00 | 2022-12-24T17:10:03.049099+00:00 | 527 | false | # concept\nhttps://cp-algorithms.com/algebra/module-inverse.html#finding-the-modular-inverse-for-array-of-numbers-modulo-m\n# Code\n```\n#define ll long long\n#define mod 1000000007\nconst int N=1e5+1;\nclass Solution {\npublic:\n ll fact[N];\n\n void pre(){\n fact[0]=1;\n for(int i=1;i<N;i++){\n ... | 1 | 0 | ['C++'] | 1 |
count-anagrams | JAVA | Modulo Multiplicative Inverse | Neat and Clean Solution | java-modulo-multiplicative-inverse-neat-82y93 | Intuition\nFor each string (space seprated) find the count of unique permutation and multiply with the result.\n Describe your first thoughts on how to solve th | sahil58555 | NORMAL | 2022-12-24T16:58:07.468522+00:00 | 2022-12-24T17:52:20.625276+00:00 | 741 | false | # Intuition\nFor each string (space seprated) find the count of unique permutation and multiply with the result.\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nHow to get unique permutation - \neg - string = "ababcb"\nunique permuation - 6! / (2! * 3! * 1!).\n\nAs max length of stri... | 1 | 0 | ['Java'] | 2 |
count-anagrams | Self contained fast python code no import of math library | self-contained-fast-python-code-no-impor-3z9c | IntuitionBig_prime = 10**9 + 7
The problem with not using module Big_prime, is that the numbers become so large, multiplication and division are O(M(number of d | ___Arash___ | NORMAL | 2025-03-27T08:40:43.152378+00:00 | 2025-03-27T08:43:01.461744+00:00 | 2 | false | # Intuition
Big_prime = 10**9 + 7
The problem with not using module Big_prime, is that the numbers become so large, multiplication and division are O(M(number of digits)) and it is not O(1) anymore.
What to do? use mod Big_prime. But how divide mod Big_prime?
use a** p mod p =a (Fermat little theorem)
therefore a**(p... | 0 | 0 | ['Python'] | 0 |
count-anagrams | Easy Permutation Approach - Beats 91% ✅ | easy-permutation-approach-beats-91-by-da-a6fy | Intuition 🤔Calculate anagram counts using the permutation formula. Compute the factorial of total letters, divide by the product of factorials of repeating lett | dark_dementor | NORMAL | 2025-03-22T10:10:46.197296+00:00 | 2025-03-22T10:10:46.197296+00:00 | 4 | false | # Intuition 🤔
Calculate anagram counts using the permutation formula. Compute the factorial of total letters, divide by the product of factorials of repeating letters, and multiply results for each word in the string.
# Approach 🚀
1. Compute the factorial of the total number of letters.
2. Compute the factor... | 0 | 0 | ['C++'] | 0 |
count-anagrams | Finest way of solving Count ANAGRAMS problem | finest-way-of-solving-count-anagrams-pro-xzdz | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | Shalman143 | NORMAL | 2025-03-15T09:40:32.746355+00:00 | 2025-03-15T09:40:32.746355+00:00 | 3 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
`... | 0 | 0 | ['Python3'] | 0 |
count-anagrams | its very tricky solution | its-very-tricky-solution-by-rho_ruler-bnmm | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | Rho_Ruler | NORMAL | 2025-01-29T06:52:11.007368+00:00 | 2025-01-29T06:52:11.007368+00:00 | 9 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
O(N)
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ ... | 0 | 0 | ['Python3'] | 0 |
count-anagrams | Comprehensive Solution by Reducing Problems Into Familiar Subproblems | comprehensive-solution-by-reducing-probl-0pau | IntuitionThis problem is about combinatorics, hence we make use of the math.comb library. We also need to keep a character frequency of each word so that we can | musk_eteer | NORMAL | 2025-01-13T15:10:33.248202+00:00 | 2025-01-13T15:10:33.248202+00:00 | 8 | false | # Intuition
This problem is about combinatorics, hence we make use of the math.comb library. We also need to keep a character frequency of each word so that we can calculate combinations where there are character repetitions
# Problem Decomposition
We can reduce this problem to the following subproblems:
- Converting ... | 0 | 0 | ['Hash Table', 'String', 'Combinatorics', 'Python3'] | 0 |
count-anagrams | Permutation logic | permutation-logic-by-vats_lc-xogg | Code | vats_lc | NORMAL | 2025-01-09T13:05:59.071370+00:00 | 2025-01-09T13:05:59.071370+00:00 | 12 | false | # Code
```cpp []
#define li long long
const li MOD = 1e9 + 7;
class Solution {
public:
li mod_exp(li x, li y, li mod) {
li res = 1;
while (y > 0) {
if (y % 2 == 1)
res = (res * x) % mod;
x = (x * x) % mod;
y /= 2;
}
return res;
... | 0 | 0 | ['C++'] | 0 |
count-anagrams | C++ SIMPLE MODULAR ARITHMATIC AND COMBINATORICS | O(N+M) SOLUTION | c-simple-modular-arithmatic-and-combinat-jqqo | \n\n# Code\ncpp []\nconst long long mxN = 1e5, MOD = 1e9 + 7;\nvector<long long> fact(mxN + 1), ifact(mxN + 1);\n\nlong long binaryExpo(long long a, long long b | ayushchavan | NORMAL | 2024-11-29T06:12:08.254935+00:00 | 2024-11-29T06:12:08.254977+00:00 | 13 | false | \n\n# Code\n```cpp []\nconst long long mxN = 1e5, MOD = 1e9 + 7;\nvector<long long> fact(mxN + 1), ifact(mxN + 1);\n\nlong long binaryExpo(long long a, long long b) {\n long long res = 1;\n while (b > 0) {\n if (b & 1)\n res = (res * a) % MOD;\n a = (a * a) % MOD;\n b >>= 1;\n }... | 0 | 0 | ['Hash Table', 'Math', 'String', 'Combinatorics', 'Counting', 'C++'] | 0 |
count-anagrams | Count Anagrams | count-anagrams-by-naeem_abd-bzb1 | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | Naeem_ABD | NORMAL | 2024-11-20T10:29:00.408016+00:00 | 2024-11-20T10:29:00.408049+00:00 | 9 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 0 | 0 | ['Python3'] | 0 |
count-anagrams | Python one-line solution | python-one-line-solution-by-arnoldioi-pc9v | This is just for fun.\nGo to https://leetcode.com/problems/count-anagrams/solutions/2947480/multiply-permutations for detailed math explanation.\n\n# Code\npyth | ArnoldIOI | NORMAL | 2024-10-28T18:52:52.105508+00:00 | 2024-10-28T18:52:52.105541+00:00 | 7 | false | This is just for fun.\nGo to https://leetcode.com/problems/count-anagrams/solutions/2947480/multiply-permutations for detailed math explanation.\n\n# Code\n```python3 []\nclass Solution:\n def countAnagrams(self, s: str) -> int:\n return reduce(operator.mul, [factorial(len(w)) // (reduce(operator.mul, [factor... | 0 | 0 | ['Python3'] | 0 |
count-anagrams | Easy Factorial Solution | easy-factorial-solution-by-kvivekcodes-nouc | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | kvivekcodes | NORMAL | 2024-10-08T11:21:07.658235+00:00 | 2024-10-08T11:21:07.658271+00:00 | 6 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 0 | 0 | ['Hash Table', 'Math', 'String', 'Combinatorics', 'Counting', 'C++'] | 0 |
count-anagrams | Simple Python, Math Formula | simple-python-math-formula-by-lenibi1507-7w60 | Formula for anagram combinations is n! / (k1! * k2! * ... km!), where n is number of letters in word, k is count of letter in word (for all letters)\n\nSplit s | lenibi1507 | NORMAL | 2024-09-24T06:16:55.352826+00:00 | 2024-09-24T06:18:34.260554+00:00 | 4 | false | Formula for anagram combinations is n! / (k1! * k2! * ... km!), where n is number of letters in word, k is count of letter in word (for all letters)\n\nSplit s and multiply the number of combinations for each word together.\n\nModulo by pow(10,9) + 7\n\n# Code\n```python3 []\nclass Solution:\n def countAnagrams(self... | 0 | 0 | ['Python3'] | 0 |
count-anagrams | ASCII key and Fermat's Little Theorem | ascii-key-and-fermats-little-theorem-by-cbasm | Intuition\n Describe your first thoughts on how to solve this problem. \nASCII key and Fermat\'s Little Theorem\n# Approach\n Describe your approach to solving | kenjpais | NORMAL | 2024-08-22T18:22:41.459599+00:00 | 2024-08-22T18:25:26.192803+00:00 | 3 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nASCII key and Fermat\'s Little Theorem\n# Approach\n<!-- Describe your approach to solving the problem. -->\nASCII key and Fermat\'s Little Theorem\n\n# Complexity\n- Time complexity:\nO(nlogn)\n\n- Space complexity:\nO(1)\n\n# Code\n```g... | 0 | 0 | ['Go'] | 0 |
count-anagrams | Count Anagrams | count-anagrams-by-shaludroid-30a6 | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | Shaludroid | NORMAL | 2024-08-17T12:27:14.367819+00:00 | 2024-08-17T12:27:14.367851+00:00 | 31 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 0 | 0 | ['Java'] | 0 |
count-anagrams | Python : count anagram | python-count-anagram-by-shristysharma-4rws | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | shristysharma | NORMAL | 2024-08-12T16:57:14.155773+00:00 | 2024-08-12T16:57:14.155794+00:00 | 27 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 0 | 0 | ['Hash Table', 'Python', 'Python3'] | 0 |
count-anagrams | Most Basic approach for beginners-C++(Beats -80%) | most-basic-approach-for-beginners-cbeats-nyl3 | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | sanyam46 | NORMAL | 2024-08-09T09:51:40.354831+00:00 | 2024-08-09T09:51:40.354860+00:00 | 6 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 0 | 0 | ['C++'] | 0 |
count-anagrams | Python (Simple Maths) | python-simple-maths-by-rnotappl-1bea | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | rnotappl | NORMAL | 2024-07-21T15:44:35.255479+00:00 | 2024-07-21T15:44:35.255509+00:00 | 4 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 0 | 0 | ['Python3'] | 0 |
count-anagrams | yo! wanna see a one Liner ✅✅✅ | yo-wanna-see-a-one-liner-by-saisreenivas-u13d | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | saisreenivas21 | NORMAL | 2024-07-14T15:01:49.017984+00:00 | 2024-07-14T15:01:49.018011+00:00 | 8 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 0 | 0 | ['Math', 'Combinatorics', 'Counting', 'Python3'] | 0 |
count-anagrams | MATHS | C++ | O(N) | maths-c-on-by-pro-electro-h8ks | Time Complexity: O(N)\n## Theory:\n\nGiven string: "aabbc"\n\n- Total Length: The length of the string is 5 characters.\n \n- Character Counts:\n - \'a\' appe | pro-electro | NORMAL | 2024-06-17T15:25:56.363705+00:00 | 2024-06-17T15:25:56.363734+00:00 | 7 | false | ## Time Complexity: O(N)\n## Theory:\n\nGiven string: "aabbc"\n\n- **Total Length**: The length of the string is 5 characters.\n \n- **Character Counts**:\n - \'a\' appears twice.\n - \'b\' appears twice.\n - \'c\' appears once.\n\nTo find the total number of distinct permutations (anagrams) of the string "aabbc", ... | 0 | 0 | ['C++'] | 0 |
count-anagrams | Easy CPP Solution | easy-cpp-solution-by-pratima-bakshi-l9o8 | Complexity\n- Time complexity:\n O(N)\n\n- Space complexity:\n O(N)\n\n# Code\n\nclass Solution {\npublic:\n int mod = 1e9+7;\n vector<long long>fac | Pratima-Bakshi | NORMAL | 2024-06-11T19:41:19.941256+00:00 | 2024-06-11T19:41:19.941279+00:00 | 6 | false | # Complexity\n- Time complexity:\n O(N)\n\n- Space complexity:\n O(N)\n\n# Code\n```\nclass Solution {\npublic:\n int mod = 1e9+7;\n vector<long long>fact;\n long long power(long long x, long long y) {\n long long res = 1;\n x = x % mod;\n while (y > 0) {\n if (y & 1)\n ... | 0 | 0 | ['C++'] | 0 |
count-anagrams | [C++]Beats 100% Detailed Explanation Modulo Inverse and Fermat Theorem | cbeats-100-detailed-explanation-modulo-i-fyl2 | Approach/Explanation \n Describe your first thoughts on how to solve this problem. \nYou need knowledge of modulo inverse and fermat theorem to solve this prob | berserk5703 | NORMAL | 2024-06-05T13:57:04.579825+00:00 | 2024-06-05T13:57:04.579865+00:00 | 8 | false | # Approach/Explanation \n<!-- Describe your first thoughts on how to solve this problem. -->\nYou need knowledge of **modulo inverse** and **fermat theorem** to solve this problem\n\nMODULO INVERSE SAYS\n1. (a+b)%m = (a%m + b%m)%m \n2. (a-b)%m = (a%m - b%m + **m**)%m \n> in case "a%m - b%m" is negative the highligh... | 0 | 0 | ['C++'] | 0 |
count-anagrams | Beats 100% in time and memory | beats-100-in-time-and-memory-by-dipanshu-tsl4 | Intuition\n Describe your first thoughts on how to solve this problem. \nthis problem can be solved by using the basic concepts of permutation and combination \ | dipanshu-tiwari | NORMAL | 2024-06-04T14:20:18.233590+00:00 | 2024-06-04T14:20:18.233619+00:00 | 16 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nthis problem can be solved by using the basic concepts of permutation and combination \n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nwe will brreak the string in a list of word and return the product of all permu... | 0 | 0 | ['Python'] | 0 |
count-anagrams | for only beginners🔥🔥🔥python | for-only-beginnerspython-by-sathish_loal-i3pg | \nclass Solution:\n def countAnagrams(self, s: str) -> int:\n def permute(st):\n dic = Counter(st)\n perm = 0\n perm | sathish_loal | NORMAL | 2024-06-03T17:07:53.050313+00:00 | 2024-06-03T17:07:53.050342+00:00 | 0 | false | ```\nclass Solution:\n def countAnagrams(self, s: str) -> int:\n def permute(st):\n dic = Counter(st)\n perm = 0\n perm = factorial(len(st))\n for k,v in dic.items():\n if v > 1:\n perm = perm//factorial(v)\n return perm\... | 0 | 0 | ['Math'] | 0 |
count-anagrams | # Easy and Simple Approach using Factorial And modular inverse | easy-and-simple-approach-using-factorial-pzvm | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | Gyanu_sahu | NORMAL | 2024-06-02T06:43:16.813163+00:00 | 2024-06-02T06:43:16.813193+00:00 | 2 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 0 | 0 | ['Ordered Map', 'C++'] | 0 |
count-anagrams | Fermat's Little Theorem || P&C | fermats-little-theorem-pc-by-ishaankulka-uubo | Intuition\nThis problem can be simply treated as basic P&C type of qs.We have to just calculate all the possible premutations of each word and multiply them.Onl | ishaankulkarni11 | NORMAL | 2024-05-29T09:18:39.918222+00:00 | 2024-05-29T09:18:39.918253+00:00 | 7 | false | # Intuition\nThis problem can be simply treated as basic P&C type of qs.We have to just calculate all the possible premutations of each word and multiply them.Only thing we have to consider is that the calculation of permutations of words with duplicate letters.\nFor eg - aabb -> fact(4)/fact(2)*fact(2)\n\n# Approach\n... | 0 | 0 | ['C++'] | 0 |
count-anagrams | hard? | hard-by-qulinxao-oe5m | \nclass Solution:\n def countAnagrams(self, s: str) -> int:\n o,b=1,10**9+7\n for v in s.split(\' \'):\n r,n=1,sum(v:=Counter(v).val | qulinxao | NORMAL | 2024-05-26T16:14:11.749373+00:00 | 2024-05-26T16:14:11.749395+00:00 | 9 | false | ```\nclass Solution:\n def countAnagrams(self, s: str) -> int:\n o,b=1,10**9+7\n for v in s.split(\' \'):\n r,n=1,sum(v:=Counter(v).values())\n for k in v:r=r*comb(n,k)%b;n-=k\n o=o*r%b\n return o\n``` | 0 | 0 | ['Python3'] | 0 |
count-anagrams | [C++] Combinatorics, Permutations | c-combinatorics-permutations-by-amanmeha-tidw | \nclass Solution {\npublic:\n int countAnagrams(string s) {\n int mod = 1e9 + 7;\n int n = s.size();\n long anagrams = 1;\n vecto | amanmehara | NORMAL | 2024-05-12T14:12:03.987949+00:00 | 2024-05-12T14:15:46.517440+00:00 | 6 | false | ```\nclass Solution {\npublic:\n int countAnagrams(string s) {\n int mod = 1e9 + 7;\n int n = s.size();\n long anagrams = 1;\n vector<long> facts(n + 1);\n facts[0] = 1;\n for (int i = 1; i <= n; i++) {\n facts[i] = facts[i - 1] * i % mod;\n }\n unor... | 0 | 0 | ['Hash Table', 'Math', 'String', 'Combinatorics', 'C++'] | 0 |
count-anagrams | Rust - Basic combinatorics + some number theory | rust-basic-combinatorics-some-number-the-soqb | Basic permutation with repetition to find possible anagrams of each word. The answer is the product of that modulo 10^9 + 7\n\nThe challenge lies in the actual | ajmarin89 | NORMAL | 2024-04-25T03:54:49.617795+00:00 | 2024-04-25T03:54:49.617822+00:00 | 2 | false | Basic permutation with repetition to find possible anagrams of each word. The answer is the product of that modulo 10^9 + 7\n\nThe challenge lies in the actual computation of the factorials modulo a large number, specifically in dealing with the divisors. Using Fermat\'s little theorem it\'s possible to compute the mod... | 0 | 0 | ['Rust'] | 0 |
count-anagrams | Java Solution | java-solution-by-divyanshagrawal96-b9i4 | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | divyanshagrawal96 | NORMAL | 2024-04-14T16:13:33.417569+00:00 | 2024-04-14T16:13:33.417596+00:00 | 44 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 0 | 0 | ['Java'] | 0 |
count-anagrams | Simple C++ Solution | simple-c-solution-by-chikucool2012-k4jf | Intuition\n\nThe problem is asking for the number of distinct anagrams of a given string where each word in the string is permuted independently. So by using th | chikucool2012 | NORMAL | 2024-04-09T09:47:29.400585+00:00 | 2024-04-09T09:47:29.400603+00:00 | 4 | false | # Intuition\n\nThe problem is asking for the number of distinct anagrams of a given string where each word in the string is permuted independently. So by using the simple formula we use in Aptitude Questions i.e No of different permutations of a word with some repeating characters is:\n(No. of characters)! / (repating ... | 0 | 0 | ['C++'] | 0 |
count-anagrams | Simple python3 solution with explanation | 199 ms - faster than 90.13% solutions | simple-python3-solution-with-explanation-2mzo | Approach\n Describe your approach to solving the problem. \n\nCalculate for "too hot":\n1. split into words: "too", "hot"\n2. answer is \prod_{i = 0}^n calc(wor | tigprog | NORMAL | 2024-03-25T17:28:45.031095+00:00 | 2024-03-25T17:28:45.031118+00:00 | 8 | false | # Approach\n<!-- Describe your approach to solving the problem. -->\n\nCalculate for `"too hot"`:\n1. split into words: `"too"`, `"hot"`\n2. answer is $$\\prod_{i = 0}^n calc(word_i) = \\prod_{i = 0}^n \\frac{m_i!}{\\prod{k_{ij}!}}$$\nwhere $$m_i$$ is length of i-word and $$k_{ij}$$ is number of repetitions of unique c... | 0 | 0 | ['Hash Table', 'Math', 'Combinatorics', 'Counting', 'Python3'] | 0 |
count-anagrams | C++ || Combinatorics under modular arithmetic | c-combinatorics-under-modular-arithmetic-n1or | Intuition\nWe can find the number of permutations for each word in the string. \nLet\'s consider the first example:\n\n\ns = "too hot"\n\n\nLet\'s find the numb | Gismet | NORMAL | 2024-03-12T12:08:52.216986+00:00 | 2024-03-12T12:10:39.276562+00:00 | 1 | false | # Intuition\nWe can find the number of permutations for each word in the string. \nLet\'s consider the first example:\n\n```\ns = "too hot"\n```\n\n**Let\'s find the number of permutations of the first word**\n\nIf we were given 3 distinct characters and asked to find the number of permutations, we can use the factoria... | 0 | 0 | ['C++'] | 0 |
count-anagrams | Python 3 | Solution | python-3-solution-by-mati44-66yo | Code\n\nclass Solution:\n def countAnagrams(self, s: str) -> int:\n \n res = 1\n mod = 10**9 + 7\n\n def count_anagram(word):\n\n | mati44 | NORMAL | 2024-03-11T22:03:38.317676+00:00 | 2024-03-11T22:03:38.317704+00:00 | 4 | false | # Code\n```\nclass Solution:\n def countAnagrams(self, s: str) -> int:\n \n res = 1\n mod = 10**9 + 7\n\n def count_anagram(word):\n\n D = Counter(word)\n res = math.factorial(len(word))\n\n for x in D.values():\n res //= math.factorial(x)\n... | 0 | 0 | ['Hash Table', 'Math', 'String', 'Combinatorics', 'Counting', 'Python3'] | 0 |
count-anagrams | Not a Hard Problem || Easy C++ Solution using (inverse modulo and binary exponentiation) | not-a-hard-problem-easy-c-solution-using-vfe5 | \n\n# Approach\n\nConsider each space seperated string as chunk of that string, find number of permutaion of each chunk and multiply them. \n\nfor finding numbe | viraj7403 | NORMAL | 2024-03-04T13:40:15.962025+00:00 | 2024-03-04T13:41:36.160106+00:00 | 3 | false | \n\n# Approach\n\nConsider each space seperated string as chunk of that string, find number of permutaion of each chunk and multiply them. \n\nfor finding number of ways you should we aware of basic formula like : \nto arrange k different things number of ways \n= (k1 + k2 + k3) ! / (k1! * k2! * k3!) , where ki\'s are ... | 0 | 0 | ['C++'] | 0 |
count-anagrams | Simple Python "in 2 lines" solution using map and distinct calculations | simple-python-in-2-lines-solution-using-175x1 | Description\n1e9 + 7 and 10**9 + 7 in Python are different (StackOverflow: 67438654)\n\n# Code\nPython\nclass Solution:\n def distinctAnagram(self, s: str) - | AriosJentu | NORMAL | 2024-02-23T19:35:12.860114+00:00 | 2024-02-23T19:35:30.889267+00:00 | 5 | false | # Description\n`1e9 + 7` and `10**9 + 7` in Python are different (StackOverflow: 67438654)\n\n# Code\n```Python\nclass Solution:\n def distinctAnagram(self, s: str) -> int:\n return math.factorial(len(s))//math.prod(map(lambda x: math.factorial(x), [s.count(i) for i in set(s)]))\n\n def countAnagrams(self,... | 0 | 0 | ['Python3'] | 0 |
count-anagrams | Using Brute Force and Factorial - | using-brute-force-and-factorial-by-soban-g366 | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n Using Brute-For | sobanss2001 | NORMAL | 2024-02-14T15:38:30.740577+00:00 | 2024-02-14T15:38:30.740606+00:00 | 4 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n Using Brute-Force and Math.Factorial \n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n O(n*k^2)\n- Space com... | 0 | 0 | ['Hash Table', 'Math', 'String', 'Combinatorics', 'Counting', 'Python3'] | 0 |
count-anagrams | C++ ,Simple with explanation , Easy ... | c-simple-with-explanation-easy-by-udaysi-rpfg | Intuition\nSimple Permuataion formaul\n\nfor duplicate = !N / !D1*!D2\n\nwhere d1 and d2 duplicate for character in aab , d1=2,d2=1\n\n# Code\n\n\ntypedef long | udaysinghp95 | NORMAL | 2024-02-09T18:53:19.686960+00:00 | 2024-02-09T18:53:19.686985+00:00 | 4 | false | # Intuition\nSimple Permuataion formaul\n\nfor duplicate = !N / !D1*!D2\n\nwhere d1 and d2 duplicate for character in aab , d1=2,d2=1\n\n# Code\n```\n\ntypedef long long int lli;\nint MOD=1e9+7;\n\nclass Solution {\n\n\npublic:\n\n int power(lli x, lli y) {\n lli res = 1;\n x = x % MOD; // Take modulo ... | 0 | 0 | ['C++'] | 0 |
count-anagrams | Easy Python Solution | easy-python-solution-by-sb012-6fnq | Code\n\nfrom collections import Counter\n\nclass Solution:\n def countAnagrams(self, s: str) -> int:\n s = s.split(" ")\n\n answer = 1\n | sb012 | NORMAL | 2024-02-07T19:54:54.484808+00:00 | 2024-02-07T19:54:54.484833+00:00 | 6 | false | # Code\n```\nfrom collections import Counter\n\nclass Solution:\n def countAnagrams(self, s: str) -> int:\n s = s.split(" ")\n\n answer = 1\n for i in s:\n answer = answer * self.permutations(i)\n \n return answer % ((10 ** 9) + 7)\n \n def permutations(self, s):\n... | 0 | 0 | ['Python3'] | 0 |
count-anagrams | Using modulo inverse | using-modulo-inverse-by-shoukthik-bd1f | Intuition\n Describe your first thoughts on how to solve this problem. \nuse permutations concept : \n- The no of ways you can arrange n letters (unique) is n!\ | shoukthik | NORMAL | 2024-02-07T13:02:20.077825+00:00 | 2024-02-07T13:02:20.077856+00:00 | 5 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nuse permutations concept : \n- The no of ways you can arrange n letters (unique) is n!\n- If n letters includes ( x1 letters of same alphabet , x2 letters of another same alphabet and so on ..) , the formula is n! / (x1! * x2! * ...)\n- S... | 0 | 0 | ['Python3'] | 0 |
count-anagrams | Not a good one but it's a beginner friendly brute force approach.....:) | not-a-good-one-but-its-a-beginner-friend-7c66 | Intuition\n1. The code leverages the concept of factorials to compute the number of distinct permutations of each word.\n\n2. It utilizes the Counter class to e | Rohini0802 | NORMAL | 2024-02-06T17:07:11.424400+00:00 | 2024-02-06T17:07:11.424430+00:00 | 133 | false | # Intuition\n1. The code leverages the concept of factorials to compute the number of distinct permutations of each word.\n\n2. It utilizes the Counter class to efficiently count the occurrences of each character in a word.\n3. By considering the multiplicities of characters and applying factorial calculations, it accu... | 0 | 0 | ['Hash Table', 'Math', 'String', 'C', 'Combinatorics', 'Counting', 'Python', 'C++', 'Java', 'Python3'] | 0 |
count-anagrams | Two HashMaps | two-hashmaps-by-sav20011962-kezy | Intuition\nTwo HashMaps - for the frequencies of letters in words and a common one for inverted MODs for the frequencies of letters in words (memo).\nAll multip | sav20011962 | NORMAL | 2024-02-06T13:11:45.658762+00:00 | 2024-02-06T13:11:45.658795+00:00 | 4 | false | # Intuition\nTwo HashMaps - for the frequencies of letters in words and a common one for inverted MODs for the frequencies of letters in words (memo).\nAll multiplications and "divisions" in LONG, finally .toInt()\n# Approach\nTwo HashMaps - for the frequencies of letters in words and a common one for inverted MODs for... | 0 | 0 | ['Kotlin'] | 0 |
count-anagrams | Count Anagrams, C++ Explained Solution With Complete Maths and Intuition | count-anagrams-c-explained-solution-with-f62g | Upvote If Found Helpful !!!\n\n# Approach\n Describe your approach to solving the problem. \nThe problem here is actually quite simple in terms of logic formul | ShuklaAmit1311 | NORMAL | 2024-02-06T08:47:48.282305+00:00 | 2024-02-06T08:47:48.282335+00:00 | 11 | false | ***Upvote If Found Helpful !!!***\n\n# Approach\n<!-- Describe your approach to solving the problem. --> \nThe problem here is actually quite simple in terms of logic formulation. We can directly see that we just have to multiply the number of permutations of each word to get the total distinct number of anagrams. The ... | 0 | 0 | ['Math', 'C++'] | 0 |
count-anagrams | Simple approach using the basics of maths | simple-approach-using-the-basics-of-math-1arg | Intuition\n Describe your first thoughts on how to solve this problem. \nJust start thinking about the anagram so we get an idea that the total number of anagra | aamirsiddiqui1804 | NORMAL | 2024-02-06T07:36:13.919643+00:00 | 2024-02-06T07:36:13.919676+00:00 | 9 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nJust start thinking about the anagram so we get an idea that the total number of anagram for a word is the total number of permutation of this word.\nAnd second thing is that the total number of anagram is equal to the product of the perm... | 0 | 0 | ['C++'] | 0 |
count-anagrams | Easy and concise solution! - Python | easy-and-concise-solution-python-by-abid-ni5s | Approach\n Describe your approach to solving the problem. \nThis is a simple permutation problem. If you know, how to calculate the permutation of a word, rest | Abid95 | NORMAL | 2024-02-06T02:13:05.383900+00:00 | 2024-02-06T02:13:05.383932+00:00 | 13 | false | # Approach\n<!-- Describe your approach to solving the problem. -->\nThis is a simple permutation problem. If you know, how to calculate the permutation of a word, rest is just multipying one\'s permutation with the previous one\'s. As simple as that.**Please upvote, if it helps you**.\n\n# Complexity\n- Time complexit... | 0 | 0 | ['Python3'] | 0 |
count-anagrams | Ruby math combinatorics RT 100% | ruby-math-combinatorics-rt-100-by-alobzo-hdqy | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | alobzov | NORMAL | 2024-01-28T17:58:17.970830+00:00 | 2024-01-28T17:58:17.970870+00:00 | 2 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 0 | 0 | ['Math', 'Ruby'] | 0 |
count-anagrams | Python3 solution w/ dp + modinv | python3-solution-w-dp-modinv-by-mhabtezg-sp9t | Code\n\nimport math\n\nclass Solution:\n def countAnagrams(self, s: str) -> int:\n dp = [0 for _ in range(100001)]\n dp[0] = 1\n MOD = 1 | mhabtezgi56 | NORMAL | 2024-01-26T15:49:10.313841+00:00 | 2024-01-26T15:49:10.313871+00:00 | 5 | false | # Code\n```\nimport math\n\nclass Solution:\n def countAnagrams(self, s: str) -> int:\n dp = [0 for _ in range(100001)]\n dp[0] = 1\n MOD = 1000000007\n for i in range(1, len(s) + 1):\n dp[i] = (dp[i - 1] * i) % MOD\n\n t = s.split(" ")\n\n res = 1\n for wo... | 0 | 0 | ['Python3'] | 0 |
count-anagrams | Using Permutation | using-permutation-by-sayan_kd-dlpd | \n# Code\n\nclass Solution:\n def countAnagrams(self, s: str) -> int:\n words, total = s.split(), 1\n for word in words:\n anagrams | sayan_kd | NORMAL | 2024-01-19T12:13:07.128911+00:00 | 2024-01-19T12:13:07.128943+00:00 | 7 | false | \n# Code\n```\nclass Solution:\n def countAnagrams(self, s: str) -> int:\n words, total = s.split(), 1\n for word in words:\n anagrams = math.factorial(len(word))\n letters = Counter(word)\n for occ in letters.values():\n anagrams //= math.factorial(occ)\... | 0 | 0 | ['Hash Table', 'Math', 'Python3'] | 0 |
count-anagrams | || C++ | c-by-1abc-awgk | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | 1ABC | NORMAL | 2024-01-16T16:32:15.939338+00:00 | 2024-01-16T16:32:15.939376+00:00 | 14 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 0 | 0 | ['C++'] | 0 |
count-anagrams | inverse... | inverse-by-user3043sb-x4s6 | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | user3043SB | NORMAL | 2023-12-20T18:23:59.786082+00:00 | 2023-12-20T18:23:59.786115+00:00 | 16 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 0 | 0 | ['Java'] | 0 |
count-anagrams | Use extended Euclidian Algorithm to evaluate the faction mod p | use-extended-euclidian-algorithm-to-eval-ne7a | Code\n\nuse std::collections::HashMap;\n\nconst BIG:i64 = 1_000_000_007;\n\n// modular inverse\nfn inv(k: i64) -> i64 {\n egcd(k, BIG).1.rem_euclid(BIG)\n}\n | user5285Zn | NORMAL | 2023-12-20T12:38:45.039494+00:00 | 2023-12-20T12:38:45.039537+00:00 | 1 | false | # Code\n```\nuse std::collections::HashMap;\n\nconst BIG:i64 = 1_000_000_007;\n\n// modular inverse\nfn inv(k: i64) -> i64 {\n egcd(k, BIG).1.rem_euclid(BIG)\n}\n\nfn egcd(x: i64, y: i64) -> (i64, i64, i64) {\n match y {\n 0 => (x, 1, 0),\n _ => {let k = x/y; \n let r = x.rem_euclid(y);... | 0 | 0 | ['Rust'] | 0 |
count-anagrams | HERE is THE RECURSION APPROACH you all are searching for👾 | here-is-the-recursion-approach-you-all-a-imja | NOTE: MY FIRST SOlUTION I EVER POSTED!!\n# Intuition\n=> The code leverages factorials to compute the count of anagrams for each word efficiently.\n=> The calc | maneeshnandreddy | NORMAL | 2023-12-19T13:42:46.115741+00:00 | 2023-12-19T13:42:46.115777+00:00 | 1 | false | NOTE: MY FIRST SOlUTION I EVER POSTED!!\n# Intuition\n=> The code leverages factorials to compute the count of anagrams for each word efficiently.\n=> The calc function recursively computes the product of factorials for character counts.\n=> The outer loop handles each word, and the inner loops calculate factorials and... | 0 | 0 | ['Python3'] | 0 |
count-anagrams | Python: T/M - 92%/90% (Mathematical/Combinatorial) | python-tm-9290-mathematicalcombinatorial-unie | Intuition\n Describe your first thoughts on how to solve this problem. \nThe nature of this problem really defines it as more of a combinatorics problem wrapped | gmontes01 | NORMAL | 2023-12-16T21:32:24.351356+00:00 | 2023-12-16T21:32:24.351373+00:00 | 0 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe nature of this problem really defines it as more of a combinatorics problem wrapped in a simple coding problem. \n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nFrom the [product rule](https://en.wikipedia.org/... | 0 | 0 | ['Math', 'Combinatorics', 'Counting', 'Python3'] | 0 |
sender-with-largest-word-count | Count Spaces | count-spaces-by-votrubac-w8oz | The number of words in a message is the number of spaces, plus one.\n\nWe count words for each sender using a hash map, and track max count with the sender\'s n | votrubac | NORMAL | 2022-05-28T16:01:24.020359+00:00 | 2022-05-28T16:07:59.140138+00:00 | 3,795 | false | The number of words in a message is the number of spaces, plus one.\n\nWe count words for each sender using a hash map, and track max count with the sender\'s name.\n\n**C++**\n```cpp\nstring largestWordCount(vector<string>& messages, vector<string>& senders) {\n unordered_map<string, int> cnt;\n string res;\n ... | 65 | 0 | ['C'] | 14 |
sender-with-largest-word-count | Two Solution (StringStream and Count Space) | two-solution-stringstream-and-count-spac-klbd | Store the count of words sent by each sender and find the sender with the largest word count in the hashmap.\n\n\nclass Solution {\npublic:\n string largestW | kamisamaaaa | NORMAL | 2022-05-28T16:02:56.285422+00:00 | 2022-06-03T05:54:05.521580+00:00 | 1,344 | false | ***Store the count of words sent by each sender and find the sender with the largest word count in the hashmap.***\n\n```\nclass Solution {\npublic:\n string largestWordCount(vector<string>& messages, vector<string>& senders) {\n \n int n(size(messages));\n map<string, int> m;\n for (auto... | 18 | 0 | ['C'] | 7 |
sender-with-largest-word-count | [Java/Python 3] Two codes w/ analysis. | javapython-3-two-codes-w-analysis-by-roc-xkv9 | Method 1: Sort the senders with the largest word count\njava\n public String largestWordCount(String[] messages, String[] senders) {\n Map<String, Int | rock | NORMAL | 2022-05-28T16:05:13.909008+00:00 | 2022-05-29T14:05:51.317963+00:00 | 1,361 | false | **Method 1: Sort the senders with the largest word count**\n```java\n public String largestWordCount(String[] messages, String[] senders) {\n Map<String, Integer> cnt = new HashMap<>();\n int largest = 0;\n for (int i = 0; i < senders.length; ++i) {\n largest = Math.max(largest, cnt.m... | 13 | 0 | [] | 2 |
sender-with-largest-word-count | C++ || MAP || Easy | c-map-easy-by-aakash_mehta_2023-3u5j | \nclass Solution {\npublic:\n string largestWordCount(vector<string>& messages, vector<string>& senders){\n map<string, int> mp;\n for(int i = | aakash_mehta_2023 | NORMAL | 2022-05-28T16:28:56.461919+00:00 | 2022-05-30T18:37:57.890319+00:00 | 1,166 | false | ```\nclass Solution {\npublic:\n string largestWordCount(vector<string>& messages, vector<string>& senders){\n map<string, int> mp;\n for(int i = 0; i<messages.size(); ++i){\n int words = count(begin(messages[i]), end(messages[i]), \' \')+1;\n mp[senders[i]]+=words;\n }\n ... | 10 | 0 | ['C'] | 5 |
sender-with-largest-word-count | [Java] Code with comments || HashMap + PriorityQueue | java-code-with-comments-hashmap-priority-utbu | \nclass Solution {\n \n class Pair {\n String name;\n int cnt;\n \n public Pair(String n, int c) {\n this.name = n; | vj98 | NORMAL | 2022-05-28T16:04:46.998146+00:00 | 2022-05-30T06:52:07.398886+00:00 | 911 | false | ```\nclass Solution {\n \n class Pair {\n String name;\n int cnt;\n \n public Pair(String n, int c) {\n this.name = n;\n this.cnt = c;\n }\n }\n \n class Compare implements Comparator<Pair> {\n public int compare(Pair a, Pair b) {\n ... | 8 | 0 | ['Heap (Priority Queue)', 'Java'] | 1 |
sender-with-largest-word-count | Easy Python Solution With Dictionary | easy-python-solution-with-dictionary-by-sb9oe | \nclass Solution:\n def largestWordCount(self, messages: List[str], senders: List[str]) -> str:\n d={}\n l=[]\n for i in range(len(messa | aadi_2 | NORMAL | 2022-05-28T16:36:26.412523+00:00 | 2022-05-28T16:36:26.412552+00:00 | 1,142 | false | ```\nclass Solution:\n def largestWordCount(self, messages: List[str], senders: List[str]) -> str:\n d={}\n l=[]\n for i in range(len(messages)):\n if senders[i] not in d:\n d[senders[i]]=len(messages[i].split())\n else:\n d[senders[i]]+=len(me... | 7 | 0 | ['Python', 'Python3'] | 3 |
sender-with-largest-word-count | Easy Approach in Java | using HashMap Only | easy-approach-in-java-using-hashmap-only-1awr | \n\nclass Solution {\n public String largestWordCount(String[] messages, String[] senders) {\n HashMap<String,Integer> hm=new HashMap<>();\n\t\t\n | himanshusharma2024 | NORMAL | 2022-05-28T16:05:17.174979+00:00 | 2022-06-01T10:16:56.026049+00:00 | 940 | false | ```\n\nclass Solution {\n public String largestWordCount(String[] messages, String[] senders) {\n HashMap<String,Integer> hm=new HashMap<>();\n\t\t\n int max=0;\n String name="";\n for(int i=0;i<messages.length;i++){\n String[] words=messages[i].split(" ");\n \n ... | 7 | 1 | ['Java'] | 0 |
sender-with-largest-word-count | Simple Space count solution || No String-Stream | simple-space-count-solution-no-string-st-y86a | \nclass Solution {\npublic:\n string largestWordCount(vector<string>& messages, vector<string>& senders) {\n map<string,int> m;\n int n=senders | ashu143 | NORMAL | 2022-05-28T16:29:11.207183+00:00 | 2022-05-28T16:29:11.207211+00:00 | 294 | false | ```\nclass Solution {\npublic:\n string largestWordCount(vector<string>& messages, vector<string>& senders) {\n map<string,int> m;\n int n=senders.size();\n for(int i=0;i<n;i++)\n {\n int cnt=0;\n for(int j=0;j<messages[i].size();j++)\n {\n ... | 6 | 0 | ['C'] | 3 |
sender-with-largest-word-count | C++ || Map || count space || Easy-to-understand | c-map-count-space-easy-to-understand-by-cf211 | \nclass Solution {\npublic:\n int solve(string &s){\n int n=s.length();\n int cnt=1;\n for(int i=0;i<n;i++){\n if(s[i]==\' \' | Pitbull_45 | NORMAL | 2022-05-28T19:15:41.127933+00:00 | 2022-05-28T19:15:58.403980+00:00 | 115 | false | ```\nclass Solution {\npublic:\n int solve(string &s){\n int n=s.length();\n int cnt=1;\n for(int i=0;i<n;i++){\n if(s[i]==\' \'){\n cnt++;\n }\n }\n return cnt;\n }\n string largestWordCount(vector<string>& messages, vector<string>& sende... | 5 | 0 | [] | 0 |
sender-with-largest-word-count | Map || C++ Solution | map-c-solution-by-shishir_sharma-xnrm | \nclass Solution {\npublic:\n\n int find(string str)\n{\n int count = 0;\n int temp = 0;\n int i=0;\n \n while (i!=str.length( | Shishir_Sharma | NORMAL | 2022-05-28T16:04:51.900623+00:00 | 2022-05-28T16:04:51.900654+00:00 | 701 | false | ```\nclass Solution {\npublic:\n\n int find(string str)\n{\n int count = 0;\n int temp = 0;\n int i=0;\n \n while (i!=str.length()){\n if (str[i] == \' \' || str[i] == \'\\n\' || str[i] == \'\\t\'){\n temp = 0;\n }\n else if(temp == 0){\n temp = 1;\n ... | 5 | 0 | ['C', 'C++'] | 1 |
sender-with-largest-word-count | [Python 3] 2 solutions, one pass and dictionary search | python-3-2-solutions-one-pass-and-dictio-caxz | Find the max sender name durion one iteration:\npython3 []\nclass Solution:\n def largestWordCount(self, messages: List[str], senders: List[str]) -> str:\n | yourick | NORMAL | 2023-07-13T22:39:24.472550+00:00 | 2024-03-08T22:12:29.548134+00:00 | 426 | false | ##### Find the max sender name durion one iteration:\n```python3 []\nclass Solution:\n def largestWordCount(self, messages: List[str], senders: List[str]) -> str:\n d, maxSenderName= defaultdict(int), \'\'\n for mes, name in zip(messages, senders):\n d[name] += len(mes.split())\n ... | 4 | 0 | ['Hash Table', 'Python', 'Python3'] | 0 |
sender-with-largest-word-count | Python fast solution with explanation | python-fast-solution-with-explanation-by-q158 | \nclass Solution:\n def largestWordCount(self, messages: List[str], senders: List[str]) -> str:\n \n # total will contain total sum of sender\' | a-miin | NORMAL | 2022-06-04T06:05:49.710413+00:00 | 2022-06-04T06:05:49.710457+00:00 | 301 | false | ```\nclass Solution:\n def largestWordCount(self, messages: List[str], senders: List[str]) -> str:\n \n # total will contain total sum of sender\'s words \n total = {}\n max_name = \'\'\n max_value = 0\n \n for i in range(len(senders)):\n ... | 4 | 0 | ['Python'] | 0 |
sender-with-largest-word-count | c++ || Count space || HashMap || 2284. Sender With Largest Word Count | c-count-space-hashmap-2284-sender-with-l-j0qo | \n\tclass Solution {\n\tpublic:\n\t\tstring largestWordCount(vector& messages, vector& senders) {\n\t\t\tmapm;\n\t\t\tfor(int i=0;imaxi)\n\t\t\t\t{\n\t\t\t\t\ta | anubhavsingh11 | NORMAL | 2022-05-28T17:12:17.949205+00:00 | 2022-05-28T17:12:17.949246+00:00 | 101 | false | \n\tclass Solution {\n\tpublic:\n\t\tstring largestWordCount(vector<string>& messages, vector<string>& senders) {\n\t\t\tmap<string,int>m;\n\t\t\tfor(int i=0;i<senders.size();i++)\n\t\t\t{\n\t\t\t\tint cnt=1;\n\t\t\t\tfor(int j=0;j<messages[i].size();j++)\n\t\t\t\t{\n\t\t\t\t\tif(messages[i][j]==\' \') cnt++;\n\t\t\t\t... | 4 | 0 | ['C'] | 0 |
sender-with-largest-word-count | Count Spaces | Maps | C++ | Easy to understand | count-spaces-maps-c-easy-to-understand-b-sly9 | We simply count the words for each sender and store the sender and their count of words in a map.\n\nFinally we iterate over the map and find sender with max wo | rgarg2580 | NORMAL | 2022-05-28T16:04:20.837164+00:00 | 2022-05-28T16:34:32.643425+00:00 | 243 | false | We simply count the words for each sender and store the sender and their count of words in a map.\n\nFinally we iterate over the map and find sender with max word count.\n\n```\nclass Solution {\n\t// Count number of words in a message by counting spaces\n int f(string s) {\n int words = 0;\n for(auto ... | 4 | 0 | ['C'] | 2 |
sender-with-largest-word-count | Map | map-by-yadavharsha50-y7mx | \nclass Solution {\n public String largestWordCount(String[] messages, String[] senders) {\n Map<String,Integer> map=new HashMap<>();\n int max | yadavharsha50 | NORMAL | 2022-05-28T16:02:22.650584+00:00 | 2022-05-28T16:02:22.650625+00:00 | 207 | false | ```\nclass Solution {\n public String largestWordCount(String[] messages, String[] senders) {\n Map<String,Integer> map=new HashMap<>();\n int max=0;\n for(int i=0;i<messages.length;i++){\n String s=messages[i];\n String str[]=s.split(" ");\n map.put(senders[i],m... | 4 | 0 | ['Java'] | 0 |
sender-with-largest-word-count | StringStream || Implementation Based Question || Sorting | stringstream-implementation-based-questi-83n6 | ```\nstatic bool cmp(pair &a,pair &b){\n \n if(a.first != b.first) return a.first > b.first;\n \n return a.second > b.second;\n | njcoder | NORMAL | 2022-05-28T16:00:55.981881+00:00 | 2022-05-28T16:00:55.981925+00:00 | 255 | false | ```\nstatic bool cmp(pair<int,string> &a,pair<int,string> &b){\n \n if(a.first != b.first) return a.first > b.first;\n \n return a.second > b.second;\n \n }\n \n string largestWordCount(vector<string>& M, vector<string>& S) {\n unordered_map<string,int> um;\n \n... | 4 | 0 | ['String', 'Sorting'] | 0 |
sender-with-largest-word-count | JAVA | Clean solution using HashMap | Explained ✅ | java-clean-solution-using-hashmap-explai-krcd | Solution explained using comments \uD83D\uDE07\n---\n### Code:\n\nclass Solution {\n public String largestWordCount(String[] messages, String[] senders) {\n | sourin_bruh | NORMAL | 2023-03-16T21:37:22.419373+00:00 | 2023-03-16T21:37:36.548092+00:00 | 258 | false | # Solution explained using comments \uD83D\uDE07\n---\n### Code:\n```\nclass Solution {\n public String largestWordCount(String[] messages, String[] senders) {\n // In a hashmap, record whhich person has sent how many words\n Map<String, Integer> map = new HashMap<>();\n for (int i = 0; i < mess... | 3 | 0 | ['Array', 'Hash Table', 'String', 'Java'] | 0 |
sender-with-largest-word-count | Simple Solution using Dictionary in Python | simple-solution-using-dictionary-in-pyth-fnrz | Intuition\n Describe your first thoughts on how to solve this problem. \nFirst of all , for this problem we are going to use a map which in python can be implem | niketh_1234 | NORMAL | 2022-11-18T12:23:25.601169+00:00 | 2022-11-18T12:23:25.601205+00:00 | 82 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nFirst of all , for this problem we are going to use a map which in python can be implemented by using dictionary.\nWe are going to find the words count of every sender\n\n# Approach\n<!-- Describe your approach to solving the problem. -->... | 3 | 0 | ['Ordered Map', 'Python3'] | 0 |
sender-with-largest-word-count | C++ Solution || Easy Explained || using maps. | c-solution-easy-explained-using-maps-by-8duw8 | we create a new function to count total number of words in a string;\n2. we create a a map PerUserWordCount and a vector maxCounter;\n3. we put all the count | prasoonrajpoot | NORMAL | 2022-07-28T05:12:26.795115+00:00 | 2022-07-28T05:12:26.795149+00:00 | 134 | false | 1. we create a new function to count total number of words in a string;\n2. we create a a map PerUserWordCount and a vector maxCounter;\n3. we put all the count of words per user in the map, while doing so , we also save the maximum frequency.\n4. we also check that if a multiple senders have maximum words, if so th... | 3 | 0 | ['String', 'C', 'Iterator'] | 0 |
sender-with-largest-word-count | Javascript || Count space || HashMap | javascript-count-space-hashmap-by-seymur-dcll | \n/**\n * @param {string[]} messages\n * @param {string[]} senders\n * @return {string}\n */\nvar largestWordCount = function(messages, senders) {\n let word | seymuromarov | NORMAL | 2022-06-02T15:15:39.655417+00:00 | 2022-06-02T15:24:55.917195+00:00 | 238 | false | ```\n/**\n * @param {string[]} messages\n * @param {string[]} senders\n * @return {string}\n */\nvar largestWordCount = function(messages, senders) {\n let wordCount = {}\n let result = \'\'\n let maxCount = -Infinity\n for (let i = 0; i < messages.length;i++) {\n let count=messages[i].split(\' \').l... | 3 | 0 | ['JavaScript'] | 0 |
sender-with-largest-word-count | Easy to Understand | Beginner Friendly | My Notes | easy-to-understand-beginner-friendly-my-1lesw | Keep a hashmap that stores keys as elements from sender and the value as a list with the indexes.\n\nIf Senders are [Alice,Zhund,Zhund,Alice]\n\nYour dictionary | thezhund | NORMAL | 2022-05-28T16:11:22.606904+00:00 | 2022-05-28T17:03:44.011027+00:00 | 292 | false | Keep a hashmap that stores keys as elements from sender and the value as a list with the indexes.\n\nIf Senders are [Alice,Zhund,Zhund,Alice]\n\nYour dictionary becomes: {\'Alice\': [0,3], \'Zhund\':[1,2]}\n\nNow you need to iterate within this dictionary.\nAnd use those indexes.\n\nSo, for every element, we can iterat... | 3 | 0 | ['Python'] | 0 |
sender-with-largest-word-count | Sender with largest Word Count | Java Solution | sender-with-largest-word-count-java-solu-j1xy | \nclass Solution {\n public String largestWordCount(String[] messages, String[] senders) {\n HashMap<String, Integer> hm=new HashMap<>();//sender->wor | shaguftashahroz09 | NORMAL | 2022-05-28T16:04:51.584498+00:00 | 2022-05-28T16:05:29.207348+00:00 | 195 | false | ```\nclass Solution {\n public String largestWordCount(String[] messages, String[] senders) {\n HashMap<String, Integer> hm=new HashMap<>();//sender->word count\n int n=messages.length;\n for(int i=0;i<n;i++)\n {\n String sender=senders[i];\n int wordCount=messages[i... | 3 | 0 | ['Java'] | 0 |
sender-with-largest-word-count | simple cpp solution | simple-cpp-solution-by-prithviraj26-8lbp | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | prithviraj26 | NORMAL | 2023-02-20T05:52:19.954146+00:00 | 2023-02-20T05:52:19.954198+00:00 | 124 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\no(n^2)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O... | 2 | 0 | ['Array', 'Hash Table', 'String', 'Counting', 'C++'] | 0 |
sender-with-largest-word-count | Java | HashMap | O(n) | Simple | java-hashmap-on-simple-by-judgementdey-r2iz | Intuition\n Describe your first thoughts on how to solve this problem. \nCalculate the word count for every message. Maintain a hash map of senders -> word coun | judgementdey | NORMAL | 2023-01-26T23:01:49.999534+00:00 | 2023-01-26T23:01:49.999565+00:00 | 190 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nCalculate the word count for every message. Maintain a hash map of senders -> word count. Iterate over the hash map and figure out the sender with the largest word count.\n\n# Approach\n<!-- Describe your approach to solving the problem. ... | 2 | 0 | ['Hash Table', 'Java'] | 0 |
sender-with-largest-word-count | c++| Faster than 100% | Hashmap | c-faster-than-100-hashmap-by-zdansari-syjq | \n\n\n\n// This function takes in two vectors of strings, "messages" and "senders", and returns the sender \n// with the largest number of words in their messag | zdansari | NORMAL | 2023-01-13T06:11:16.023320+00:00 | 2023-01-13T06:15:52.367202+00:00 | 453 | false | \n\n\n```\n// This function takes in two vectors of strings, "messages" and "senders", and returns the sender \n// with the largest number of words in their messages. \nstring largestWordCount(vector<string>& messages, vector<string>& senders) {\n // Create an unordered map to store the number of words in each sende... | 2 | 0 | ['C'] | 1 |
sender-with-largest-word-count | Simple Java Solution Beats 99% | simple-java-solution-beats-99-by-nomaana-ydp2 | \nclass Solution {\n public String largestWordCount(String[] messages, String[] senders) \n {\n HashMap<String,Integer> map = new HashMap<>();\n | nomaanansarii100 | NORMAL | 2022-10-19T05:35:43.896265+00:00 | 2022-10-19T05:35:43.896308+00:00 | 528 | false | ```\nclass Solution {\n public String largestWordCount(String[] messages, String[] senders) \n {\n HashMap<String,Integer> map = new HashMap<>();\n String res = "";int max =0;\n \n for(int i=0; i<messages.length;i++)\n {\n int words = get_count(messages[i]);\n ... | 2 | 0 | ['Counting', 'Java'] | 0 |
sender-with-largest-word-count | Python Faster | python-faster-by-onosetaleoseghale-fvb2 | ```\n def largestWordCount(self, messages: List[str], senders: List[str]) -> str:\n \n hashMap = {}\n for message, sender in zip(messages, senders | onosetaleoseghale | NORMAL | 2022-10-07T08:52:20.199719+00:00 | 2022-10-07T08:52:20.199757+00:00 | 169 | false | ```\n def largestWordCount(self, messages: List[str], senders: List[str]) -> str:\n \n hashMap = {}\n for message, sender in zip(messages, senders):\n if sender in hashMap:\n hashMap[sender] += len(message.split())\n else:\n hashMap[sender] = len(message... | 2 | 0 | ['Python'] | 0 |
sender-with-largest-word-count | Python3 | Hash word count associated with a sender's name then return max | python3-hash-word-count-associated-with-oywyd | \nclass Solution:\n def largestWordCount(self, messages: List[str], senders: List[str]) -> str:\n words_count = defaultdict(int)\n for m, perso | ploypaphat | NORMAL | 2022-09-30T18:24:34.888046+00:00 | 2022-09-30T18:24:34.888078+00:00 | 466 | false | ```\nclass Solution:\n def largestWordCount(self, messages: List[str], senders: List[str]) -> str:\n words_count = defaultdict(int)\n for m, person in zip(messages, senders):\n words_count[person] += len(m.split())\n \n max_len = max(words_count.values())\n \n ... | 2 | 0 | ['Python', 'Python3'] | 0 |
sender-with-largest-word-count | C++ Solution Using Hashmap | Simple & Easy | c-solution-using-hashmap-simple-easy-by-o3na4 | Just create a map of (string, int) pair and store the count of no of words for each word in the map. \nAfter this iterate and find the strings for maximum count | shrudex | NORMAL | 2022-09-06T19:16:20.234661+00:00 | 2022-09-06T19:16:20.234696+00:00 | 198 | false | Just create a map of (string, int) pair and store the count of no of words for each word in the map. \nAfter this iterate and find the strings for maximum count, if 2 such string exists, check which one is lexicographically greater and print the required output.\n\n```\nclass Solution {\npublic:\n string largestWord... | 2 | 0 | ['Hash Table', 'C++'] | 0 |
sender-with-largest-word-count | Python: Easy Sorting & Map | python-easy-sorting-map-by-jijnasu-oqr4 | \nclass Solution:\n def largestWordCount(self, messages: List[str], senders: List[str]) -> str:\n d = defaultdict(int)\n mx = 0\n for i, | jijnasu | NORMAL | 2022-09-03T12:33:25.716944+00:00 | 2022-09-03T12:33:25.716982+00:00 | 145 | false | ```\nclass Solution:\n def largestWordCount(self, messages: List[str], senders: List[str]) -> str:\n d = defaultdict(int)\n mx = 0\n for i,snd in enumerate(senders):\n d[snd] += len(messages[i].split())\n mx = max(mx, d[snd])\n \n for snd in sorted(d.keys())[:... | 2 | 0 | [] | 1 |
sender-with-largest-word-count | Python 99.90 memory efficient - Simple | Fast | Detailed Explanation | python-9990-memory-efficient-simple-fast-qpo8 | Take a defaultdict of integers to store the count of words.\n Iterate over the senders array and count number of words during each iteration. If key already exi | hitttttt | NORMAL | 2022-08-10T08:54:24.820217+00:00 | 2022-08-10T08:54:46.736247+00:00 | 71 | false | * Take a `defaultdict` of integers to store the count of words.\n* Iterate over the `senders` array and count number of words during each iteration. If key already exisits in the hash table, add the current value in already exisiting value. For example, if `Alice` has send a message `Hi`. Add it to the dictionary with ... | 2 | 0 | ['String'] | 0 |
sender-with-largest-word-count | JAVA || HASHMAP || ONE PASS || COUNT SPACE +1 | java-hashmap-one-pass-count-space-1-by-2-tp1e | \nclass Solution {\n public String largestWordCount(String[] messages, String[] senders) \n {\n int n=messages.length;\n \n String an | 29nidhishah | NORMAL | 2022-06-28T06:37:06.334478+00:00 | 2022-06-28T06:37:06.334519+00:00 | 187 | false | ```\nclass Solution {\n public String largestWordCount(String[] messages, String[] senders) \n {\n int n=messages.length;\n \n String ans="";\n int max=0;\n Map<String,Integer> map=new HashMap<>();\n \n for(int i=0;i<n;i++)\n {\n int c=0;\n ... | 2 | 0 | ['String', 'Java'] | 0 |
sender-with-largest-word-count | Python3 - Clear solution using dictionaries for word count per sender | python3-clear-solution-using-dictionarie-uvzu | At first glance, I thought that I can get the solution by making one loop over zip(messages, senders) and finding the sender with the maximum word count, But I | ahmadheshamzaki | NORMAL | 2022-06-14T16:50:40.853490+00:00 | 2022-06-14T16:50:40.853536+00:00 | 254 | false | At first glance, I thought that I can get the solution by making one loop over `zip(messages, senders)` and finding the sender with the maximum word count, But I realized that this won\'t work because a sender can send multple messages. Therefore, I had to create a dictionary to track the word count of each sender, the... | 2 | 0 | ['Counting', 'Python', 'Python3'] | 0 |
sender-with-largest-word-count | c# and Linq | c-and-linq-by-bytchenko-zkdl | We can just query the both arrays with a help of Linq. Instead of counting words (which can be time consuming for Split) we can count spaces:\n\n\n wordCount | bytchenko | NORMAL | 2022-05-29T09:58:05.895551+00:00 | 2022-05-29T09:58:21.064624+00:00 | 109 | false | We can just *query* the both arrays with a help of *Linq*. Instead of counting words (which can be time consuming for `Split`) we can count *spaces*:\n\n```\n wordCount = spaceCount + 1\n```\n\n**Code:**\n\n```\npublic class Solution {\n public string LargestWordCount(string[] messages, string[] senders) {\n ... | 2 | 0 | [] | 0 |
sender-with-largest-word-count | C# || Dictionary | c-dictionary-by-cdev-8k1d | \n public string LargestWordCount(string[] messages, string[] senders)\n {\n Dictionary<string, int> messageCount = new();\n for (int i = 0; | CDev | NORMAL | 2022-05-28T19:23:56.076178+00:00 | 2022-05-28T19:24:12.756150+00:00 | 120 | false | ```\n public string LargestWordCount(string[] messages, string[] senders)\n {\n Dictionary<string, int> messageCount = new();\n for (int i = 0; i < messages.Length; i++)\n {\n messageCount.TryAdd(senders[i], 0);\n messageCount[senders[i]] += messages[i].Split(\' \').Coun... | 2 | 0 | [] | 2 |
sender-with-largest-word-count | easiest explanation python | easiest-explanation-python-by-vansh_ika-6nal | class Solution:\n def largestWordCount(self, messages: List[str], senders: List[str]) -> str:\n \n f={}\n for i in range(len(senders)):\ | Vansh_ika | NORMAL | 2022-05-28T18:07:16.735335+00:00 | 2022-05-28T18:07:16.735372+00:00 | 68 | false | class Solution:\n def largestWordCount(self, messages: List[str], senders: List[str]) -> str:\n \n f={}\n for i in range(len(senders)):\n if senders[i] in f:\n f[senders[i]]=f[senders[i]]+" "+messages[i]\n else:\n f[senders[i]]=messages[i]\n ... | 2 | 0 | ['Python'] | 0 |
sender-with-largest-word-count | c++ || priority queue + hashmap | c-priority-queue-hashmap-by-ayushanand24-0331 | \nclass Solution {\nprivate:\n struct my_comparator {\n bool operator() (const pair<int,string>&a, const pair<int,string>& b) {\n if(a.firs | ayushanand245 | NORMAL | 2022-05-28T17:16:38.674985+00:00 | 2022-05-28T17:16:38.675027+00:00 | 124 | false | ```\nclass Solution {\nprivate:\n struct my_comparator {\n bool operator() (const pair<int,string>&a, const pair<int,string>& b) {\n if(a.first != b.first) {\n return a.first > b.first;\n }\n else {\n return a.second > b.second;\n }\n ... | 2 | 0 | ['Heap (Priority Queue)'] | 0 |
sender-with-largest-word-count | ✅ C++ | Count space & map | Easy to understand | c-count-space-map-easy-to-understand-by-mm3gv | \nclass Solution {\npublic:\n\t// this function will return the number of words in the given string\n int countWord(string s){\n int cnt=1;\n f | rupam66 | NORMAL | 2022-05-28T16:26:55.745960+00:00 | 2022-05-28T16:26:55.745995+00:00 | 179 | false | ```\nclass Solution {\npublic:\n\t// this function will return the number of words in the given string\n int countWord(string s){\n int cnt=1;\n for(int i=0;i<s.size();i++) \n if(s[i]==\' \') cnt++;\n return cnt;\n }\n string largestWordCount(vector<string>& messages, vector<str... | 2 | 0 | ['C'] | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.