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
maximize-happiness-of-selected-children
Easy to Understand || brute force || solution without using greedy algo
easy-to-understand-brute-force-solution-sgfxk
\n\nclass Solution {\npublic:\n long long maximumHappinessSum(vector<int>& happiness, int k) {\n sort(happiness.begin(),happiness.end()); // sorting s
divyanxsh
NORMAL
2024-05-13T14:39:48.961585+00:00
2024-05-13T14:40:14.661565+00:00
4
false
\n```\nclass Solution {\npublic:\n long long maximumHappinessSum(vector<int>& happiness, int k) {\n sort(happiness.begin(),happiness.end()); // sorting so that the happiest child is at the last index\n long long int ans= 0;\n int count=0;\n int size= happiness.size();\n while(count...
1
0
['C++']
0
maximize-happiness-of-selected-children
✅ C#, Beginner Friendly, Beats %94 ✅
c-beginner-friendly-beats-94-by-msoykann-0m43
Intuition\n Describe your first thoughts on how to solve this problem. \nWe simply need to find n highest values inside the given array.\n\n# Approach\n Describ
MSoykann
NORMAL
2024-05-10T13:46:14.806025+00:00
2024-05-17T10:28:43.046185+00:00
15
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nWe simply need to find n highest values inside the given array.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nFirst we sort the happiness list. In order to maximize our happiness score we start picking values fro...
1
0
['Sorting', 'C#']
0
maximize-happiness-of-selected-children
Another day another 1 liner
another-day-another-1-liner-by-santoshvi-mwi2
Intuition\n Describe your first thoughts on how to solve this problem. \n## Greeeeeeedyyyy\n\n\n# Approach\n Describe your approach to solving the problem. \n-
santoshvijapure
NORMAL
2024-05-09T18:37:59.235465+00:00
2024-05-09T18:37:59.235497+00:00
14
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n## Greeeeeeedyyyy\n![Greeeeeeedyyyy](https://assets.leetcode.com/users/images/1ca0da4b-5bbd-43bc-9115-2290b187bb5d_1715279673.645965.gif)\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n- sort them in decreasing or...
1
0
['Greedy', 'Sorting', 'JavaScript']
1
maximize-happiness-of-selected-children
Beats 99% | O(n + k*logk) runtime and O(1) space
beats-99-on-klogk-runtime-and-o1-space-b-606q
Intuition\nSelect the children with the max happiness to maximize the sum of the happiness.\n\n# Approach\nAvoid sorting of the very happy children with happine
sanjok
NORMAL
2024-05-09T18:37:40.920431+00:00
2024-05-09T19:10:24.329056+00:00
17
false
# Intuition\nSelect the children with the max happiness to maximize the sum of the happiness.\n\n# Approach\nAvoid sorting of the very happy children with $$happiness > K$$.\nAvoid sorting of the unhappy children. All of them will be zeroed.\n\n# Complexity\n- Time complexity: $$O(n + k*logk)$$ on average\n<!-- Add you...
1
0
['Heap (Priority Queue)', 'C++']
0
maximize-happiness-of-selected-children
Simple JAVA Solution || Sorting and turns || Greedy
simple-java-solution-sorting-and-turns-g-zqvv
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
saad_hussain_
NORMAL
2024-05-09T18:20:34.546601+00:00
2024-05-09T18:20:34.546650+00:00
1
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(NlogN)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(1)\n<!-- Add your space complexity here, e.g....
1
0
['Greedy', 'Java']
0
maximize-happiness-of-selected-children
Maximizing Happiness Sum: Selecting Children in Turns
maximizing-happiness-sum-selecting-child-sjdn
Intuition\nTo maximize the sum of happiness values while selecting children, we should prioritize selecting children with higher initial happiness values.\n Des
janhvipandey
NORMAL
2024-05-09T17:59:59.843646+00:00
2024-05-09T17:59:59.843677+00:00
0
false
# Intuition\nTo maximize the sum of happiness values while selecting children, we should prioritize selecting children with higher initial happiness values.\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n1. Sort the array of happiness values in non-decreasing order.\n2. Iterate thro...
1
0
['C++']
0
maximize-happiness-of-selected-children
Easiest approach with sorting
easiest-approach-with-sorting-by-zhiyang-epav
Intuition\n Describe your first thoughts on how to solve this problem. \nGreedily select the first k largest element and/or stop until you see the first 0.\n\n#
ZhiYangLim
NORMAL
2024-05-09T17:47:07.068441+00:00
2024-05-09T18:07:17.559863+00:00
5
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nGreedily select the first $$k$$ largest element and/or stop until you see the first $$0$$.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. sort `happiness` in descending order\n2. initialize `max=0` to keep trac...
1
0
['Array', 'Greedy', 'Sorting', 'Python3']
1
maximize-happiness-of-selected-children
Swift solution
swift-solution-by-azm819-sp8x
Complexity\n- Time complexity: O(n * log(n))\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(n)\n Add your space complexity here, e.g. O(n)
azm819
NORMAL
2024-05-09T17:27:14.800070+00:00
2024-05-09T17:27:14.800104+00:00
9
false
# Complexity\n- Time complexity: $$O(n * log(n))$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(n)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n func maximumHappinessSum(_ happiness: [Int], _ k: Int) -> Int {\n let hapiness = ...
1
0
['Array', 'Greedy', 'Swift', 'Sorting']
0
maximize-happiness-of-selected-children
Easy and Efficient Approach
easy-and-efficient-approach-by-vedantdap-mc2z
\n\n# Approach\nWe first sort the happiness vector in descending order\nand then consider the elements that give maximum happiness value.\n\n# Complexity\n- Tim
vedantdapolikar18
NORMAL
2024-05-09T16:54:49.556355+00:00
2024-05-09T16:54:49.556387+00:00
8
false
\n\n# Approach\nWe first sort the happiness vector in descending order\nand then consider the elements that give maximum happiness value.\n\n# Complexity\n- Time complexity:\n$$O(nlogn)$$\n\n- Space complexity:\n$$O(1)$$\n\n# Code\n```\nclass Solution {\npublic:\n long long maximumHappinessSum(vector<int>& happiness...
1
0
['C++']
0
find-the-maximum-factor-score-of-array
O(N^2) and O(N) solutions explained.
on2-and-on-solutions-explained-by-stomac-6qnk
Intuition\nPick an index to eliminate (-1 for none) and keep track of best score. In the inner loop d is the current gcd, m is the current lcm. Note that: gcd(0
stomachion
NORMAL
2024-10-27T04:36:42.544604+00:00
2024-10-27T05:30:12.972247+00:00
1,655
false
# Intuition\nPick an index to eliminate (-1 for none) and keep track of best score. In the inner loop `d` is the current **gcd**, `m` is the current **lcm**. Note that: `gcd(0, x) = x` and `lcm(1, x) = x`.\n\nSince N is small (up to 100) the brute force $$O(N^2)$$ solution is very fast. For larger values of N (up to $$...
16
0
['Python3']
2
find-the-maximum-factor-score-of-array
C# Short and simple
c-short-and-simple-by-connectedpuddle-g0c7
Intuition\n\nCheck all cases of which number if any is excluded. Compute the factor score in each case.\n\nexclude = -1 means no number is excluded.\n\nlcm is i
ConnectedPuddle
NORMAL
2024-10-27T05:08:54.675470+00:00
2024-10-27T05:08:54.675498+00:00
701
false
# Intuition\n\nCheck all cases of which number if any is excluded. Compute the factor score in each case.\n\n`exclude = -1` means no number is excluded.\n\n`lcm` is initialised to 1 because $LCM(1, x) = x$ for all $x$\n\n`gcd` is initialised to 0 because $GCD(0, x) = x$ for all $x$\n\n\n# Complexity\n- Time complexity:...
14
0
['Number Theory', 'C#']
1
find-the-maximum-factor-score-of-array
Python3 || Two eight-line versions || T/S: 99% / 89%
python3-two-eight-line-versions-ts-99-89-mx9u
\n### Brute Force with an optimization version:\nHere\'s the intuition:\n- The problem\'s constraints allow for acceptable O(N^2) solutions.\n\n- The constraint
Spaulding_
NORMAL
2024-10-27T17:22:30.246934+00:00
2024-10-29T20:05:37.598350+00:00
466
false
\n### Brute Force with an optimization version:\nHere\'s the intuition:\n- The problem\'s constraints allow for acceptable *O*(*N*^2) solutions.\n\n- The constraints also permit significant optimization in using *Counter* to filter the elements of `nums` so that we only test the *unique* elements of `nums`.\n\n```pytho...
13
1
['Python3']
2
find-the-maximum-factor-score-of-array
Max Score with Brute Force ✅🔥: GCD and LCM Solutions
max-score-with-brute-force-gcd-and-lcm-s-iw2u
Approach\n\nJUST FINDING ALL POSSIBLE SOLUTION \n\n# Complexity\n- Time complexity:\n Add your time complexity here, e.g. O(n) \n\n- Space complexity:\n Add you
ankit_kumar12345
NORMAL
2024-10-27T04:03:38.990401+00:00
2024-10-27T12:38:41.592690+00:00
3,622
false
# Approach\n\nJUST FINDING ALL POSSIBLE SOLUTION \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 []\n#include <vector>\n#include <algorithm>\n#include <numeric>\n\nclass Solution ...
10
2
['C++', 'Java', 'Python3', 'JavaScript']
4
find-the-maximum-factor-score-of-array
🥁EASY SOLUTION EXPLAINED
easy-solution-explained-by-ramitgangwar-jt0s
\n\n# \uD83D\uDC93**_PLEASE CONSIDER UPVOTING_**\uD83D\uDC93\n\n \n\n\n\n# \u2B50 Intuition\nThe goal is to maximize the "factor score," defined as the product
ramitgangwar
NORMAL
2024-10-28T06:22:33.504570+00:00
2024-10-28T06:22:33.504607+00:00
248
false
<div align="center">\n\n# \uD83D\uDC93**_PLEASE CONSIDER UPVOTING_**\uD83D\uDC93\n\n</div>\n\n***\n\n# \u2B50 Intuition\nThe goal is to maximize the "factor score," defined as the product of the array\'s GCD and LCM, after potentially removing one element. Calculating the factor score for different subsets of the array...
6
0
['Math', 'Java']
0
find-the-maximum-factor-score-of-array
Brute Force + Prefix and Suffix Array
brute-force-prefix-and-suffix-array-by-z-m3g7
Intuition\n Describe your first thoughts on how to solve this problem. \nSince we have the property that gcd(a,b,c) = gcd (gcd(a,b),c), and same for lcm, we can
ZiwenLiu35
NORMAL
2024-10-27T05:54:52.307062+00:00
2024-10-27T05:54:52.307088+00:00
596
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nSince we have the property that gcd(a,b,c) = gcd (gcd(a,b),c), and same for lcm, we can build prefix and suffix gcd and lcm array to store these value beforehand.\n# Approach\n<!-- Describe your approach to solving the problem. -->\nloop ...
6
0
['Java']
2
find-the-maximum-factor-score-of-array
Java Easy and Clearn Solution ( Explained )
java-easy-and-clearn-solution-explained-yvt7q
Solution\njava []\nclass Solution {\n public long gcd(long a, long b) {\n while(b!=0){\n long temp =b;\n b = a%b;\n a
moazmar
NORMAL
2024-11-01T21:53:57.249130+00:00
2024-11-01T21:53:57.249180+00:00
306
false
# Solution\n```java []\nclass Solution {\n public long gcd(long a, long b) {\n while(b!=0){\n long temp =b;\n b = a%b;\n a = temp;\n }\n return a;\n }\n\n public long lcm(long a, long b) {\n return a*b / gcd(a,b);\n }\n\n public long gcdOfArray...
5
0
['Java']
1
find-the-maximum-factor-score-of-array
Calculate Prefix and Suffix for both lcm and gcd
calculate-prefix-and-suffix-for-both-lcm-qi7y
Intuition\nWe can calculate prefix and suffix arrays for gcd and lcm as they\'re both associative.\n\n# Approach\n- For array size n \n - if n = 0 return 0 as
sriharivishnu
NORMAL
2024-10-27T06:28:35.946558+00:00
2024-10-27T06:28:35.946588+00:00
728
false
# Intuition\nWe can calculate prefix and suffix arrays for gcd and lcm as they\'re both associative.\n\n# Approach\n- For array size $$n$$ \n - if $$n = 0$$ return $$0$$ as mentioned in the problem\n - Else if $$n = 1$$ return $$nums[0] * nums[0]$$ as $$nums[0]$$ as lcm and gcd of a number is itself\n - Else, procee...
5
0
['C++']
1
find-the-maximum-factor-score-of-array
"Medium"? Ridiculous. (Python, 5 lines)
medium-ridiculous-python-5-lines-by-stef-2cwh
It\'s an "Easy" problem.\n\n def maxScore(self, nums: List[int]) -> int:\n return max(\n lcm(a) * gcd(a)\n for i in range(len(nu
stefanpochmann
NORMAL
2024-10-28T20:41:08.703062+00:00
2024-10-28T20:50:42.603091+00:00
127
false
It\'s an "Easy" problem.\n\n def maxScore(self, nums: List[int]) -> int:\n return max(\n lcm(*a) * gcd(*a)\n for i in range(len(nums) + 1)\n for a in [nums[:i] + nums[i+1:]]\n )
4
0
[]
0
find-the-maximum-factor-score-of-array
Easy Approach with proper Explanation.
easy-approach-with-proper-explanation-by-7vq3
Intuition\nWhen tackling the problem of finding the maximum factor score of an integer array after potentially removing one element, my first thought was to lev
siddhuuse
NORMAL
2024-10-27T04:26:49.240733+00:00
2024-10-27T04:26:49.240764+00:00
392
false
# Intuition\nWhen tackling the problem of finding the maximum factor score of an integer array after potentially removing one element, my first thought was to leverage the properties of GCD (Greatest Common Divisor) and LCM (Least Common Multiple). The factor score is defined as the product of the GCD and LCM of the ar...
4
0
['Math', 'Greedy', 'Python3']
0
find-the-maximum-factor-score-of-array
Easy and Fast Cpp solution
easy-and-fast-cpp-solution-by-manishbhar-ekbu
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n1.Calculate the total GCD of the entire array using a helper function.\n2
Manishbhartiya07
NORMAL
2024-10-27T04:04:01.435022+00:00
2024-10-27T04:04:01.435043+00:00
1,643
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n1.Calculate the total GCD of the entire array using a helper function.\n2.Calculate the total LCM of the entire array using another helper function.\n3.Compute the initial factor score using the total GCD and total LCM.\n4.L...
3
0
['C++']
1
find-the-maximum-factor-score-of-array
❓What if constrains were (1 <= nums.length <= 10^5)❓
what-if-constrains-were-1-numslength-105-tfha
\n\n### Approach\n1. Calculate Prefix and Suffix GCD/LCM Arrays:\n - We need two arrays for each of GCD and LCM:\n - prefixGCD and suffixGCD: Store the GC
Ajay_Prabhu
NORMAL
2024-11-01T06:52:50.322994+00:00
2024-11-01T06:52:50.323022+00:00
40
false
\n\n### Approach\n1. **Calculate Prefix and Suffix GCD/LCM Arrays**:\n - We need two arrays for each of GCD and LCM:\n - `prefixGCD` and `suffixGCD`: Store the GCD of elements from the start up to each index, and from each index to the end.\n - `prefixLCM` and `suffixLCM`: Store the LCM of elements from the s...
2
0
['Array', 'Math', 'Number Theory', 'Prefix Sum', 'Java']
2
find-the-maximum-factor-score-of-array
Easy to understand c++ soln with separate function for each task. Beats 100%.
easy-to-understand-c-soln-with-separate-zr9s7
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\nCalculating lcm and gcd for nums array and then trying all possible array
Samarth1512
NORMAL
2024-10-27T09:31:09.835819+00:00
2024-10-27T09:31:09.835842+00:00
438
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nCalculating lcm and gcd for nums array and then trying all possible arrays by removing one element from nums and calculating product of gcd and lcm for each of them and storing the maximum of all.\n\n# Complexity\n- Time co...
2
0
['Array', 'C++']
0
find-the-maximum-factor-score-of-array
Beat 100% , TC = O(n log(min(a, b))) , SC = O(n).
beat-100-tc-on-logmina-b-sc-on-by-expon2-m51l
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
expon23_9
NORMAL
2024-10-27T07:02:16.237043+00:00
2024-10-27T07:02:16.237098+00:00
276
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)$$ --...
2
0
['C++']
1
find-the-maximum-factor-score-of-array
Cpp | Beats 100 %
cpp-beats-100-by-rtik-4d76
Intuition\n Describe your first thoughts on how to solve this problem. \nGreedy\n# Approach\nCreate left and right array for gcd and lcm \n Describe your approa
rtik
NORMAL
2024-10-27T05:47:28.734902+00:00
2024-10-27T05:47:28.734934+00:00
156
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nGreedy\n# Approach\nCreate left and right array for gcd and lcm \n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity...
2
0
['C++']
1
find-the-maximum-factor-score-of-array
Simple Easy Java Solution
simple-easy-java-solution-by-shree_govin-wja6
Code\njava []\nclass Solution {\n private int gcd(int a, int b) {\n if (b == 0) {\n return a;\n }\n return gcd(b, a % b);\n
Shree_Govind_Jee
NORMAL
2024-10-27T05:00:20.110709+00:00
2024-10-27T05:00:20.110748+00:00
462
false
# Code\n```java []\nclass Solution {\n private int gcd(int a, int b) {\n if (b == 0) {\n return a;\n }\n return gcd(b, a % b);\n }\n\n private long gcd(long a, int b) {\n if (b == 0) {\n return a;\n }\n return gcd(b, (int) (a % b));\n }\n\n ...
2
0
['Java']
0
find-the-maximum-factor-score-of-array
Beats 100%
beats-100-by-mainframekuznetsov-bbvh
Intuition\n Describe your first thoughts on how to solve this problem. \nFirst calculate the product of GCDLCM of the whole array then calculate all other possi
MainFrameKuznetSov
NORMAL
2024-10-27T04:17:47.233150+00:00
2024-10-27T04:17:47.233178+00:00
63
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nFirst calculate the product of GCD*LCM of the whole array then calculate all other possible products excluding 1 element per iteration.\n# Approach\n<!-- Describe your approach to solving the problem. -->\n- Generate GCD*LCM of full array...
2
0
['Greedy', 'Number Theory', 'C++']
0
find-the-maximum-factor-score-of-array
Python Solution Time -- > O(N) and Space --> O(1)
python-solution-time-on-and-space-o1-by-wwzxn
IntuitionIdea to solve this problem given by Claude Not very Hard ApproachApproach*nums is used to unpack the list as the gcd and lcm function takes only intege
Amritraj777
NORMAL
2025-03-27T19:43:51.809849+00:00
2025-03-27T19:43:51.809849+00:00
23
false
# Intuition Idea to solve this problem given by Claude Not very Hard Approach # Approach ***nums** is used to unpack the list as the gcd and lcm function takes only integers # Complexity - Time complexity: <!-- Add your time complexity here, e.g. $$O(n)$$ --> O(N) --> Linear - Space complexity: <!-- Add your space c...
1
0
['Python3']
1
find-the-maximum-factor-score-of-array
Prefix and suffix. Simple solution O(n)
prefix-and-suffix-simple-solution-on-by-o8kxd
null
xxxxkav
NORMAL
2025-02-11T09:46:59.408861+00:00
2025-02-13T15:56:10.883014+00:00
40
false
``` class Solution: def maxScore(self, nums: List[int]) -> int: if len(nums) == 1: return nums[0] * nums[0] pref_gcd = [*accumulate(nums, gcd)] pref_lcm = [*accumulate(nums, lcm)] suff_gcd = [*accumulate(reversed(nums), gcd)] suff_lcm = [*accumulate(reversed(nums...
1
0
['Python3']
0
find-the-maximum-factor-score-of-array
C++ Solution | Time Complexity: O(n) | Space Complexity: O(n) | Beats 100% Runtime
c-solution-time-complexity-on-space-comp-shvf
IntuitionThe first thing that would come to your mind when thinking about removing at most one element is the need to link the elements before and after it. To
Sohil423Abuzeid
NORMAL
2025-01-16T22:48:53.897526+00:00
2025-01-16T22:48:53.897526+00:00
74
false
# Intuition The first thing that would come to your mind when thinking about removing at most one element is the need to link the elements before and after it. To do that, I need to know the values of all elements after it and all elements before it, and then concatenate these values. # Approach <!-- Describe your appr...
1
0
['C++']
0
find-the-maximum-factor-score-of-array
[C++] No trick, just simple implementation
c-no-trick-just-simple-implementation-by-0egh
lcm of an array: we iterate throguh the array and calculate for each position the new lcm, lcm at i will be lcm[i] = lcm(lcm_nums[i-1], nums[i]), since for posi
bora_marian
NORMAL
2024-11-02T07:59:29.650173+00:00
2024-11-02T08:56:19.398223+00:00
91
false
lcm of an array: we iterate throguh the array and calculate for each position the new lcm, lcm at i will be ```lcm[i] = lcm(lcm_nums[i-1], nums[i])```, since for position i we need only the lcm at ```i-1``` we can keep it in a single variable ```lcm_nums = lcm(lcm_nums, nums[i]);```\ngcf of an array: the same as for LC...
1
0
['C++']
0
find-the-maximum-factor-score-of-array
Good and Easy to understand solution using prefix and suffix gcd and lcm arrays
good-and-easy-to-understand-solution-usi-535e
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
Ronitwanare
NORMAL
2024-10-29T07:36:57.825907+00:00
2024-10-29T07:38:00.271451+00:00
17
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
find-the-maximum-factor-score-of-array
Simple Python solution | Beats 100% in time and memory
simple-python-solution-beats-100-in-time-ec5e
Intuition\nThe GCD of multiple numbers can be computed by taking the GCD of the first two, then repeating with the next number:\n\nGCD(a, b, c, ...) = GCD(GCD(a
david1121
NORMAL
2024-10-28T04:22:26.332587+00:00
2024-10-28T04:22:26.332614+00:00
64
false
# Intuition\nThe GCD of multiple numbers can be computed by taking the GCD of the first two, then repeating with the next number:\n\n$$GCD(a, b, c, ...) = GCD(GCD(a, b), c, ...)$$\n\nThe same thing is true for the LCM:\n\n$$LCM(a, b, c, ...) = LCM(LCM(a, b), c, ...)$$\n\nTo get the LCM of two numbers, we can multiply t...
1
0
['Python3']
0
find-the-maximum-factor-score-of-array
Greedy with prefix array | 4 ms - beats 100.00%
greedy-with-prefix-array-4-ms-beats-1000-018g
Complexity\n- Time complexity: O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(n)\n Add your space complexity here, e.g. O(n) \n\n# Co
tigprog
NORMAL
2024-10-27T13:43:16.024116+00:00
2024-10-27T13:43:40.178596+00:00
33
false
# Complexity\n- Time complexity: $$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(n)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```python3 []\nfrom math import lcm, gcd\n\nclass Solution:\n def maxScore(self, nums: List[int]) -> int:\n suffix...
1
0
['Greedy', 'Suffix Array', 'Python3']
0
find-the-maximum-factor-score-of-array
python3 bruteforce
python3-bruteforce-by-0icy-1q1m
\n\n# Code\npython3 []\nclass Solution:\n def maxScore(self, nums: List[int]) -> int:\n if len(nums) == 1:\n return nums[0]**2\n ans
0icy
NORMAL
2024-10-27T06:34:01.829295+00:00
2024-10-27T06:34:01.829318+00:00
23
false
\n\n# Code\n```python3 []\nclass Solution:\n def maxScore(self, nums: List[int]) -> int:\n if len(nums) == 1:\n return nums[0]**2\n ans = reduce(lcm,nums)*reduce(gcd,nums)\n for i in range(len(nums)):\n temp = nums[:i]+nums[i+1:]\n ans = max(ans,reduce(lcm,temp)*...
1
0
['Python3']
0
find-the-maximum-factor-score-of-array
Beats 100% || Constant Space
beats-100-constant-space-by-amar_1-w4jr
Complexity\n- Time complexity:\nO(n^2)\n- Space complexity:\nO(1)\n\n# Code\njava []\nclass Solution {\n public long gcd(long m, long n){\n while(n !=
Amar_1
NORMAL
2024-10-27T05:35:53.354696+00:00
2024-10-27T05:35:53.354722+00:00
37
false
# Complexity\n- Time complexity:\nO(n^2)\n- Space complexity:\nO(1)\n\n# Code\n```java []\nclass Solution {\n public long gcd(long m, long n){\n while(n != 0){\n long gcd = m % n;\n m = n;\n n = gcd;\n }\n\n return m;\n }\n public long lcm(long m, long n){\...
1
0
['Java']
0
find-the-maximum-factor-score-of-array
Beats 100% in both Time and Space || Simplest Approach to understand
beats-100-in-both-time-and-space-simples-1k7c
Complexity\n- Time complexity:\n \uD835\uDC42(n^2)\n\n- Space complexity:\n O(n)\n\n\n# Code\njava []\nclass Solution {\n public long maxScore(int[] nu
Shivam_Mainro
NORMAL
2024-10-27T05:08:38.168702+00:00
2024-10-27T05:08:38.168744+00:00
34
false
# Complexity\n- Time complexity:\n \uD835\uDC42(n^2)\n\n- Space complexity:\n O(n)\n\n\n# Code\n```java []\nclass Solution {\n public long maxScore(int[] nums) {\n int n = nums.length;\n if(n==0) return 0;\n if(n==1) return (long)(nums[0] * nums[0]);\n long maxans = lcmarr(nums) * g...
1
0
['Java']
1
find-the-maximum-factor-score-of-array
radhe radhe || simple and easy solution || beats 100%
radhe-radhe-simple-and-easy-solution-bea-96d2
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
neerajofficial1919
NORMAL
2024-10-27T04:40:57.638771+00:00
2024-10-27T04:40:57.638798+00:00
191
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
find-the-maximum-factor-score-of-array
O(n^2) solution 7 line AC code (bruteforce)
on2-solution-7-line-ac-code-bruteforce-b-bsf5
Intuition\nYes gcd and lcm pre-exist for array in python as well which i don\'t know during contest.\n# Approach\nyes this is an easy code with self explainatio
Divyanshu52Singhal
NORMAL
2024-10-27T04:16:01.850012+00:00
2024-10-27T04:16:01.850037+00:00
146
false
# Intuition\nYes gcd and lcm pre-exist for array in python as well which i don\'t know during contest.\n# Approach\nyes this is an easy code with self explaination \n# Complexity\n- Time complexity: $$O(n^2)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:$$O(n)$$\n<!-- Add your space com...
1
0
['Python3']
2
find-the-maximum-factor-score-of-array
This Solution You Will never Forget | | C++
this-solution-you-will-never-forget-c-by-c33b
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
Ninja_1006
NORMAL
2024-10-27T04:06:20.079518+00:00
2024-10-27T04:06:20.079546+00:00
197
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
1
['C++']
0
find-the-maximum-factor-score-of-array
Easiest Solution 💡
easiest-solution-by-sobhandevp2021-y66z
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
sobhandevp2021
NORMAL
2024-10-27T04:05:02.556518+00:00
2024-10-27T04:05:02.556538+00:00
239
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', 'Java']
1
find-the-maximum-factor-score-of-array
easy way to solve
easy-way-to-solve-by-kamesh-babu-qy3k
IntuitionApproachComplexity Time complexity: Space complexity: Code
Kamesh-Babu
NORMAL
2025-03-06T15:46:22.892179+00:00
2025-03-06T15:46:22.892179+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
['C++']
0
find-the-maximum-factor-score-of-array
Easy solution
easy-solution-by-koushik_55_koushik-80ro
IntuitionApproachComplexity Time complexity: Space complexity: Code
Koushik_55_Koushik
NORMAL
2025-02-09T16:47:19.208977+00:00
2025-02-09T16:47:19.208977+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
['Python3']
0
find-the-maximum-factor-score-of-array
Brute-forcing solution by slicing and calculating LCM and GCD for remaining elements
brute-forcing-solution-by-slicing-and-ca-ur2x
IntuitionWe'll approach this problem in a rather brute-"forcish" fashion. We'll ignore the element at each position in nums and calculate the LCM and GCD for th
mnjk
NORMAL
2025-02-08T14:08:30.854380+00:00
2025-02-08T14:08:30.854380+00:00
3
false
# Intuition We'll approach this problem in a rather brute-"forcish" fashion. We'll ignore the element at each position in `nums` and calculate the LCM and GCD for the remaining elements while keeping track of the maximum value. # Approach The LCM and GCD of a single number are the number itself: ```py if L == 1: ...
0
0
['Number Theory', 'Python3']
0
find-the-maximum-factor-score-of-array
GCD,LCM RELATION WITH RESOURCES (EASY LOGIC EXPLAINATION)
gcdlcm-relation-with-resources-easy-logi-iuh7
IntuitionApproachComplexity Time complexity: Space complexity: Code
Prahlad_07
NORMAL
2025-02-03T08:39:19.030373+00:00
2025-02-03T08:39:19.030373+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
['C++']
0
find-the-maximum-factor-score-of-array
C++ || Prefix & Suffix || Beats 100% || Easy to Understand
c-prefix-suffix-beats-100-easy-to-unders-upqi
Complexity Time complexity: O(n⋅log(max_value)) (max_value here 30) Space complexity: O(n) Code
james_thorn
NORMAL
2024-12-16T21:44:22.063649+00:00
2024-12-16T21:44:22.063649+00:00
7
false
# Complexity\n- Time complexity: O(n\u22C5log(max_value)) (max_value here 30)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\n#define ll long long\nclass Solution {\npublic:\n long long gcd(ll div, ll qo)...
0
0
['C++']
0
find-the-maximum-factor-score-of-array
Python Brute Force
python-brute-force-by-kaluginpeter-up2e
\n\n# Complexity\n- Time complexity: O(N**2)\n\n- Space complexity: O(N)\n\n# Code\npython3 []\ndef gcd(a, b):\n return math.gcd(a, b)\n\ndef lcm(a, b):\n
kaluginpeter
NORMAL
2024-11-26T17:12:27.810464+00:00
2024-11-26T17:12:27.810501+00:00
5
false
\n\n# Complexity\n- Time complexity: O(N**2)\n\n- Space complexity: O(N)\n\n# Code\n```python3 []\ndef gcd(a, b):\n return math.gcd(a, b)\n\ndef lcm(a, b):\n return abs(a * b) // gcd(a, b)\n\ndef gcd_of_list(numbers):\n return reduce(gcd, numbers)\n\ndef lcm_of_list(numbers):\n return reduce(lcm, numbers)\n...
0
0
['Array', 'Math', 'Number Theory', 'Python3']
0
find-the-maximum-factor-score-of-array
Using gcd and lcm concept
using-gcd-and-lcm-concept-by-risabhuchih-dbwj
\njava []\nclass Solution {\n public long maxScore(int[] nums) {\n if(nums.length==1)return nums[0]*nums[0];\n long ans=f(-1,nums);\n for
risabhuchiha
NORMAL
2024-11-25T07:50:12.640144+00:00
2024-11-25T07:50:12.640184+00:00
9
false
\n```java []\nclass Solution {\n public long maxScore(int[] nums) {\n if(nums.length==1)return nums[0]*nums[0];\n long ans=f(-1,nums);\n for(int i=0;i<nums.length;i++){\n ans=Math.max(f(i,nums),ans);\n } \n return ans;\n }\n public long f(int idx,int[] nums){\n l...
0
0
['Java']
0
find-the-maximum-factor-score-of-array
Simple and Easy JAVA Solution , Brute Force approach
simple-and-easy-java-solution-brute-forc-v4qd
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
Triyaambak
NORMAL
2024-11-09T07:42:16.958793+00:00
2024-11-09T07:42:16.958829+00:00
7
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
find-the-maximum-factor-score-of-array
Two liner || most DISGUSTING code you'll ever see
two-liner-most-disgusting-code-youll-eve-j3ea
Code\npython3 []\nclass Solution:\n def maxScore(self, nums: List[int]) -> int:\n r = [[[n % q**i for i in range(1,5)].count(0) for q in (2,3,5,7,11,1
dingotron
NORMAL
2024-11-07T17:10:34.437407+00:00
2024-11-07T17:10:34.437441+00:00
13
false
# Code\n```python3 []\nclass Solution:\n def maxScore(self, nums: List[int]) -> int:\n r = [[[n % q**i for i in range(1,5)].count(0) for q in (2,3,5,7,11,13,17,19,23,29)] for n in range(31)] \n return nums[0]** 2 if len(nums) == 1 else max((f := lambda l: prod((2,3,5,7,11,13,17,19,23,29)[i]**(min(s :=...
0
0
['Python3']
0
find-the-maximum-factor-score-of-array
java simple solution
java-simple-solution-by-trivedi_cs1-pi9j
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
trivedi_cs1
NORMAL
2024-11-07T11:45:16.753741+00:00
2024-11-07T11:45:16.753762+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
['Java']
0
find-the-maximum-factor-score-of-array
[C] prefix & suffix | Time: O(n), Space: O(n)
c-prefix-suffix-time-on-space-on-by-zhan-qmkz
C []\nstatic int gcd(int a, int b){\n\twhile (b != 0){\n\t\tconst int c = a % b;\n\n\t\ta = b;\n\t\tb = c;\n\t}\n\n\treturn a;\n}\n\nstatic int64_t gcd_int64(in
zhang_jiabo
NORMAL
2024-11-07T07:50:14.548409+00:00
2024-11-07T08:24:53.573322+00:00
12
false
```C []\nstatic int gcd(int a, int b){\n\twhile (b != 0){\n\t\tconst int c = a % b;\n\n\t\ta = b;\n\t\tb = c;\n\t}\n\n\treturn a;\n}\n\nstatic int64_t gcd_int64(int64_t a, int64_t b){\n\twhile (b != 0){\n\t\tconst int64_t c = a % b;\n\n\t\ta = b;\n\t\tb = c;\n\t}\n\n\treturn a;\n}\nstatic int64_t lcm_int64(const int64_...
0
0
['C']
0
find-the-maximum-factor-score-of-array
scala solution
scala-solution-by-vititov-nvgn
scala []\nobject Solution {\n import scala.util.chaining._\n def maxScore(nums: Array[Int]): Long = {\n def reducer(a:(BigInt,BigInt),b:(BigInt,BigInt)) =\
vititov
NORMAL
2024-11-06T20:24:30.070190+00:00
2024-11-06T20:24:30.070221+00:00
1
false
```scala []\nobject Solution {\n import scala.util.chaining._\n def maxScore(nums: Array[Int]): Long = {\n def reducer(a:(BigInt,BigInt),b:(BigInt,BigInt)) =\n (a._1 gcd b._1, (a._2 / (a._2 gcd b._2)) * b._2)\n val pfx = nums.sorted.map(BigInt(_)).map(a => (a,a))\n .pipe{l => l.tail.scanLeft(l.head)(r...
0
0
['Array', 'Prefix Sum', 'Scala']
0
find-the-maximum-factor-score-of-array
Beats 100% || Number Theory || Math|| Easy Solution.
beats-100-number-theory-math-easy-soluti-oitk
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
ganesh_jaggu
NORMAL
2024-11-06T15:05:51.432458+00:00
2024-11-06T15:06:42.135799+00:00
15
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
['Array', 'Math', 'Suffix Array', 'Number Theory', 'Prefix Sum', 'C++']
0
find-the-maximum-factor-score-of-array
Super Simple || C++
super-simple-c-by-lotus18-j6ci
Code\ncpp []\nclass Solution \n{\npublic:\n long long maxScore(vector<int>& nums) \n {\n int n=nums.size();\n if(n==1) return nums[0]*nums[0
lotus18
NORMAL
2024-11-06T06:19:35.654048+00:00
2024-11-06T06:19:35.654084+00:00
11
false
# Code\n```cpp []\nclass Solution \n{\npublic:\n long long maxScore(vector<int>& nums) \n {\n int n=nums.size();\n if(n==1) return nums[0]*nums[0];\n if(n==2)\n {\n long long lcm=((long long)nums[0]*nums[1])/__gcd(nums[0],nums[1]);\n int gcd=__gcd(nums[0],nums[1])...
0
0
['C++']
0
find-the-maximum-factor-score-of-array
Best Solution || Easy to Understand
best-solution-easy-to-understand-by-nand-j6w3
\n# Code\ncpp []\n#define ll long long\n// here we are normally calculating gcd and lcm after removing every element as the contraints are not high.\nclass Solu
NandiniJindal
NORMAL
2024-11-06T01:36:13.926773+00:00
2024-11-06T01:36:13.926799+00:00
6
false
\n# Code\n```cpp []\n#define ll long long\n// here we are normally calculating gcd and lcm after removing every element as the contraints are not high.\nclass Solution {\npublic:\n ll gcd(ll a,ll b){\n if(b==0) return a;\n return gcd(b,a%b);\n }\n\n ll lcm(ll a,ll b)\n {\n return a*b/gc...
0
0
['Array', 'Math', 'C++']
0
find-the-maximum-factor-score-of-array
Brute Force
brute-force-by-azizkaz-plhc
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \nBrute Force\n\n# Comple
azizkaz
NORMAL
2024-11-05T06:45:57.391947+00:00
2024-11-05T06:45:57.391988+00:00
3
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nBrute Force\n\n# Complexity\n- Time complexity: $O(n^2)$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $O(1)$\n<!-- Add your space comp...
0
0
['Array', 'Math', 'Number Theory', 'Rust']
0
find-the-maximum-factor-score-of-array
Prefix + Suffix
prefix-suffix-by-azizkaz-3v1u
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \nPrefix + Suffix\n\n# Co
azizkaz
NORMAL
2024-11-05T06:43:32.004819+00:00
2024-11-05T06:49:42.333428+00:00
5
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nPrefix + Suffix\n\n# Complexity\n- Time complexity: $O(n)$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $O(n)$\n<!-- Add your space co...
0
0
['Array', 'Math', 'Number Theory', 'Rust']
0
find-the-maximum-factor-score-of-array
Short Ruby solution. No libraries.
short-ruby-solution-no-libraries-by-oneu-0544
Intuition\nStraight forward\n\n# Approach\nBrute-force\n\n# Complexity\n- Time complexity:\nO(n^2)\n\n- Space complexity:\nO(1)\n\n# Code\nruby []\n# @param {In
oneunknownuser
NORMAL
2024-11-03T18:41:18.296273+00:00
2024-11-04T23:40:34.044375+00:00
3
false
# Intuition\nStraight forward\n\n# Approach\nBrute-force\n\n# Complexity\n- Time complexity:\n$$O(n^2)$$\n\n- Space complexity:\n$$O(1)$$\n\n# Code\n```ruby []\n# @param {Integer[]} nums\n# @return {Integer}\ndef max_score(nums)\n n = nums.size \n return 0 if n == 0\n return nums[0] * nums[0] if n == 1\n \n max...
0
0
['Ruby']
0
find-the-maximum-factor-score-of-array
Prime Factorisation | O(𝑛²), O(𝑛) | 5.83%, 59.60%
prime-factorisation-on2-on-583-5960-by-w-1qh5
Intuition\n Describe your first thoughts on how to solve this problem. \nThis problem involves finding the lowest common multiple (LCM) and the greatest common
Winoal875
NORMAL
2024-11-03T15:02:02.739310+00:00
2024-11-17T19:24:57.805252+00:00
5
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThis problem involves finding the lowest common multiple (LCM) and the greatest common divider (GCD) [or highest common factor (HCF)] of the entire array minus one or no elements. Our approach uses <ins>number theory</ins> by first doing ...
0
0
['Math', 'Number Theory', 'Python3']
0
find-the-maximum-factor-score-of-array
Find the Maximum Factor Score of Array
find-the-maximum-factor-score-of-array-b-kgo3
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
zH6HvQOmcZ
NORMAL
2024-11-03T04:14:52.168012+00:00
2024-11-03T04:14:52.168041+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
find-the-maximum-factor-score-of-array
Find the Maximum Factor Score of Array
find-the-maximum-factor-score-of-array-b-p6cf
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
zH6HvQOmcZ
NORMAL
2024-11-03T04:14:48.940976+00:00
2024-11-03T04:14:48.941002+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
['Python3']
0
find-the-maximum-factor-score-of-array
Simple Python
simple-python-by-amruthamuralidhar-lo38
Intuition\ncalculate gcd and lcm each time by removing one element\n\n# Complexity\n- Time complexity:\nO(n)\n- Space complexity:\nO(n)\n\n# Code\npython3 []\nc
AmruthaMuralidhar
NORMAL
2024-11-02T14:17:46.450864+00:00
2024-11-02T14:17:46.450891+00:00
8
false
# Intuition\ncalculate gcd and lcm each time by removing one element\n\n# Complexity\n- Time complexity:\nO(n)\n- Space complexity:\nO(n)\n\n# Code\n```python3 []\nclass Solution:\n import math\n def maxScore(self, nums: List[int]) -> int:\n mx = gcd(*nums) * lcm(*nums)\n for i in nums:\n ...
0
0
['Python3']
0
find-the-maximum-factor-score-of-array
Fast solurtion C#
fast-solurtion-c-by-bogdanonline444-06x6
\n# Complexity\n- Time complexity: O(n ^ 2)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(1)\n Add your space complexity here, e.g. O(n)
bogdanonline444
NORMAL
2024-11-02T10:59:21.911109+00:00
2024-11-02T10:59:21.911130+00:00
0
false
\n# Complexity\n- Time complexity: O(n ^ 2)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```csharp []\npublic class Solution {\n public long MaxScore(int[] nums) {\n if(nums.Length == 1)\n {\n ...
0
0
['Array', 'Math', 'C#']
0
find-the-maximum-factor-score-of-array
Simple Java Solution
simple-java-solution-by-sakshikishore-7zwi
Code\njava []\nclass Solution {\n public long maxScore(int[] nums) {\n long max=0;\n for(int i=0;i<nums.length;i++)\n {\n int flag=
sakshikishore
NORMAL
2024-11-02T09:23:58.417011+00:00
2024-11-02T09:23:58.417040+00:00
4
false
# Code\n```java []\nclass Solution {\n public long maxScore(int[] nums) {\n long max=0;\n for(int i=0;i<nums.length;i++)\n {\n int flag=0;\n long gcd=0,lcm=0;\n for(int j=0;j<nums.length;j++)\n {\n if(i==j)\n {\n continue;\n ...
0
0
['Java']
0
find-the-maximum-factor-score-of-array
Simple Java Solution
simple-java-solution-by-rajatgandhi333-p591
Intuition\n Describe your first thoughts on how to solve this problem. \nBrute force, find the gcd and lcm of the array\nand compare when one element is removed
rajatgandhi333
NORMAL
2024-11-02T08:49:18.924477+00:00
2024-11-02T08:49:18.924504+00:00
6
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nBrute force, find the gcd and lcm of the array\nand compare when one element is removed\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. $...
0
0
['Java']
0
find-the-maximum-factor-score-of-array
Easiest and Self Explanatory Solution || Brute Force
easiest-and-self-explanatory-solution-br-586p
\n\n# Code\ncpp []\nclass Solution {\npublic:\n long long computelcm(long long a, long long b) {\n return (a * b) / __gcd(a,b);\n }\n\n\n long l
karan_maheshwari16
NORMAL
2024-11-02T07:04:36.964275+00:00
2024-11-02T07:05:03.527166+00:00
8
false
\n\n# Code\n```cpp []\nclass Solution {\npublic:\n long long computelcm(long long a, long long b) {\n return (a * b) / __gcd(a,b);\n }\n\n\n long long maxScore(vector<int>& nums) {\n long long ans = 0;\n long long gcd = 0, lcm = 0;\n int n = nums.size();\n\n for(int i=0 ; i<n...
0
0
['C++']
0
find-the-maximum-factor-score-of-array
C++ Easy Solution.
c-easy-solution-by-sujay_awale-sv7z
\n# Code\ncpp []\nclass Solution {\npublic:\n long long maxScore(vector<int>& nums) {\n long long ans=0, gcd1=0, lcm1=0;\n // Removing no eleme
sujay_awale
NORMAL
2024-11-01T16:18:03.964161+00:00
2024-11-01T16:18:03.964191+00:00
24
false
\n# Code\n```cpp []\nclass Solution {\npublic:\n long long maxScore(vector<int>& nums) {\n long long ans=0, gcd1=0, lcm1=0;\n // Removing no element\n for(int i=0; i<nums.size(); i++){\n if(gcd1==0){gcd1=1LL*nums[i];}\n else{gcd1=__gcd(gcd1, 1LL*nums[i]);}\n if(l...
0
0
['C++']
0
find-the-maximum-factor-score-of-array
100% beat
100-beat-by-maancodes-76kd
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
Maancodes
NORMAL
2024-11-01T08:47:29.156644+00:00
2024-11-01T08:47:29.156690+00:00
15
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', 'Prefix Sum', 'C++']
0
find-the-maximum-factor-score-of-array
Python3 Brute Force
python3-brute-force-by-tkr_6-m9ni
\n\n# Code\npython3 []\nclass Solution:\n def maxScore(self, nums: List[int]) -> int:\n\n ans=lcm(*nums)*gcd(*nums)\n n=len(nums)\n\n fo
TKR_6
NORMAL
2024-11-01T07:12:20.231983+00:00
2024-11-01T07:12:20.232007+00:00
14
false
\n\n# Code\n```python3 []\nclass Solution:\n def maxScore(self, nums: List[int]) -> int:\n\n ans=lcm(*nums)*gcd(*nums)\n n=len(nums)\n\n for i in range(n):\n sub=nums[:i]+nums[i+1:]\n l=lcm(*sub)\n g=gcd(*sub)\n ans=max(ans,l*g)\n \n return a...
0
0
['Math', 'Python', 'Python3']
0
find-the-maximum-factor-score-of-array
Easy to understand C++ code
easy-to-understand-c-code-by-rk_25-vnmx
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
RK_25
NORMAL
2024-11-01T06:55:31.794034+00:00
2024-11-01T06:55:31.794068+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
find-the-maximum-factor-score-of-array
Maximize Factor Score of an Array After Removing One Element
maximize-factor-score-of-an-array-after-t3fp9
Intuition\n Describe your first thoughts on how to solve this problem. \nThe factor score is defined as the product of the LCM and GCD of the array. Removing on
i-sayankh
NORMAL
2024-10-31T03:51:40.508176+00:00
2024-10-31T03:51:40.508212+00:00
17
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe factor score is defined as the product of the LCM and GCD of the array. Removing one element from the array may increase the factor score by changing the GCD and LCM in ways that maximize their product. We aim to explore all possible ...
0
0
['JavaScript']
0
find-the-maximum-factor-score-of-array
C++ | Brute Force Solution | Clean Code ✅ | Beginner Friendly
c-brute-force-solution-clean-code-beginn-rwdv
Time complexity is\n - due to outer loop = N\n - due to inner loop = N\n - for gcd function = log(min(a, b)) , since a and b can be at max 30, the comp
Felix-Felicis
NORMAL
2024-10-30T20:25:04.608962+00:00
2024-10-30T20:25:04.608997+00:00
15
false
Time complexity is\n - due to outer loop = N\n - due to inner loop = N\n - for gcd function = log(min(a, b)) , since a and b can be at max 30, the complexity becomes =~ log 30 =~ constant\n \n TC - O(N^2)\n SC - O(1)\n\n# Code\n```cpp []\nclass Solution {\npublic:\n\n // optimized Euclidean algorit...
0
0
['Math', 'Number Theory', 'C++']
0
find-the-maximum-factor-score-of-array
JAVA 1ms with GCD
java-1ms-with-gcd-by-meringueee-k7zr
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
meringueee
NORMAL
2024-10-30T10:19:43.532625+00:00
2024-10-30T10:19:43.532664+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
find-the-maximum-factor-score-of-array
Time: O(n) , Space : O(n) , 2 pass , C++
time-on-space-on-2-pass-c-by-gearman0712-1moq
Intuition\nIterate through the array , leave current element and calculate gcd and lcm for all the remaining elements.\nBut it would take O(n^2).\nIf you look
gearman0712
NORMAL
2024-10-30T10:11:40.910145+00:00
2024-10-30T10:11:40.910176+00:00
9
false
# Intuition\nIterate through the array , leave current element and calculate gcd and lcm for all the remaining elements.\nBut it would take O(n^2).\nIf you look closely you will find redundent work , why can\'t we calculate in the starting and save these answers in suffix arrays.\n\nNo need to create prefix array we c...
0
0
['C++']
0
find-the-maximum-factor-score-of-array
Max Score with Brute Force lcm*gcd
max-score-with-brute-force-lcmgcd-by-roh-zv4h
Intuition\n Describe your first thoughts on how to solve this problem. \nAs the Questions says that we find the maximum score that is equal to product of lcm of
rohitsinghmaurya20
NORMAL
2024-10-30T08:14:38.266549+00:00
2024-10-30T08:14:38.266572+00:00
2
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nAs the Questions says that we find the maximum score that is equal to product of lcm of array elements and gcd of the array elements and we can remove at most one element.\nThen first thing which come in my mind that according to constrai...
0
0
['C++']
0
find-the-maximum-factor-score-of-array
3334.Find the Maximum Factor Score of Array (Solution)
3334find-the-maximum-factor-score-of-arr-x4vc
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
py_nitin
NORMAL
2024-10-30T05:24:39.552125+00:00
2024-10-30T05:24:39.552152+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
['Python']
0
find-the-maximum-factor-score-of-array
O(n^2) Time complexity. Easy solution✅✅✅.
on2-time-complexity-easy-solution-by-ava-hvt1
\n\n# Code\njava []\nclass Solution {\n long gcd(long a,long b)\n {\n if(a%b==0)\n {\n return b;\n }\n else\n
avaneesh2523
NORMAL
2024-10-30T05:20:12.273448+00:00
2024-10-30T05:20:12.273466+00:00
9
false
\n\n# Code\n```java []\nclass Solution {\n long gcd(long a,long b)\n {\n if(a%b==0)\n {\n return b;\n }\n else\n {\n return gcd(b,a%b);\n }\n }\n long calculateLCM(long a,long b)\n {\n return ((a/gcd(a,b))*b);\n }\n public long ...
0
0
['Java']
0
find-the-maximum-factor-score-of-array
lcm(a,b,c) = lcm(lcm(a,b), c); lcm(a,b) = a*b/gcd(a,b)
lcmabc-lcmlcmab-c-lcmab-abgcdab-by-user5-te6d
rust []\nfn gcd(x: i64, y: i64) -> i64 {\n if y == 0 {x} else {gcd(y, x % y)}\n}\n\nfn lcm(x: i64, y: i64) -> i64 {\n x * y / gcd(x,y) \n}\n\n\nfn cum<I>(
user5285Zn
NORMAL
2024-10-29T17:13:54.876066+00:00
2024-10-29T17:13:54.876102+00:00
13
false
```rust []\nfn gcd(x: i64, y: i64) -> i64 {\n if y == 0 {x} else {gcd(y, x % y)}\n}\n\nfn lcm(x: i64, y: i64) -> i64 {\n x * y / gcd(x,y) \n}\n\n\nfn cum<I>(xs: I) -> Vec<(i64, i32)> \n where I : Iterator <Item = i32> {\n let mut r = vec![(1, 0)];\n let mut d = 0;\n let mut p = 1;\n ...
0
0
['Rust']
0
find-the-maximum-factor-score-of-array
brute force --> better --> optimal ||🧮 || find maximal factor score of array ||
brute-force-better-optimal-find-maximal-dz7n8
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
adityamohanty1310
NORMAL
2024-10-29T15:16:45.826313+00:00
2024-10-29T15:16:45.826348+00:00
19
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 brute force -- O(N^2)\n optimal -- O(N)\n\n- Space complexity:\n<!-- ...
0
0
['Array', 'Math', 'Suffix Array', 'Number Theory', 'Prefix Sum', 'Java']
0
find-the-maximum-factor-score-of-array
Solved by Relation between gcd and lcm , C++ , TC : O ( n^2 ) ,SC: O ( 1 )
solved-by-relation-between-gcd-and-lcm-c-vk0x
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
Devarshi1206
NORMAL
2024-10-29T15:13:03.329916+00:00
2024-10-29T15:13:03.329951+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
find-the-maximum-factor-score-of-array
Step-by-Step Solution
step-by-step-solution-by-lakshy01-lbi9
Intuition\n Describe your first thoughts on how to solve this problem. \n\nYou\u2019re given a list of numbers, and your mission (should you choose to accept it
lakshy01
NORMAL
2024-10-29T14:45:34.669210+00:00
2024-10-29T14:45:34.669240+00:00
10
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\nYou\u2019re given a list of numbers, and your mission (should you choose to accept it) is to calculate the maximum score by playing around with the GCD (Greatest Common Divisor) and LCM (Least Common Multiple) of these numbers.\n\nSo, i...
0
0
['C++']
0
find-the-maximum-factor-score-of-array
Maximizing Array Products with Prefix and Suffix GCD-LCM in C++
maximizing-array-products-with-prefix-an-lkjm
Intuition\nThe problem requires maximizing a product involving the GCD and LCM of subarrays. By separating the array into different prefix and suffix segments,
krishnavipulcoder
NORMAL
2024-10-29T13:37:46.003877+00:00
2024-10-29T13:37:46.003920+00:00
15
false
# Intuition\nThe problem requires maximizing a product involving the **GCD** and **LCM **of subarrays. By separating the array into different **prefix **and **suffix **segments, we can efficiently calculate the maximum possible GCD-LCM product using precomputed arrays.\n\n# Approach\n# 1. Precompute Prefix and Suffix A...
0
0
['Suffix Array', 'C++']
0
find-the-maximum-factor-score-of-array
C++ Code with complexity O(n^2) and O(1)
c-code-with-complexity-on2-and-o1-by-hit-fhja
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
hitkar_miglani
NORMAL
2024-10-29T11:17:20.674241+00:00
2024-10-29T11:17:20.674266+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: O(n^2)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g....
0
0
['C++']
0
find-the-maximum-factor-score-of-array
[Python] 5 lines simple brute force
python-5-lines-simple-brute-force-by-pbe-dw6v
\nclass Solution:\n def maxScore(self, nums: List[int]) -> int:\n m = lcm(*nums)*gcd(*nums)\n\n for i in range(len(nums)):\n a = num
pbelskiy
NORMAL
2024-10-29T10:08:36.200063+00:00
2024-10-29T10:08:36.200099+00:00
13
false
```\nclass Solution:\n def maxScore(self, nums: List[int]) -> int:\n m = lcm(*nums)*gcd(*nums)\n\n for i in range(len(nums)):\n a = nums[:i] + nums[i+1:]\n m = max(m, lcm(*a)*gcd(*a))\n \n return m\n```
0
0
['Math', 'Python']
0
find-the-maximum-factor-score-of-array
Just Brute Force it !!
just-brute-force-it-by-mr-banana-q15z
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
kr-ankit
NORMAL
2024-10-29T04:32:22.879238+00:00
2024-10-29T04:32:22.879275+00:00
12
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(n^2)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:$$O(n)$$\n<!-- Add your space complexity here...
0
0
['Array', 'Math', 'Number Theory', 'C++']
0
find-the-maximum-factor-score-of-array
C++ | Prefix Suffix
c-prefix-suffix-by-pikachuu-euhg
Code\ncpp []\nclass Solution {\npublic:\n long long maxScore(vector<int>& nums) {\n int n = nums.size();\n if(n == 1) return nums[0] * nums[0];
pikachuu
NORMAL
2024-10-28T21:10:26.994917+00:00
2024-10-28T21:10:26.994945+00:00
8
false
# Code\n```cpp []\nclass Solution {\npublic:\n long long maxScore(vector<int>& nums) {\n int n = nums.size();\n if(n == 1) return nums[0] * nums[0];\n vector<long long> gcdRight(n), lcmRight(n);\n gcdRight[n - 1] = lcmRight[n - 1] = nums[n - 1];\n long long ans = 0;\n for(in...
0
0
['C++']
0
find-the-maximum-factor-score-of-array
Python || Simple solution
python-simple-solution-by-vilaparthibhas-t8hl
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
vilaparthibhaskar
NORMAL
2024-10-28T18:57:59.873670+00:00
2024-10-28T18:57:59.873689+00:00
3
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', 'Python3']
0
find-the-maximum-factor-score-of-array
Java | DP | time O(N) | Beats 100.00%
java-dp-time-on-beats-10000-by-markchen8-klin
Intuition\n Describe your first thoughts on how to solve this problem. \nif we want to calculate the factor score which removed nums[i],\nwe need prefix[i-1] an
markchen83115
NORMAL
2024-10-28T15:00:54.405542+00:00
2024-10-29T08:59:15.204006+00:00
19
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nif we want to calculate the **factor score** which removed `nums[i]`,\nwe need `prefix[i-1]` and `suffix[i+1]`\n```text\nprefix[i-1] suffix[i+1]\n[x x x x] x [x x x x]\n i \n```\n# Approach\n<!-- Describe your approach t...
0
0
['Java']
0
find-the-maximum-factor-score-of-array
Python: Beats 100%
python-beats-100-by-alexc2024-nx0m
Intuition\nCreate functions for lcn(nums) and gcd(nums), calculate the maxfactor. Try removing the numbers one by one from the list and check whether the update
AlexC2024
NORMAL
2024-10-28T12:45:14.926693+00:00
2024-10-28T12:45:14.926725+00:00
30
false
# Intuition\nCreate functions for lcn(nums) and gcd(nums), calculate the maxfactor. Try removing the numbers one by one from the list and check whether the updated maxfactor exceeds the running maximum\n\n# Approach\nThe idea is to convert the list of numbers into a matrix of size 11xn, where each row will contain the ...
0
0
['Python']
1
find-the-maximum-factor-score-of-array
Easiest || C++ || Beginer Friendly 🏆
easiest-c-beginer-friendly-by-gupta14ayn-uv7p
Intuition\n Describe your first thoughts on how to solve this problem. \nThe factor score is the product of LCM and GCD of the elements in the array. Removing d
gupta14aynat
NORMAL
2024-10-28T11:51:48.898220+00:00
2024-10-28T11:51:48.898244+00:00
20
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe factor score is the product of LCM and GCD of the elements in the array. Removing different elements will change the LCM and GCD, so we need to check each possibility to find the maximum score.\n# Approach\n<!-- Describe your approach...
0
0
['C++']
0
find-the-maximum-factor-score-of-array
C++ solution prefix + suffix array
c-solution-prefix-suffix-array-by-oleksa-axgg
\n// Please, upvote if you like it. Thanks :-)\nlong long maxScore(vector<int>& nums) {\n\tint n = nums.size();\n\tif (n == 1)\n\t\treturn nums.back() * nums.ba
oleksam
NORMAL
2024-10-28T09:22:04.471979+00:00
2024-10-28T09:22:04.472017+00:00
10
false
```\n// Please, upvote if you like it. Thanks :-)\nlong long maxScore(vector<int>& nums) {\n\tint n = nums.size();\n\tif (n == 1)\n\t\treturn nums.back() * nums.back();\n\tvector<long long> pregcd(n, nums[0]), prelcm(n, nums[0]);\n\tvector<long long> postgcd(n, nums.back()), postlcm(n, nums.back());\n\tfor (int i = 1; ...
0
0
['Array', 'Math', 'Greedy', 'C', 'C++']
0
find-the-maximum-factor-score-of-array
My solution
my-solution-by-sahil-2005-0khq
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
Sahil-2005
NORMAL
2024-10-28T09:14:28.075262+00:00
2024-10-28T09:14:28.075293+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
find-the-maximum-factor-score-of-array
My Solution
my-solution-by-hope_ma-kmw7
\n/**\n * Time Complexity: O(n)\n * Space Complexity: O(n)\n * where `n` is the length of the vector `nums`\n */\nclass Solution {\n public:\n long long maxSco
hope_ma
NORMAL
2024-10-28T05:40:38.665618+00:00
2024-10-28T05:40:38.665644+00:00
0
false
```\n/**\n * Time Complexity: O(n)\n * Space Complexity: O(n)\n * where `n` is the length of the vector `nums`\n */\nclass Solution {\n public:\n long long maxScore(const vector<int> &nums) {\n const int n = static_cast<int>(nums.size());\n long long left_gcd[n];\n memset(left_gcd, 0, sizeof(left_gcd));\n ...
0
0
[]
0
find-the-maximum-factor-score-of-array
precompute prefix and suffix lcm's and gcd's | Python
precompute-prefix-and-suffix-lcms-and-gc-1ooh
\n"""\nPrecompute the prefix and suffix lcm\'s and gcd\'s.\n"""\n\nfrom math import gcd, lcm\nclass Solution:\n def maxScore(self, A: List[int]) -> int:\n
wxy0925
NORMAL
2024-10-28T04:12:29.858499+00:00
2024-10-28T04:12:29.858536+00:00
11
false
```\n"""\nPrecompute the prefix and suffix lcm\'s and gcd\'s.\n"""\n\nfrom math import gcd, lcm\nclass Solution:\n def maxScore(self, A: List[int]) -> int:\n n = len(A)\n \n if n == 1:\n return A[0] ** 2\n \n gcd_left = [1] * n\n gcd_right = [1] * n\n lcm_l...
0
0
['Python']
0
find-the-maximum-factor-score-of-array
Maximum Factor Score After Removing At Most One Element
maximum-factor-score-after-removing-at-m-u389
Intuition\nWhen I first saw this problem, I realized we need to calculate the (GCD \times LCM) for different subarrays after removing at most one element. The k
iammawaistariq
NORMAL
2024-10-28T02:09:33.962836+00:00
2024-10-28T02:09:33.962866+00:00
9
false
# Intuition\nWhen I first saw this problem, I realized we need to calculate the $$(GCD \\times LCM)$$ for different subarrays after removing at most one element. The key insight is that we need to compare the factor score of the original array with the scores after removing each element one by one to find the maximum p...
0
0
['Python3']
0
find-the-maximum-factor-score-of-array
Greedy Algorithm
greedy-algorithm-by-alanchanghsnu-af3b
Approach\n1. len = 1\n\nWe can get the result num[0]^2\n\n2. len = 2\n\nAssume [a*b, a*c] where LCM = a, GCD = a*b*c. Then res = a*a*b*c = (a*b) * (a*c).\nIf we
alanchanghsnu
NORMAL
2024-10-27T21:39:30.842480+00:00
2024-10-27T21:50:10.234991+00:00
18
false
# Approach\n1. `len = 1`\n\nWe can get the result `num[0]^2`\n\n2. `len = 2`\n\nAssume `[a*b, a*c]` where `LCM = a`, `GCD = a*b*c`. Then `res = a*a*b*c = (a*b) * (a*c)`.\nIf we choose to remove smaller one `(a*b)`, then `res = (a*c) * (a*c)` .\n\nSince `a*b < a*c`, we can know that the best strategy is to remove the sm...
0
0
['Greedy', 'Java']
0
find-the-maximum-factor-score-of-array
Easy Approach C++,100% accepted solution
easy-approach-c100-accepted-solution-by-ozu5h
Intuition\n### Brute force: \nUse two loops to find the solution. However, this would be inefficient for large arrays.\n\n### Optimized approach:\n\n- Use prefi
ss_ww_1
NORMAL
2024-10-27T20:51:42.695812+00:00
2024-10-27T20:51:42.695833+00:00
2
false
# Intuition\n### Brute force: \nUse two loops to find the solution. However, this would be inefficient for large arrays.\n\n### Optimized approach:\n\n- Use prefix and suffix arrays.\n- First, calculate the gcd and lcm of all the elements ahead of the current index and store them in arrays using a loop.\n- Then, itera...
0
0
['C++']
0
find-the-maximum-factor-score-of-array
C++ solution of time complexity O(n^2) space complexity O(1)
c-solution-of-time-complexity-on2-space-ijp6d
Intuition\nTo solve the problem of finding the maximum score, which is defined as the product of the least common multiple (LCM) and the greatest common divisor
sumukhbendre
NORMAL
2024-10-27T20:25:34.920071+00:00
2024-10-27T20:25:34.920096+00:00
13
false
# Intuition\nTo solve the problem of finding the maximum score, which is defined as the product of the least common multiple (LCM) and the greatest common divisor (GCD) of a given array, we can think of two main operations:\n\n1. **GCD and LCM Calculations:** We need to compute the GCD and LCM of the entire array.\n2. ...
0
0
['C++']
0
find-the-maximum-factor-score-of-array
Beats 100% efficient solution
beats-100-efficient-solution-by-vinaiinf-ixdk
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
vinaiinfo18
NORMAL
2024-10-27T18:42:51.401619+00:00
2024-10-27T18:42:51.401651+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
['C++']
0
find-the-maximum-factor-score-of-array
O(n) Solution | Prefix and Suffix Array
on-solution-prefix-and-suffix-array-by-s-ibxt
Intuition and Approach\n Describe your approach to solving the problem. \nThe problem ask us to remove atmost one element and calculate the maximum score.\n\n#
sauram228
NORMAL
2024-10-27T17:22:33.156743+00:00
2024-10-27T17:22:33.156784+00:00
19
false
# Intuition and Approach\n<!-- Describe your approach to solving the problem. -->\nThe problem ask us to remove atmost one element and calculate the maximum score.\n\n# Complexity\n- Time complexity: $$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(n)$$\n<!-- Add your space com...
0
0
['C++']
0