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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
minimum-deletions-to-make-string-k-special | C++ using memo and sort-counting | c-using-memo-and-sort-counting-by-aavii-iqq4 | 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 | aavii | NORMAL | 2024-03-28T17:38:58.459555+00:00 | 2024-03-28T17:38:58.459588+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 | ['C++'] | 0 |
minimum-deletions-to-make-string-k-special | [Java] Simple solution frequency array | java-simple-solution-frequency-array-by-3haxb | Upvote if you learn something new :)\n\nclass Solution {\n public int minimumDeletions(String word, int k) {\n int[] freq = new int[26];\n \n | Naresh_Choudhary | NORMAL | 2024-03-27T13:03:38.411667+00:00 | 2024-03-27T13:03:38.411710+00:00 | 16 | false | **Upvote if you learn something new :)**\n```\nclass Solution {\n public int minimumDeletions(String word, int k) {\n int[] freq = new int[26];\n \n for(char c : word.toCharArray()){\n freq[c-\'a\']++;\n }\n \n int min = Integer.MAX_VALUE;\n for(int i=0; i<... | 0 | 0 | ['Java'] | 0 |
minimum-deletions-to-make-string-k-special | easy to understand c++ | easy-to-understand-c-by-warril-x7jd | all steps according to hints\n\n# Code\n\nclass Solution {\npublic:\n int minimumDeletions(string word, int k) {\n\n unordered_map<char,int>m;\n\n | warril | NORMAL | 2024-03-27T10:11:27.842318+00:00 | 2024-03-27T10:11:27.842349+00:00 | 19 | false | all steps according to hints\n\n# Code\n```\nclass Solution {\npublic:\n int minimumDeletions(string word, int k) {\n\n unordered_map<char,int>m;\n\n for(auto &i:word)\n m[i]++;\n\n vector<int>freq;\n for(auto i:m)\n {freq.push_back(i.second);}\n\n sort(freq.begin(),... | 0 | 0 | ['C++'] | 0 |
minimum-deletions-to-make-string-k-special | C++ solution | c-solution-by-bhanutechie-0tcf | Code\n\nclass Solution {\npublic:\n int minimumDeletions(string word, int k) {\n unordered_map<char, int> m;\n int n = word.size();\n fo | bhanutechie | NORMAL | 2024-03-26T08:31:59.919139+00:00 | 2024-03-26T08:31:59.919171+00:00 | 12 | false | # Code\n```\nclass Solution {\npublic:\n int minimumDeletions(string word, int k) {\n unordered_map<char, int> m;\n int n = word.size();\n for(int i = 0; i < n; i++) {\n m[word[i]]++;\n }\n vector<int> v;\n for(auto it : m) {\n v.push_back(it.second);\n... | 0 | 0 | ['C++'] | 0 |
minimum-deletions-to-make-string-k-special | simple and easy | simple-and-easy-by-hardik_3010-uzg9 | \n# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(1)\n\n# Code\n\nclass Solution {\npublic:\n int minimumDeletions(string word, int k) {\n | hardik_3010 | NORMAL | 2024-03-25T14:27:45.090883+00:00 | 2024-03-25T14:27:45.090921+00:00 | 8 | false | \n# Complexity\n- Time complexity:\n**O(n)**\n\n- Space complexity:\n**O(1)**\n\n# Code\n```\nclass Solution {\npublic:\n int minimumDeletions(string word, int k) {\n vector<int> freq(26, 0);\n\n for(char &ch : word) {\n freq[ch-\'a\']++;\n }\n\n sort(begin(freq), end(freq));\n... | 0 | 0 | ['Two Pointers', 'Sorting', 'C++'] | 0 |
minimum-deletions-to-make-string-k-special | scala solution | scala-solution-by-lyk4411-7a13 | 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 | lyk4411 | NORMAL | 2024-03-25T09:13:13.190770+00:00 | 2024-03-25T09:15:53.329720+00:00 | 10 | 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 | ['Scala'] | 0 |
minimum-deletions-to-make-string-k-special | Easy to understand code | easy-to-understand-code-by-ps02-xvoa | 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 | PS02 | NORMAL | 2024-03-25T08:50:57.376693+00:00 | 2024-03-25T08:50:57.376727+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)$$ -->\nO(N)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n... | 0 | 0 | ['Python3'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | ✅ [Python/C++] prime factorization (explained) | pythonc-prime-factorization-explained-by-tnui | \u2705 IF YOU LIKE THIS SOLUTION, PLEASE UPVOTE.\n*\nThis solution employs prime factorization.\n\n\nComment. The idea of this solution relies on the fact that | stanislav-iablokov | NORMAL | 2022-12-18T04:01:36.525821+00:00 | 2022-12-18T07:45:31.254379+00:00 | 5,635 | false | **\u2705 IF YOU LIKE THIS SOLUTION, PLEASE UPVOTE.**\n****\nThis solution employs prime factorization.\n****\n\n**Comment.** The idea of this solution relies on the fact that a number is not less than the sum of its primes. Equality is attained for the prime numbers themselves and also for the number 4. Thus we can ite... | 41 | 10 | [] | 9 |
smallest-value-after-replacing-with-sum-of-prime-factors | C++ || Simple Prime Factorization | c-simple-prime-factorization-by-mohakhar-4de3 | \nclass Solution {\npublic:\n long long getSumOfFactors(int n)\n {\n int divisor = 2;\n long long ans = 0;\n while(n > 1)\n {\ | mohakharjani | NORMAL | 2022-12-18T04:06:42.735926+00:00 | 2022-12-18T04:06:42.735963+00:00 | 3,423 | false | ```\nclass Solution {\npublic:\n long long getSumOfFactors(int n)\n {\n int divisor = 2;\n long long ans = 0;\n while(n > 1)\n {\n if (n % divisor == 0) \n {\n ans += divisor;\n n = n / divisor;\n }\n else diviso... | 36 | 5 | ['C', 'C++'] | 6 |
smallest-value-after-replacing-with-sum-of-prime-factors | simple java prime factorization | simple-java-prime-factorization-by-flyro-mko9 | \nclass Solution {\n public int smallestValue(int n) {\n int sum=n;\n while(true){\n int sum1=0;\n int c=2;\n | flyRoko123 | NORMAL | 2022-12-18T04:46:31.393756+00:00 | 2022-12-18T04:46:31.393795+00:00 | 2,031 | false | ```\nclass Solution {\n public int smallestValue(int n) {\n int sum=n;\n while(true){\n int sum1=0;\n int c=2;\n //for prime factors\n while(n>1){\n \n if(n%c==0){\n sum1+=c;\n n=n/c;\n ... | 28 | 0 | ['Math', 'Greedy', 'Java'] | 5 |
smallest-value-after-replacing-with-sum-of-prime-factors | Python 3 || 10 lines, recursion, w/ brief explanation || T/S: 42% / 90% | python-3-10-lines-recursion-w-brief-expl-tbkt | \nclass Solution:\n def smallestValue(self, n):\n\n prev, ans = n, 0\n\n while not n%2: # 2 is the unique even prime\n | Spaulding_ | NORMAL | 2022-12-18T21:01:18.699217+00:00 | 2024-06-16T21:02:45.454524+00:00 | 1,153 | false | ```\nclass Solution:\n def smallestValue(self, n):\n\n prev, ans = n, 0\n\n while not n%2: # 2 is the unique even prime\n ans += 2\n n//= 2\n\n for i in range(3,n+1,2): # <\u2013\u2013 prune even divisors...\n while not n%i:\n... | 14 | 0 | ['Python', 'Python3'] | 1 |
smallest-value-after-replacing-with-sum-of-prime-factors | Prime Factorization | prime-factorization-by-votrubac-hqni | We prepare the list of primes to cover up to sqrt(10,000). You can either precompute them, or just use a static array.\n\n> This is an important optimization. W | votrubac | NORMAL | 2022-12-18T04:01:23.407690+00:00 | 2022-12-21T00:05:45.138845+00:00 | 2,314 | false | We prepare the list of primes to cover up to `sqrt(10,000)`. You can either precompute them, or just use a static array.\n\n> This is an important optimization. We check up to 65 primes for `n`, and the complexity is \u03C0(sqrt(n)).\n> If, after we try all primes, `n > 1`, then `n` is a large prime. E.g. for 99951 exa... | 13 | 2 | [] | 6 |
smallest-value-after-replacing-with-sum-of-prime-factors | Straight Forward || Easy || Reacursion|| Prime Factorization | straight-forward-easy-reacursion-prime-f-0umu | Base case: If n is prime it means we can not subdivide it, means it is in its minimum form hence return it.\n\nIf the sum_of_prime_factors_of_n == n then it me | pankaj_patel63 | NORMAL | 2022-12-18T05:39:03.876835+00:00 | 2023-02-22T04:33:12.063245+00:00 | 607 | false | Base case: If n is prime it means we can not subdivide it, means it is in its minimum form hence return it.\n\nIf the sum_of_prime_factors_of_n == n then it means we can not reduce it so we return n otherwise it will create infinite loop.\n\n# Code\n```\nclass Solution {\n bool isPrime(int n){\n for(int i = ... | 8 | 0 | ['Recursion', 'C'] | 2 |
smallest-value-after-replacing-with-sum-of-prime-factors | Very Simple Recursion | very-simple-recursion-by-kreakemp-hsqz | \n\n/*\nHere we use the theorem to optimize the runtime, that is prime no can be always in the form of 6k+1 or 6k-1, except 2 & 3\nSo we only itereate on 2, 3, | kreakEmp | NORMAL | 2022-12-18T04:01:42.814610+00:00 | 2022-12-18T04:01:42.814646+00:00 | 1,831 | false | ```\n\n/*\nHere we use the theorem to optimize the runtime, that is prime no can be always in the form of 6k+1 or 6k-1, except 2 & 3\nSo we only itereate on 2, 3, 6k-1 & 6k + 1\nWe have return a separate function that just keep on evluating the sum of all factor and return total sum.\n*/\nclass Solution {\npublic:\n ... | 8 | 6 | ['C++'] | 2 |
smallest-value-after-replacing-with-sum-of-prime-factors | Beginner friendly Java Solution | beginner-friendly-java-solution-by-himan-djph | Code\n\nclass Solution {\n public int smallestValue(int n) {\n if(n == 0 || n == 4) return 4;\n return factors(n);\n }\n private int fac | HimanshuBhoir | NORMAL | 2022-12-18T04:09:09.105264+00:00 | 2022-12-18T04:09:09.105295+00:00 | 582 | false | # Code\n```\nclass Solution {\n public int smallestValue(int n) {\n if(n == 0 || n == 4) return 4;\n return factors(n);\n }\n private int factors(int n){\n int i, sum = 0;\n for(i=2; i<=n; i++){\n while(n%i == 0){\n sum += i;\n n /= i;\n ... | 7 | 0 | ['Java'] | 1 |
smallest-value-after-replacing-with-sum-of-prime-factors | [C++|Java|Python3] simulation | cjavapython3-simulation-by-ye15-b79g | Please pull this commit for solutions of weekly 324. \n\nIntuition\nWe can simply repeatedly compute the sum of prime factors of each number and see where it en | ye15 | NORMAL | 2022-12-18T04:03:58.319937+00:00 | 2022-12-18T23:08:51.706829+00:00 | 729 | false | Please pull this [commit](https://github.com/gaosanyong/leetcode/commit/af6e415cd101768ea8743ea9e4d22d788c9461c3) for solutions of weekly 324. \n\n**Intuition**\nWe can simply repeatedly compute the sum of prime factors of each number and see where it ends. \n**Implementation**\n**C++**\n```\nclass Solution {\npublic: ... | 7 | 0 | ['C', 'Java', 'Python3'] | 2 |
smallest-value-after-replacing-with-sum-of-prime-factors | [C++] Using Sieve | c-using-sieve-by-vgnshiyer-y4lc | \nclass Solution {\npublic:\n vector<int> sieve(int n){\n vector<int> isPrime(n+1, 1);\n isPrime[0] = isPrime[1] = 0;\n \n vector | vgnshiyer | NORMAL | 2022-12-18T04:01:24.487390+00:00 | 2022-12-18T04:01:24.487435+00:00 | 828 | false | ```\nclass Solution {\npublic:\n vector<int> sieve(int n){\n vector<int> isPrime(n+1, 1);\n isPrime[0] = isPrime[1] = 0;\n \n vector<int> prime;\n for(int i = 2; i <= n; i++){\n if(isPrime[i]){\n prime.push_back(i);\n for(long long j = (long... | 6 | 0 | ['C'] | 1 |
smallest-value-after-replacing-with-sum-of-prime-factors | ✳️Two Solution |Factorization is optimized using Sieve of Eratosthenes✅ | two-solution-factorization-is-optimized-bhxoy | Intuition\nWe know that product of numbers are always greater than sum of numbers, if the numbers are greater than 1. Hence, we repeatedly find the sum of the | tbekzhoroev | NORMAL | 2022-12-18T04:08:48.710915+00:00 | 2023-03-09T12:40:02.731514+00:00 | 587 | false | # Intuition\nWe know that product of numbers are always greater than sum of numbers, if the numbers are greater than 1. Hence, we repeatedly find the sum of the factors of a given number until the sum is itself. \n\n\n# Space Complexity: $\\mathcal{O}(1)$\n\n\n# Solution 1\n```\nclass Solution:\n def smallestValue(... | 5 | 0 | ['Math', 'Python', 'Python3'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | C++ || Simple Prime Factorisation || EAsy to Understand | c-simple-prime-factorisation-easy-to-und-ds46 | \n# Code\n\nclass Solution {\npublic:\n int smallestValue(int n) {\n while(n){\n int sum = 0;\n int prev = n;\n for(i | pradipta_ltcode | NORMAL | 2022-12-18T04:08:47.786351+00:00 | 2022-12-18T04:08:47.786393+00:00 | 641 | false | \n# Code\n```\nclass Solution {\npublic:\n int smallestValue(int n) {\n while(n){\n int sum = 0;\n int prev = n;\n for(int i=2;i<=n;){\n if(n%i ==0){\n sum+=i;\n n/=i;\n }\n else{\n ... | 5 | 0 | ['C++'] | 2 |
smallest-value-after-replacing-with-sum-of-prime-factors | Simple java solution | simple-java-solution-by-siddhant_1602-w06r | \n\n# Code\n\nclass Solution {\n public int smallestValue(int n) {\n int k=n;\n if(n<=4)\n return n;\n\t\twhile(true)\n {\n | Siddhant_1602 | NORMAL | 2022-12-18T04:01:08.233023+00:00 | 2022-12-18T04:03:36.959435+00:00 | 1,325 | false | \n\n# Code\n```\nclass Solution {\n public int smallestValue(int n) {\n int k=n;\n if(n<=4)\n return n;\n\t\twhile(true)\n {\n int sum=0;\n for (int i=2;i<=n/2;i++)\n {\n //System.out.println(i);\n if(prime(i))\n ... | 5 | 1 | ['Java'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | Java | Simplest solution | beats 100% | java-simplest-solution-beats-100-by-akxh-cj5p | Approach\n Describe your approach to solving the problem. \n1. If a number is prime, that is the smallest value itself.\n2. Else Calculate the sum of prime fact | akxhayxharma | NORMAL | 2022-12-18T04:01:05.513982+00:00 | 2022-12-19T03:26:36.229093+00:00 | 1,801 | false | # Approach\n<!-- Describe your approach to solving the problem. -->\n1. If a number is prime, that is the smallest value itself.\n2. Else Calculate the sum of prime factors\n - Calculate first prime factor.\n - Add in sum\n - Calculate remainder\n - Reapeat above steps till remainder is prime.\n - Add re... | 5 | 0 | ['Java'] | 2 |
smallest-value-after-replacing-with-sum-of-prime-factors | Beats 100% || Easy and Simple Solution🔥🔥 | beats-100-easy-and-simple-solution-by-_j-udez | Intuition\nBasic intution is find the sum of only those factors which are prime and then replacing it with the initial "n" till the number "n" have no factor ot | _jarvis | NORMAL | 2023-12-21T08:00:45.403193+00:00 | 2023-12-21T08:09:40.969745+00:00 | 69 | false | # Intuition\nBasic intution is find the sum of only those factors which are prime and then replacing it with the initial "n" till the number "n" have no factor other than 1 and "n", i.e. till "n" becomes prime.\n\n**Every line of code is explained through comments**\n\n\n# Code\n```\nclass Solution {\npublic:\nbool isP... | 4 | 0 | ['C++'] | 1 |
smallest-value-after-replacing-with-sum-of-prime-factors | C++ || MATHS | c-maths-by-ganeshkumawat8740-z3mk | Code\n\nclass Solution {\npublic:\n int smallestValue(int n) {\n int x ,k,i;\n while(n){\n x = 0;\n k = n;\n f | ganeshkumawat8740 | NORMAL | 2023-07-30T08:57:47.505785+00:00 | 2023-07-30T08:57:47.505812+00:00 | 216 | false | # Code\n```\nclass Solution {\npublic:\n int smallestValue(int n) {\n int x ,k,i;\n while(n){\n x = 0;\n k = n;\n for(i = 2; i <= sqrt(n); i++){\n while(n%i == 0){\n x += i;\n n /= i;\n }\n }... | 4 | 0 | ['Math', 'Number Theory', 'C++'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | C++ || Commented-Code | c-commented-code-by-sourabcodes-1yfv | class Solution {\npublic:\n \n //* Function to create a hash array for prime numbers till n *.\n vector hashprime(int n){\n vector arr(n,0);\n\n | SourabCodes | NORMAL | 2022-12-18T19:19:23.710811+00:00 | 2022-12-18T19:19:23.710839+00:00 | 144 | false | class Solution {\npublic:\n \n //**** Function to create a hash array for prime numbers till n ****.\n vector<int> hashprime(int n){\n vector<int> arr(n,0);\n\n for(int i = 0 ; i < n ; i++){\n arr[i] = i;\n }\n arr[0] = arr[1] = 0;\n for(int i = 2 ; i < n ; i++){\n... | 4 | 0 | ['C'] | 1 |
smallest-value-after-replacing-with-sum-of-prime-factors | Simple || C++ | simple-c-by-shrikanta8-xy2j | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. \n\n\n\n\n\n\n\n \n\n# Code\n\nclass Solution {\npublic:\n int primeFactorsFin | Shrikanta8 | NORMAL | 2022-12-18T04:02:03.187600+00:00 | 2022-12-18T04:03:34.900199+00:00 | 397 | 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:\nAdd your space complexity... | 4 | 0 | ['C++'] | 1 |
smallest-value-after-replacing-with-sum-of-prime-factors | Java Solution | java-solution-by-kthnode-b34e | 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 | kthNode | NORMAL | 2023-05-28T06:35:56.240427+00:00 | 2023-05-28T06:35:56.240468+00:00 | 410 | 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)$$ --... | 3 | 0 | ['Java'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | c++ || easy solution using prime factarization and seive | c-easy-solution-using-prime-factarizatio-waa3 | 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 | aashi__70 | NORMAL | 2023-01-30T19:05:04.338463+00:00 | 2023-01-30T19:05:04.338502+00:00 | 86 | 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)$$ --... | 3 | 0 | ['C++'] | 1 |
smallest-value-after-replacing-with-sum-of-prime-factors | using prime factor | using-prime-factor-by-lavkush_173-ukuh | Intuition\nUsing prime factore\n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time complexity:\n Add your time complexity he | Lavkush_173 | NORMAL | 2022-12-20T18:13:38.728902+00:00 | 2022-12-20T18:13:38.728941+00:00 | 127 | false | # Intuition\nUsing prime factore\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)$$ -->\n\n# Code\n```\nclass Solution {\n public ... | 3 | 0 | ['Java'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | Check Prime | check-prime-by-ayushy_78-ti52 | # Intuition \n\n\n\n\n\n# Complexity\n- Time complexity: O((log n) ^ 2)\n\n\n- Space complexity: O(log n)\n\n\n# Code\n\nclass Solution {\npublic:\n bool i | SelfHelp | NORMAL | 2022-12-18T04:50:42.229427+00:00 | 2022-12-18T04:50:42.229451+00:00 | 137 | 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: *`O((log n) ^ 2)`*\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: *`O(log n)`*\n<!-... | 3 | 0 | ['Math', 'Simulation', 'C++'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | ✅ C++ || Simple Solution || Easy Solution | c-simple-solution-easy-solution-by-indre-5fiy | \nclass Solution {\npublic:\n vector<int> findPrimeFactors(int n) {\n vector<int> prime_factors;\n // 2 is the smallest prime number\n while (n % 2 | indresh149 | NORMAL | 2022-12-18T04:03:59.929917+00:00 | 2022-12-18T04:03:59.929973+00:00 | 1,147 | false | ```\nclass Solution {\npublic:\n vector<int> findPrimeFactors(int n) {\n vector<int> prime_factors;\n // 2 is the smallest prime number\n while (n % 2 == 0) {\n prime_factors.push_back(2);\n n = n / 2;\n }\n // check for other prime numbers up to sqrt(n)\n for (int i = 3; i <= sqrt(n)... | 3 | 0 | ['C'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | Python3 | Finding prime factors | Intuitive | Easy to understand | python3-finding-prime-factors-intuitive-1tcf6 | \n# Code\n\nclass Solution:\n def prime_factors(self, n):\n i = 2\n factors = []\n while i * i <= n:\n if n % i:\n | jubinsoni | NORMAL | 2022-12-18T04:02:01.658476+00:00 | 2022-12-18T04:02:01.658518+00:00 | 886 | false | \n# Code\n```\nclass Solution:\n def prime_factors(self, n):\n i = 2\n factors = []\n while i * i <= n:\n if n % i:\n i += 1\n else:\n n //= i\n factors.append(i)\n if n > 1:\n factors.append(n)\n return ... | 3 | 0 | ['Math', 'Python3'] | 1 |
smallest-value-after-replacing-with-sum-of-prime-factors | Easy cpp | easy-cpp-by-psetti-f9nc | \nclass Solution {\npublic:\n int smallestValue(int n) {\n int primes = primeFactors(n);\n if(primes == n) {\n return n;\n } | psetti | NORMAL | 2022-12-18T04:00:58.557573+00:00 | 2022-12-18T04:00:58.557621+00:00 | 1,411 | false | ```\nclass Solution {\npublic:\n int smallestValue(int n) {\n int primes = primeFactors(n);\n if(primes == n) {\n return n;\n }\n return smallestValue(primes);\n }\n int primeFactors(int n) {\n int result = 0;\n while (n % 2 == 0)\n {\n ... | 3 | 0 | ['Math'] | 1 |
smallest-value-after-replacing-with-sum-of-prime-factors | ✔[C++] Simple Solution | c-simple-solution-by-in-imitable-n2yr | Code\n\nclass Solution {\npublic:\n int solve(int n){\n if(n<=3) return n;\n int sum=0;\n for(int i=2; i<=n; i++){\n while(n% | in-imitable | NORMAL | 2022-12-18T07:12:44.636629+00:00 | 2022-12-18T07:12:44.636656+00:00 | 159 | false | # Code\n```\nclass Solution {\npublic:\n int solve(int n){\n if(n<=3) return n;\n int sum=0;\n for(int i=2; i<=n; i++){\n while(n%i == 0){\n sum += i;\n n = n/i;\n }\n }\n return sum;\n }\n int smallestValue(int n) {\n ... | 2 | 0 | ['C++'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | python3 Solution | python3-solution-by-motaharozzaman1996-ftvj | \n\nclass Solution:\n def smallestValue(self, n: int) -> int:\n while True:\n c=2\n t=0\n b=n\n\n while c* | Motaharozzaman1996 | NORMAL | 2022-12-18T04:14:15.715013+00:00 | 2022-12-18T04:14:15.715060+00:00 | 116 | false | \n```\nclass Solution:\n def smallestValue(self, n: int) -> int:\n while True:\n c=2\n t=0\n b=n\n\n while c*c<=n:\n while n%c==0:\n n//=c\n t+=c\n\n c+=1\n\n if t==0:\n re... | 2 | 0 | ['Python3'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | ✅ Easy and simple || recursive || C++ | easy-and-simple-recursive-c-by-mohitk30-6pub | \n\nclass Solution {\npublic:\n int f(int n)\n{\n int sm=0;\n while (n % 2 == 0)\n {\n // cout << 2 << " ";\n sm+=2;\n n = n/2; | mohitk30 | NORMAL | 2022-12-18T04:01:06.585277+00:00 | 2022-12-18T04:01:06.585320+00:00 | 1,136 | false | \n```\nclass Solution {\npublic:\n int f(int n)\n{\n int sm=0;\n while (n % 2 == 0)\n {\n // cout << 2 << " ";\n sm+=2;\n n = n/2;\n }\n \n \n for (int i = 3; i <= sqrt(n); i = i + 2)\n {\n \n while (n % i == 0)\n {\n // cout << i << " ";\n ... | 2 | 0 | ['C++'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | Recursive solution with factorization, Beats 100% | recursive-solution-with-factorization-be-3alz | Code | simolekc | NORMAL | 2025-03-03T16:24:06.142152+00:00 | 2025-03-03T16:24:06.142152+00:00 | 43 | false |
# Code
```javascript []
/**
* @param {number} n
* @return {number}
*/
var smallestValue = function (n) {
let result = n;
let newResult = 0;
let divisor = 2;
while (n > 1) {
while (n % divisor === 0) {
newResult += divisor;
n /= divisor;
}
divisor++;
... | 1 | 0 | ['JavaScript'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | (Java) || Time complexity: O(log n . √n) || Runtime : 1ms | java-time-complexity-olog-n-n-runtime-1m-qtdp | IntuitionThe problem requires repeatedly reducing a number 𝑛 by replacing it with the sum of its prime factors until it becomes a prime number. The key observat | shikhargupta0645 | NORMAL | 2025-01-22T01:40:21.653395+00:00 | 2025-01-22T01:40:21.653395+00:00 | 41 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
The problem requires repeatedly reducing a number 𝑛 by replacing it with the sum of its prime factors until it becomes a prime number. The key observation is that during each iteration, 𝑛 gets smaller (or stabilizes) due to the summation ... | 1 | 0 | ['Java'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | easy solution using recursion and maths | easy-solution-using-recursion-and-maths-zio3u | \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) \n\n# Code\n | ujjuengineer | NORMAL | 2024-10-07T00:57:18.502712+00:00 | 2024-10-07T00:57:18.502750+00:00 | 23 | false | \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)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n\n // function for checking prime\n bool isPrime(int n) {\n if(n==1) return false;\n ... | 1 | 0 | ['C++'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | easiest approch you can get (beginner friendly) | easiest-approch-you-can-get-beginner-fri-stoj | Intuition\n\nThe problem involves finding a transformation of a number based on the sum of its prime factors. The idea is to continuously replace the number wit | ishanbagra | NORMAL | 2024-08-04T06:00:05.014828+00:00 | 2024-08-04T06:00:05.014887+00:00 | 6 | false | Intuition\n\nThe problem involves finding a transformation of a number based on the sum of its prime factors. The idea is to continuously replace the number with the sum of its prime factors until the value no longer changes. This essentially reduces the number by breaking it down into smaller prime components and summ... | 1 | 0 | ['Math', 'Number Theory', 'C++'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | C++ || JavaScript || Easy Solution | c-javascript-easy-solution-by-imran32-znba | Complexity\n- Time complexity: O(sqrt(n))\n\n- Space complexity: O(1)\n\n\n# Code\n# C++\n\nclass Solution {\npublic:\n int findAns(int n){\n int div= | Imran32 | NORMAL | 2023-08-17T13:51:22.266306+00:00 | 2023-08-17T13:51:22.266330+00:00 | 335 | false | # Complexity\n- Time complexity: O(sqrt(n))\n\n- Space complexity: O(1)\n\n\n# Code\n# C++\n```\nclass Solution {\npublic:\n int findAns(int n){\n int div=2,ans=0;\n while(n%2==0){\n ans+=2;\n n/=2;\n }\n int res=sqrt(n);\n for(int i=3;i<=res;i+=2){\n ... | 1 | 0 | ['Math', 'Number Theory', 'C++', 'JavaScript'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | simple maths || easy to understand | simple-maths-easy-to-understand-by-aksha-vpil | Code\n\nclass Solution {\npublic:\n int smallestValue(int n) \n {\n while(true)\n {\n int sum = getsum(n);\n\n if( | akshat0610 | NORMAL | 2023-04-18T19:04:41.335046+00:00 | 2023-04-18T19:04:41.335085+00:00 | 213 | false | # Code\n```\nclass Solution {\npublic:\n int smallestValue(int n) \n {\n while(true)\n {\n int sum = getsum(n);\n\n if(sum == n)\n return n;\n\n n= sum;\n } \n return -1;\n }\n int getsum(int n)\n {\n int sum = 0;\n... | 1 | 0 | ['Math', 'Number Theory', 'C++'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | Easy C++ CODE || beats 100% | easy-c-code-beats-100-by-sattvikdwivedi-elpj | 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 | sattvikdwivedi | NORMAL | 2023-01-14T21:29:47.386345+00:00 | 2023-01-14T21:29:47.386375+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)$$ --... | 1 | 0 | ['C++'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | C++ || Beats 80% || Recursion || Prime Factor | c-beats-80-recursion-prime-factor-by-gar-xohf | \n# Code\n\nclass Solution {\npublic:\n /* intution : Recursion\n base case\n if(isPrime(n))\n return n;\n else\n n | garvit14 | NORMAL | 2023-01-08T11:40:52.179498+00:00 | 2023-01-08T11:40:52.179530+00:00 | 133 | false | \n# Code\n```\nclass Solution {\npublic:\n /* intution : Recursion\n base case\n if(isPrime(n))\n return n;\n else\n n tak k prime factor nekal le\n eg 15 - 2,3,5,7,11,13 -> yaha se calculate newN\n */\n bool isPrime(int n){\n for(int i = 2;i * i <= n;i++){... | 1 | 0 | ['Recursion', 'C++'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | [Python3], Recursevily sum primes | python3-recursevily-sum-primes-by-yerkon-55ul | 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 | yerkon | NORMAL | 2023-01-02T09:48:30.553186+00:00 | 2023-01-03T05:51:25.985180+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)$$ --... | 1 | 0 | ['Recursion', 'Python3'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | C++ || EASY TO UNDERSTAND || 💯 | c-easy-to-understand-by-__rushimanurkar-80sz | \nclass Solution {\npublic:\n bool checkPrime(int n){\n if(n<=1)\n return false;\n if(n==2 || n==3)\n return true;\n | __rushiManurkar_ | NORMAL | 2022-12-30T09:51:47.732620+00:00 | 2022-12-30T09:51:47.732662+00:00 | 23 | false | ```\nclass Solution {\npublic:\n bool checkPrime(int n){\n if(n<=1)\n return false;\n if(n==2 || n==3)\n return true;\n if(n%2==0 || n%3==0)\n return false;\n for(int i=5;i*i<=n;i+=6){\n if(n%i==0 || n%(i+2)==0)\n return false;\n ... | 1 | 0 | [] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | Smallest-value-after-replacing-with-sum-of-prime-factors||C++||Solution | smallest-value-after-replacing-with-sum-v3aa1 | Runtime: 3 ms, faster than 74.91% of C++ online submissions for Smallest Value After Replacing With Sum of Prime Factors.\nMemory Usage: 5.9 MB, less than 72.81 | SHIV_PRAKASH_YADAV | NORMAL | 2022-12-26T19:51:42.377488+00:00 | 2022-12-26T19:54:32.640438+00:00 | 33 | false | Runtime: 3 ms, faster than 74.91% of C++ online submissions for Smallest Value After Replacing With Sum of Prime Factors.\nMemory Usage: 5.9 MB, less than 72.81% of C++ online submissions for Smallest Value After Replacing With Sum of Prime Factors.\n```\n\nint prime(int num)\n{\n int x=num;\n int sum=0;\... | 1 | 0 | ['C'] | 1 |
smallest-value-after-replacing-with-sum-of-prime-factors | easiest solution || c++ || easy to understand | easiest-solution-c-easy-to-understand-by-4s47 | 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 | youdontknow001 | NORMAL | 2022-12-25T14:15:48.591903+00:00 | 2022-12-25T14:15:48.591949+00:00 | 66 | 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)$$ --... | 1 | 0 | ['C++'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | C++||ContestSolution||EasyToUnderstand | ccontestsolutioneasytounderstand-by-ravi-62oh | Runtime: 3 ms, faster than 75.04% of C++ online submissions for Smallest Value After Replacing With Sum of Prime Factors.\nMemory Usage: 5.9 MB, less than 95.21 | ravispandey_98670 | NORMAL | 2022-12-25T10:43:12.982333+00:00 | 2022-12-25T10:43:12.982364+00:00 | 507 | false | Runtime: 3 ms, faster than 75.04% of C++ online submissions for Smallest Value After Replacing With Sum of Prime Factors.\nMemory Usage: 5.9 MB, less than 95.21% of C++ online submissions for Smallest Value After Replacing With Sum of Prime Factors.\n\nclass Solution {\npublic:\n \n int primeFactor(int n){\n ... | 1 | 0 | ['Math', 'C'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | EASY C++ | easy-c-by-kalamarham-3kjp | Intuition\n Describe your first thoughts on how to solve this problem. \ncheck prime number at every step from 2 to n -> brute force\n\n# Approach\n Describe yo | kalamarham | NORMAL | 2022-12-25T07:05:32.648800+00:00 | 2022-12-25T07:05:32.648848+00:00 | 100 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\ncheck prime number at every step from 2 to n -> brute force\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\ncheck prime and find prime factors accordingly compxty will be reduced\n// Md Arham kalam Ansari\n# Comple... | 1 | 0 | ['C++'] | 1 |
smallest-value-after-replacing-with-sum-of-prime-factors | Simplest Recursion | simplest-recursion-by-vidhwanshak-bd95 | Intuition\n Describe your first thoughts on how to solve this problem. \nThe idea is very simple. We recursively call factorial function which calculates the su | VIDHWANSHAK | NORMAL | 2022-12-20T04:41:01.947111+00:00 | 2022-12-20T04:41:01.947144+00:00 | 318 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe idea is very simple. We recursively call `factorial` function which calculates the sum of factorial and pass it to the `smallestValue` function.\nThe only problem we will face is when sum of factorial be equal to the number `n` so we... | 1 | 0 | ['Java'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | Exception handling solution java | exception-handling-solution-java-by-pron-j9wh | Intro\nProblem isn`t hard, so only one problem that i had is stackoverflow\n Describe your first thoughts on how to solve this problem. \n\n# Approach\nYeah, yo | pronnik | NORMAL | 2022-12-20T01:02:01.819900+00:00 | 2022-12-20T01:02:01.819943+00:00 | 193 | false | # Intro\nProblem isn`t hard, so only one problem that i had is stackoverflow\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nYeah, you can make it faster by making 1 more check. But stackOverflow helped me alot in my life so i decided to leave it here^_^ss\n<!-- Describe your approac... | 1 | 0 | ['Java'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | Simple Recursive approach | simple-recursive-approach-by-varunkusabi-xq99 | Approach\nWe will calculate the sum of all possible prime factors and compare it with the number of which we are calculating for if sum is less we will recursiv | varunkusabi8 | NORMAL | 2022-12-18T21:02:12.904944+00:00 | 2023-03-26T10:52:30.821200+00:00 | 38 | false | # Approach\nWe will calculate the sum of all possible prime factors and compare it with the number of which we are calculating for if sum is less we will recursively calculate for it or else return it since it breaks condition;\n# Complexity\n- Time complexity:\n- It is recursive in approach\n\n# Code\n```\nclass Solut... | 1 | 0 | ['Recursion', 'C++'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | Clean Code || C++ || O(1) Space | clean-code-c-o1-space-by-arandomguy-74wl | ```\nclass Solution {\npublic:\n \n int smallestValue(int n) {\n int x = n;\n int ans = n;\n \n while(true) {\n in | ARandomGuy | NORMAL | 2022-12-18T19:29:26.028821+00:00 | 2022-12-18T19:33:54.844508+00:00 | 36 | false | ```\nclass Solution {\npublic:\n \n int smallestValue(int n) {\n int x = n;\n int ans = n;\n \n while(true) {\n int check = x; // Storing x in another variable as x will be lost in each iteration\n \n \n int num = x; // Condition variable to... | 1 | 0 | ['C'] | 1 |
smallest-value-after-replacing-with-sum-of-prime-factors | C++ simple solution by help of AI | c-simple-solution-by-help-of-ai-by-obscu-t571 | I gave my solution to ChatGPT and it returned me this solution....\uD83D\uDE0D\uD83D\uDE0D\uD83D\uDE0D\nAlthough it\'s run-time is costly but managed to pass al | obscure_ | NORMAL | 2022-12-18T17:48:46.156095+00:00 | 2022-12-18T17:48:46.156146+00:00 | 300 | false | I gave my solution to ChatGPT and it returned me this solution....\uD83D\uDE0D\uD83D\uDE0D\uD83D\uDE0D\nAlthough it\'s run-time is costly but managed to pass all the test cases.\n\nclass Solution {\npublic:\n const int MAXN = 100005;\n\n int getPrimeFactorSum(int x) {\n // Implement a function for computin... | 1 | 0 | ['C'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | Simple and Efficient C++ Solution | simple-and-efficient-c-solution-by-arko-xxqcq | \ntypedef long long ll;\nclass Solution {\npublic:\n ll f(int n)\n {\n ll s=0;\n ll y=n;\n for(int i=2;i<y;i++)\n {\n | Arko-816 | NORMAL | 2022-12-18T13:19:23.705514+00:00 | 2022-12-18T13:19:23.705815+00:00 | 200 | false | ```\ntypedef long long ll;\nclass Solution {\npublic:\n ll f(int n)\n {\n ll s=0;\n ll y=n;\n for(int i=2;i<y;i++)\n {\n if(isprime(i))\n {\n while(n%i==0)\n {\n n/=i;\n s+=i;\n ... | 1 | 0 | [] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | My Submission || JAVA | my-submission-java-by-pappuraj-815q | \n\n# Code\n\nclass Solution {\n \n \n int cal(int num){\n int out=0;\n for(int i = 2; i< num; i++) {\n while(num%i == 0) {\n | PAPPURAJ | NORMAL | 2022-12-18T11:03:32.626585+00:00 | 2022-12-18T11:03:32.626621+00:00 | 39 | false | \n\n# Code\n```\nclass Solution {\n \n \n int cal(int num){\n int out=0;\n for(int i = 2; i< num; i++) {\n while(num%i == 0) {\n out+=i;\n num = num/i;\n }\n }\n if(num >2) {\n out+=num;\n }\n return out;\n }\n... | 1 | 0 | ['Java'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | SIMPLE PYTHON SOLUTION | simple-python-solution-by-beneath_ocean-yb2k | Intuition\nMy intuition is that if I encounter any prime number in the process then that is the minimum of till now will be the answer or if we come across same | beneath_ocean | NORMAL | 2022-12-18T10:51:52.293547+00:00 | 2022-12-18T10:51:52.293587+00:00 | 442 | false | # Intuition\nMy intuition is that if I encounter any prime number in the process then that is the minimum of till now will be the answer or if we come across same number twice then we will return the minimum value.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity... | 1 | 0 | ['Python3'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | Easy python solution | easy-python-solution-by-harshgajera28-etxm | 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 | HarshGajera28 | NORMAL | 2022-12-18T09:39:52.226339+00:00 | 2022-12-18T09:39:52.226380+00:00 | 328 | 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 ---> 61 ms\n- Space complexity:\n<!-- Add your space complexity here, e.g... | 1 | 0 | ['Python3'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | Easy C++ Code | easy-c-code-by-aishwaryadz-zydz | Code\n\nclass Solution {\npublic:\n bool isprime(int n){\n if (n <= 1)return false;\n for (int i = 2; i < n; i++)\n if (n % i == 0)return false;\ | aishwaryadz | NORMAL | 2022-12-18T06:33:34.524765+00:00 | 2022-12-18T06:33:34.524825+00:00 | 477 | false | # Code\n```\nclass Solution {\npublic:\n bool isprime(int n){\n if (n <= 1)return false;\n for (int i = 2; i < n; i++)\n if (n % i == 0)return false;\n return true;\n}\n void primeFactors(int n,vector<int>&v){\n while (n % 2 == 0){\n v.push_back(2);\n n = n/2;\n }\n for (int i =... | 1 | 0 | ['C++'] | 2 |
smallest-value-after-replacing-with-sum-of-prime-factors | CodeDominar Solution | codedominar-solution-by-codedominar-6qp0 | Code\n\nclass Solution:\n def smallestValue(self, n: int) -> int:\n def find_factors_sum(n):\n sum_ = 0\n for i in range(2,n):\n | codeDominar | NORMAL | 2022-12-18T06:26:30.310094+00:00 | 2022-12-18T06:26:30.310135+00:00 | 61 | false | # Code\n```\nclass Solution:\n def smallestValue(self, n: int) -> int:\n def find_factors_sum(n):\n sum_ = 0\n for i in range(2,n):\n while n%i==0:\n sum_+=i\n n = n//i\n return sum_\n while find_factors_sum(n) and n!... | 1 | 0 | ['Python3'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | ✅ Java || Sieve of Eratosthenes Approach || Highly optimised code | java-sieve-of-eratosthenes-approach-high-2pli | Intuition:\nKeep breaking the number into sum of prime factors. Stop when the number becomes a prime number. Because prime numbers cannot be broken further.\n\n | Suvradippaul | NORMAL | 2022-12-18T05:09:12.520052+00:00 | 2022-12-18T14:05:50.674040+00:00 | 303 | false | **Intuition:**\n*Keep breaking the number into sum of prime factors. Stop when the number becomes a prime number. Because prime numbers cannot be broken further.*\n\n```java\nclass Solution {\n public int smallestValue(int n) {\n fillPrimes(n); // finding all primes upto n by sieve of eratosthenes\n ... | 1 | 0 | ['Java'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | c++ beginer friendly || easy solution||simplified | c-beginer-friendly-easy-solutionsimplifi-ayzi | 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 | madhur013 | NORMAL | 2022-12-18T05:02:16.312329+00:00 | 2022-12-18T05:08:39.872668+00:00 | 137 | 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)$$ --... | 1 | 0 | ['Math', 'Recursion', 'C++'] | 1 |
smallest-value-after-replacing-with-sum-of-prime-factors | C++, Fully explained 5 line code | c-fully-explained-5-line-code-by-freakin-q75x | Intuition\nFirst thought is to solve with the help of bool prime and so on, but recursively we don\'t need to find the prime. \n# Approach\n Describe your appro | freakinrkb | NORMAL | 2022-12-18T04:34:20.519808+00:00 | 2022-12-18T04:34:20.519841+00:00 | 34 | false | # Intuition\nFirst thought is to solve with the help of bool prime and so on, but recursively we don\'t need to find the prime. \n# Approach\n<!-- Describe your approach to solving the problem. -->\nFirst calculate all the prime factor of the number, then sum all of it.\nThen u recursively pass the sum to our function,... | 1 | 0 | ['C++'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | JavaScript easy | javascript-easy-by-gamboadd27-db3g | 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 | GamboaDd27 | NORMAL | 2022-12-18T04:25:17.723452+00:00 | 2022-12-18T04:25:17.723492+00:00 | 145 | 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)$$ --... | 1 | 0 | ['JavaScript'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | JAVA | Simplest and Shortest ✅ | java-simplest-and-shortest-by-sourin_bru-tj2s | Please Upvote :D\njava []\nclass Solution {\n public int smallestValue(int n) {\n int ori = n, ans = n;\n int k = 2, sum = 0;\n\n while | sourin_bruh | NORMAL | 2022-12-18T04:19:59.284884+00:00 | 2022-12-18T04:19:59.284927+00:00 | 79 | false | # Please Upvote :D\n``` java []\nclass Solution {\n public int smallestValue(int n) {\n int ori = n, ans = n;\n int k = 2, sum = 0;\n\n while (true) {\n if (n % k == 0) {\n sum += k;\n n /= k;\n }\n else k++;\n\n if (n == ... | 1 | 0 | ['Java'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | simple C++ approach | simple-c-approach-by-sudhanwaofficial-4mr7 | 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 | sudhanwaofficial | NORMAL | 2022-12-18T04:18:56.681385+00:00 | 2022-12-18T04:18:56.681427+00:00 | 316 | 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)$$ --... | 1 | 0 | ['C++'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | Simplest Easiest Solution C++ | simplest-easiest-solution-c-by-vivekkuma-vtq4 | \n int smallestValue(int n)\n {\n\n int sum = 0;\n bool flag = false;\n int i = 2;\n while (i <= n / 2)\n {\n | Vivekkumarmishra | NORMAL | 2022-12-18T04:16:41.435729+00:00 | 2022-12-18T04:16:41.435758+00:00 | 42 | false | \n int smallestValue(int n)\n {\n\n int sum = 0;\n bool flag = false;\n int i = 2;\n while (i <= n / 2)\n {\n if (n % i == 0)\n {\n sum += i;\n flag = true;\n n /= i;\n continue;\n }\n ... | 1 | 0 | ['Math', 'Recursion', 'C'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | Java | Easy to understand solution + Comments | 5 ms solution | java-easy-to-understand-solution-comment-jqk7 | \nclass Solution {\n public int smallestValue(int n) {\n while(true){\n int sum = sumOfPrimeFactors(n);\n if(sum == n) break; // | theGDM | NORMAL | 2022-12-18T04:14:17.827543+00:00 | 2022-12-18T04:15:53.304761+00:00 | 194 | false | ```\nclass Solution {\n public int smallestValue(int n) {\n while(true){\n int sum = sumOfPrimeFactors(n);\n if(sum == n) break; //if sum and n both becomes equal than break the loop\n n = sum; //update n with sum of its prime factors\n }\n \n return n;\n ... | 1 | 0 | ['Java'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | Easy C++ solution | easy-c-solution-by-dheeruthakur-1lm3 | 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 | DheeruThakur | NORMAL | 2022-12-18T04:10:41.850269+00:00 | 2022-12-18T04:10:41.850310+00:00 | 261 | 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)$$ --... | 1 | 0 | ['C++'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | [C++] Beats 92% || Prime Factorization | c-beats-92-prime-factorization-by-amanra-q693 | Code\n\nclass Solution {\npublic:\n int primeFactors(int n)\n {\n int sum = 0;\n\xA0\xA0\xA0\xA0 int count = 2;\n\xA0\xA0\xA0\xA0 while(n>1)\ | amanrathodpro | NORMAL | 2022-12-18T04:09:27.946888+00:00 | 2022-12-18T04:09:27.946921+00:00 | 54 | false | # Code\n```\nclass Solution {\npublic:\n int primeFactors(int n)\n {\n int sum = 0;\n\xA0\xA0\xA0\xA0 int count = 2;\n\xA0\xA0\xA0\xA0 while(n>1)\n\xA0\xA0\xA0 \xA0 {\n\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0 if(n % count == 0){\n\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0 sum += count;\n\xA0\xA0\xA0\xA0\xA... | 1 | 0 | ['C++'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | Python | python-by-diwakar_4-iarv | Complexity\n- Time complexity: This Approach takes O(log n) for all composite numbers and O(n) otherwise.\n- Space complexity: O(n)\n\n# Code\n\nclass Solution: | diwakar_4 | NORMAL | 2022-12-18T04:06:08.302336+00:00 | 2022-12-18T04:06:08.302372+00:00 | 101 | false | # Complexity\n- Time complexity: This Approach takes O(log n) for all composite numbers and O(n) otherwise.\n- Space complexity: O(n)\n\n# Code\n```\nclass Solution:\n def smallestValue(self, n: int) -> int:\n def prime(n):\n prev_n = n\n s = 0\n c = 2\n while(n > 1... | 1 | 0 | ['Python3'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | Java || Brute force | java-brute-force-by-henryzhc-wa0s | \nclass Solution {\n public int smallestValue(int n) {\n int check = n;\n while (isPrime(check) != 1) {\n int curr = getValue(check) | henryzhc | NORMAL | 2022-12-18T04:05:23.953417+00:00 | 2022-12-18T04:05:23.953460+00:00 | 73 | false | ```\nclass Solution {\n public int smallestValue(int n) {\n int check = n;\n while (isPrime(check) != 1) {\n int curr = getValue(check);\n if (curr == check) {\n return check;\n }\n check = curr;\n }\n return check;\n }\n pu... | 1 | 0 | ['Java'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | Easy Java Solution | easy-java-solution-by-sgsumitgupta17-6r6f | \n# Code\n\nclass Solution {\n public int smallestValue(int n) {\n int sum = 0;\n int ans=Integer.MAX_VALUE;\n HashSet<Integer> hs=new H | sgsumitgupta17 | NORMAL | 2022-12-18T04:02:36.879460+00:00 | 2022-12-18T04:50:38.398590+00:00 | 190 | false | \n# Code\n```\nclass Solution {\n public int smallestValue(int n) {\n int sum = 0;\n int ans=Integer.MAX_VALUE;\n HashSet<Integer> hs=new HashSet<>();\n while(!hs.contains(n)){\n hs.add(n);\n // check from 2 to n whenever n is the factor of c add it to the sum\n ... | 1 | 0 | ['Java'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | Easy Understandable Solution [c++] | easy-understandable-solution-c-by-algoar-bi6a | Code\n\nclass Solution {\npublic:\n int smallestValue(int n) {\n int k=2;\n int sum=0;\n int maxi=n;\n int mini=n;\n while | AlgoArtisan | NORMAL | 2022-12-18T04:01:44.064555+00:00 | 2022-12-18T04:05:57.230939+00:00 | 434 | false | # Code\n```\nclass Solution {\npublic:\n int smallestValue(int n) {\n int k=2;\n int sum=0;\n int maxi=n;\n int mini=n;\n while(true){\n if(n%k==0){\n sum+=k;\n n=n/k;\n }\n else k++;\n if(n==1){\n ... | 1 | 0 | ['C++'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | [Java] Brute force with math | java-brute-force-with-math-by-0x4c0de-mx5d | Intuition\n Describe your first thoughts on how to solve this problem. \nDecrease n with brute force.\n\n# Approach\n Describe your approach to solving the prob | 0x4c0de | NORMAL | 2022-12-18T04:01:12.263363+00:00 | 2022-12-18T04:59:47.290176+00:00 | 456 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nDecrease n with brute force.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nWatch out the $$4 = 2 * 2$$, decrease n with prime sum.\n\nFor some one want to find the math: [Fundamental theorem of arithmetic](https:... | 1 | 0 | ['Math', 'Java'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | Easy Recursive Soln. | easy-recursive-soln-by-realyogendra-n8ka | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | realyogendra | NORMAL | 2025-04-07T16:53:32.446291+00:00 | 2025-04-07T16:53:32.446291+00:00 | 1 | 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 | ['C++'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | C++ || Simple Prime Factorization | c-simple-prime-factorization-by-sawarn24-ldil | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | sawarn2411 | NORMAL | 2025-04-06T02:21:58.461532+00:00 | 2025-04-06T02:21:58.461532+00:00 | 2 | 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 | ['C++'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | Floyd's fast and slow approach in Java | floyds-fast-and-slow-approach-in-java-by-g1vz | IntuitionI saw that the least number is always reached in every case.ApproachI used prime factorisation and Floyd's Two pointer approach to efficiently calculat | 22blc1217 | NORMAL | 2025-03-23T15:17:57.208408+00:00 | 2025-03-23T15:17:57.208408+00:00 | 2 | false | # Intuition
I saw that the least number is always reached in every case.
# Approach
I used prime factorisation and Floyd's Two pointer approach to efficiently calculate the stopping point.
# Complexity
- Time complexity:O(sqrt(n)*log(n)) because it takes log(n) time to calculate prime factors and sqrt(n) time to itera... | 0 | 0 | ['Java'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | Easy solution | easy-solution-by-koushik_55_koushik-gtmx | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | Koushik_55_Koushik | NORMAL | 2025-03-21T15:33:51.568406+00:00 | 2025-03-21T15:33:51.568406+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 |
smallest-value-after-replacing-with-sum-of-prime-factors | Best c++ solution Beats 100%. | best-c-solution-beats-100-by-harsh21ngh-4002 | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | harsh21ngh | NORMAL | 2025-03-15T13:13:38.025003+00:00 | 2025-03-15T13:13:38.025003+00:00 | 1 | 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 | ['C++'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | Best c++ solution Beats 100%. | best-c-solution-beats-100-by-harsh21ngh-fqd7 | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | harsh21ngh | NORMAL | 2025-03-15T13:13:35.540600+00:00 | 2025-03-15T13:13:35.540600+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 | ['C++'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | C++ easy solution 🏆😎💥🥇 | c-easy-solution-by-rishikanaujiya9598-tpvv | Code | rishikanaujiya9598 | NORMAL | 2025-03-11T06:14:38.566517+00:00 | 2025-03-11T06:14:38.566517+00:00 | 2 | false |
# Code
```cpp []
class Solution {
public:
// Function to compute the sum of prime factors of n
int factorSum(int n) {
int ans = 0;
int divisor = 2;
while (n > 1) {
if (n % divisor == 0) {
ans += divisor;
n /= divisor;
} else {
... | 0 | 0 | ['C++'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | C++ || Easy way to find smallest value | c-easy-way-to-find-smallest-value-by-cem-4qr9 | IntuitionWe need to find the smallest value, and this smallest value will always be a prime number.ApproachIn a "while" loop, we try to find the divisors of our | cemgate | NORMAL | 2025-03-08T21:13:31.692774+00:00 | 2025-03-08T21:13:31.692774+00:00 | 6 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
We need to find the smallest value, and this smallest value will always be a prime number.
# Approach
<!-- Describe your approach to solving the problem. -->
In a "while" loop, we try to find the divisors of our number and add them to prime... | 0 | 0 | ['C++'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | Simple C++ Solution 🤯🤯🤯 | simple-c-solution-by-harsh_suthar-uai2 | 🧠 IntuitionWe start by making a function that checks whether a number is divisible by a divisor. If it is, we add the divisor to the sum (as it's a factor) and | Harsh_Suthar | NORMAL | 2025-03-07T09:25:56.028828+00:00 | 2025-03-07T09:25:56.028828+00:00 | 25 | false | # 🧠 Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
We start by making a function that checks whether a number is divisible by a divisor. If it is, we add the divisor to the sum (as it's a factor) and divide the number by the same divisor. 🔢
We continue this process until the numbe... | 0 | 0 | ['C++'] | 1 |
smallest-value-after-replacing-with-sum-of-prime-factors | Math | Simple solution with 100% beaten | math-simple-solution-with-100-beaten-by-dqvo3 | IntuitionThe problem is about repeatedly replacing a number n with the sum of its prime factors until it becomes stable (meaning the sum of its prime factors eq | Takaaki_Morofushi | NORMAL | 2025-03-06T02:25:06.334552+00:00 | 2025-03-06T02:25:06.334552+00:00 | 5 | false | # Intuition
The problem is about repeatedly replacing a number `n` with the sum of its prime factors until it becomes stable (meaning the sum of its prime factors equals itself).
The intuition is that prime factorization helps us break the number into its smallest building blocks, and summing them gradually reduces t... | 0 | 0 | ['C++'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | for beginners | for-beginners-by-abdulraoofkp-rbxl | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | abdulraoofkp | NORMAL | 2025-02-20T17:46:29.482950+00:00 | 2025-02-20T17:46:29.482950+00:00 | 4 | 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 | ['JavaScript'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | for beginners | for-beginners-by-abdulraoofkp-0sj7 | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | abdulraoofkp | NORMAL | 2025-02-20T17:46:26.235537+00:00 | 2025-02-20T17:46:26.235537+00:00 | 4 | 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 | ['JavaScript'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | ~20 | 20-by-lerfich-0yrb | IntuitionApproachComplexity
Time complexity:
O(log_p(sqrt(n))), p - most common factor except 2
Space complexity:
O(log2(n)) - n - max pow of 2, if all the f | lerfich | NORMAL | 2025-02-14T08:06:32.118941+00:00 | 2025-02-14T08:06:32.118941+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:
O(log_p(sqrt(n))), p - most common factor except 2
- Space complexity:
O(log2(n)) - n - max pow of 2, if all the factors are '2'
# Code
`... | 0 | 0 | ['TypeScript'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | 2507. Smallest Value After Replacing With Sum of Prime Factors | 2507-smallest-value-after-replacing-with-h2cf | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | G8xd0QPqTy | NORMAL | 2025-01-19T00:47:54.642164+00:00 | 2025-01-19T00:47:54.642164+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 | ['C++'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | Recursively Easy to Understand | recursively-easy-to-understand-by-yash08-skqa | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | yash080105 | NORMAL | 2025-01-07T12:15:54.598486+00:00 | 2025-01-07T12:15:54.598486+00:00 | 2 | 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 | ['Math', 'Simulation', 'Number Theory', 'C++'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | Beats 100% in C++ | beats-100-in-c-by-nishantjaiswal0001-s69w | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | nishantjaiswal0001 | NORMAL | 2025-01-06T09:10:52.070160+00:00 | 2025-01-06T09:10:52.070160+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 | ['C++'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | Simple Solution | simple-solution-by-ya1125-oj1m | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | Yagnik1125 | NORMAL | 2025-01-03T13:37:54.041932+00:00 | 2025-01-03T13:37:54.041932+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)$$ -->0(nlogn)
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->0(... | 0 | 0 | ['C++'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | c++ solution 100% beats rate | c-solution-100-beats-rate-by-9031543103-d9i8 | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | 9031543103 | NORMAL | 2025-01-02T17:16:44.738646+00:00 | 2025-01-02T17:16:44.738646+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 | ['C++'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | easy solution | easy-solution-by-kodzimk-h3z8 | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | Kodzimk | NORMAL | 2025-01-01T15:02:02.147322+00:00 | 2025-01-01T15:02:02.147322+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 | ['C++'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | Swift Solution | swift-solution-by-khaledkamal-9f7h | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | khaledkamal | NORMAL | 2024-12-30T23:34:54.643173+00:00 | 2024-12-30T23:34:54.643173+00:00 | 1 | 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 | ['Swift'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | Smallest Value After Replacing With Sum Of Prime Factors | smallest-value-after-replacing-with-sum-glxwq | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | ShaksRA | NORMAL | 2024-12-13T20:05:26.774274+00:00 | 2024-12-13T20:05:26.774274+00:00 | 10 | 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 |
smallest-value-after-replacing-with-sum-of-prime-factors | Simple to understand | simple-to-understand-by-pitcherpunchst-bjtc | null | pitcherpunchst | NORMAL | 2024-12-11T10:58:12.680566+00:00 | 2024-12-11T10:58:12.680566+00:00 | 2 | false | # Intuition\nbrute force\n# Approach\ncreate a function to check if a number is a prime, and a function to sum the prime factors\ndeal with exception of n=4\nrun a while loop as long as the number doesnt become prime, the sum of prime factors of a prime number is the number itself;\n\n# Code\n```cpp []\nclass Solution ... | 0 | 0 | ['C++'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | Smallest Value After Repeated Prime Factor Sum Replacement | smallest-value-after-repeated-prime-fact-4rvg | Intuition\nThe problem involves continuously replacing a number n with the sum of its prime factors until n becomes a prime number. The intuition behind this ap | user9375Du | NORMAL | 2024-12-01T05:20:58.394741+00:00 | 2024-12-01T05:20:58.394781+00:00 | 3 | false | ## Intuition\nThe problem involves continuously replacing a number `n` with the sum of its prime factors until `n` becomes a prime number. The intuition behind this approach is that by summing the prime factors, we can iteratively reduce the number until it converges to a prime.\n\n## Approach\n1. **Prime Factor Sum Ca... | 0 | 0 | ['Python3'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | O(sqrt(n) * P(n)) C++ solution [Beats 100% of solutions] | osqrtn-pn-c-solution-beats-100-of-soluti-p6yi | Intuition\nFor any prime number p, its prime factors will be \{1,p\}. Ignoring the trivial factor of 1, the sum of its prime factors will always be equal to p i | Sekqies | NORMAL | 2024-11-27T02:10:39.848625+00:00 | 2024-11-27T02:10:39.848653+00:00 | 0 | false | # Intuition\nFor any prime number $$p$$, its prime factors will be $$\\{1,p\\}$$. Ignoring the trivial factor of $$1$$, the sum of its prime factors will always be equal to $$p$$ itself. Therefore, we can check whether a given number $$n$$ is prime (and therefore satisfies the question) by checking whether $$n=sum(pri... | 0 | 0 | ['C++'] | 0 |
smallest-value-after-replacing-with-sum-of-prime-factors | C++ Solution || 100% beat time || Bruteforce | c-solution-100-beat-time-bruteforce-by-v-mqlf | Intuition\n Describe your first thoughts on how to solve this problem. \nSimple Bruteforce implementation.\n\n# Approach\n Describe your approach to solving the | vishalmaurya59 | NORMAL | 2024-11-14T15:05:17.145321+00:00 | 2024-11-14T15:05:17.145377+00:00 | 0 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nSimple Bruteforce implementation.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nApplying bruteforce approach. Continuosly finding the sum of the prime factors and checking if the sum is equal to the same value of... | 0 | 0 | ['C++'] | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.