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
reverse-degree-of-a-string
Scala solution with implicit, zip and map
scala-solution-with-implicit-zip-and-map-y8c6
IntuitionApproachComplexity Time complexity: Space complexity: Code
iyIeO99AmH
NORMAL
2025-04-03T21:10:20.377309+00:00
2025-04-03T21:10:20.377309+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
['Scala']
0
reverse-degree-of-a-string
Intuitive solution with array to map character to value in reversed alphabet
intuitive-solution-with-array-to-map-cha-sekc
IntuitionWe'll use a simple array to map each lowercase character to its value in the reversed alphabet.ApproachWe'll set up a simple array to map each lowercas
mnjk
NORMAL
2025-04-03T20:05:21.275617+00:00
2025-04-03T20:05:21.275617+00:00
3
false
# Intuition We'll use a simple array to map each lowercase character to its value in the reversed alphabet. # Approach We'll set up a simple array to map each lowercase character to its value in the reversed alphabet: ```ts const m = [26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5,...
0
0
['Array', 'String', 'TypeScript']
0
reverse-degree-of-a-string
python
python-by-binkswang-u2xp
Code
BinksWang
NORMAL
2025-04-03T19:12:43.709857+00:00
2025-04-03T19:12:43.709857+00:00
2
false
# Code ```python3 [] class Solution: def reverseDegree(self, s: str) -> int: arr = [] val = 26 rs = 0 while val > 0: arr.append(val) val -= 1 for i in range (0, len(s)): rs += arr[ord(s[i]) - ord('a')] * (i + 1) return rs `...
0
0
['Python3']
0
reverse-degree-of-a-string
c#
c-by-binkswang-89ua
Code
BinksWang
NORMAL
2025-04-03T19:08:36.004979+00:00
2025-04-03T19:08:36.004979+00:00
5
false
# Code ```csharp [] public class Solution { public int ReverseDegree(string s) { var arr = new int[26]; var val = 26; var rs = 0; for(var i = 0; i < arr.Length; i++){ arr[i] = val; val--; } for(var i = 0; i < s.Length; i++){ rs += a...
0
0
['C#']
0
reverse-degree-of-a-string
reverse-degree-of-a-string || very easy solution || JS
reverse-degree-of-a-string-very-easy-sol-rxn4
Complexity Time complexity:O(N) Space complexity:O(1) Code
shevykumar26
NORMAL
2025-04-03T17:56:38.958169+00:00
2025-04-03T17:56:38.958169+00:00
8
false
# Complexity - Time complexity:O(N) <!-- Add your time complexity here, e.g. $$O(n)$$ --> - Space complexity:O(1) <!-- Add your space complexity here, e.g. $$O(n)$$ --> # Code ```javascript [] /** * @param {string} s * @return {number} */ var reverseDegree = function(s) { let sum=0 for(let i=0;i<s.length...
0
0
['JavaScript']
0
reverse-degree-of-a-string
Java
java-by-soumya_699-x1hm
IntuitionApproachComplexity Time complexity: Space complexity: Code
Soumya_699
NORMAL
2025-04-03T04:29:35.207615+00:00
2025-04-03T04:29:35.207615+00:00
13
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
['Java']
0
reverse-degree-of-a-string
Java
java-by-soumya_699-lr6d
IntuitionApproachComplexity Time complexity: Space complexity: Code
Soumya_699
NORMAL
2025-04-03T04:29:31.499443+00:00
2025-04-03T04:29:31.499443+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
['Java']
0
reverse-degree-of-a-string
Reverse Degree of a String - 💯Beats 100.00% || C++✅✔️
reverse-degree-of-a-string-beats-10000-c-izsb
Complexity Time complexity: Space complexity: Code
itz_raju
NORMAL
2025-04-02T20:06:15.581196+00:00
2025-04-02T20:06:15.581196+00:00
1
false
![image.png](https://assets.leetcode.com/users/images/4f62472a-044d-4423-877c-d74aa6f6409e_1743624245.204129.png) # Complexity - Time complexity: <!-- Add your time complexity here, e.g. $$O(n)$$ --> O(n) - Space complexity: <!-- Add your space complexity here, e.g. $$O(n)$$ --> O(1) # Code ```cpp [] class So...
0
0
['String', 'C++']
0
reverse-degree-of-a-string
Unique Approach | hashing
unique-approach-hashing-by-mr_ramzan-n77a
Code
mr_ramzan
NORMAL
2025-04-02T17:17:14.427525+00:00
2025-04-02T17:17:14.427525+00:00
1
false
# Code ```cpp [] class Solution { public: int reverseDegree(string s) { unordered_map<char,int>map; for(char ch='a';ch<='z';ch++) map[ch]= 'z'-ch+1; int sum=0; for(int i=0;i<s.length();i++){ sum+=(map[s[i]]*(i+1)); } return sum; } }; ```
0
0
['Hash Table', 'String', 'C++']
0
reverse-degree-of-a-string
C++ Solution for Reverse Degree of a String
c-solution-for-reverse-degree-of-a-strin-mxqa
IntuitionThe problem likely involves transforming a string by calculating a "reverse degree." The goal is to map each character to its reverse position in the E
_tarunkr_chauhan
NORMAL
2025-04-02T10:36:01.629945+00:00
2025-04-02T10:36:01.629945+00:00
2
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> The problem likely involves transforming a string by calculating a "reverse degree." The goal is to map each character to its reverse position in the English alphabet ('a' becomes 26, 'b' becomes 25, etc.) and weight each character's revers...
0
0
['C++']
0
reverse-degree-of-a-string
esay java code of beginers!!!!!!!!!!!!!!!!
esay-java-code-of-beginers-by-churchill0-js0k
IntuitionApproachComplexity Time complexity: Space complexity: Code
CHURCHILL04
NORMAL
2025-04-02T10:00:48.302676+00:00
2025-04-02T10:00:48.302676+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
['Java']
0
reverse-degree-of-a-string
Python fast one-line solution
python-fast-one-line-solution-by-redberr-l9oz
Code
redberry33
NORMAL
2025-04-02T07:08:52.987723+00:00
2025-04-02T07:08:52.987723+00:00
6
false
# Code ```python3 [] class Solution: def reverseDegree(self, s: str) -> int: return reduce(lambda acc, enum: acc + (enum[0] + 1) * (123 - ord(enum[1])), enumerate(s), 0) ```
0
0
['Python3']
0
reverse-degree-of-a-string
3498 - Reverse Degree Of A String
3498-reverse-degree-of-a-string-by-prati-chxn
Intuitionresult += (26 - (s.charAt(i) - 'a')) * (i + 1);Approachresult += (s.charAt(i) - 123) * -(i + 1);Complexity Time complexity: Space complexity: Code
pratik_solanki
NORMAL
2025-04-02T06:11:13.172980+00:00
2025-04-02T06:11:13.172980+00:00
3
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> result += (26 - (s.charAt(i) - 'a')) * (i + 1); # Approach <!-- Describe your approach to solving the problem. --> result += (s.charAt(i) - 123) * -(i + 1); # Complexity - Time complexity: <!-- Add your time complexity here, e.g. $$O(n)$$...
0
0
['Java']
0
reverse-degree-of-a-string
Java Easy Solution
java-easy-solution-by-iamsd-szpc
Code
iamsd_
NORMAL
2025-04-02T05:31:25.396453+00:00
2025-04-02T05:31:25.396453+00:00
3
false
# Code ```java [] class Solution { public int reverseDegree(String s) { int i = 26; Map<String, Integer> map = new HashMap<>(); for (char c = 'a'; c <= 'z'; c++) { map.put(String.valueOf(c), i); i--; } int sum = 0; String[] srr = s.split(...
0
0
['Java']
0
reverse-degree-of-a-string
🔄📖 Reverse Alphabet Math Madness! 🔢🤯Simple Logic Behind the Code 🤓➡️💡PYTHON
reverse-alphabet-math-madness-simple-log-hp51
IntuitionThe problem requires calculating a weighted sum where each letter's reverse alphabet value is multiplied by its 1-based index in the string. Since lett
Shahin1212
NORMAL
2025-04-02T04:41:08.554637+00:00
2025-04-02T04:41:08.554637+00:00
3
false
# Intuition The problem requires calculating a weighted sum where each letter's **reverse alphabet value** is multiplied by its **1-based index** in the string. Since letter values are fixed, we can **precompute** them in a dictionary and efficiently compute the sum in a **single pass**. # Approach 1. **Create a dic...
0
0
['Python3']
0
reverse-degree-of-a-string
Java 100% Faster Solution
java-100-faster-solution-by-tbekpro-p8vb
Complexity Time complexity: O(N) Space complexity: O(1) Code
tbekpro
NORMAL
2025-04-01T19:11:57.318045+00:00
2025-04-01T19:11:57.318045+00:00
4
false
# Complexity - Time complexity: O(N) - Space complexity: O(1) # Code ```java [] class Solution { public int reverseDegree(String s) { int result = 0; for (int i = 0; i < s.length(); i++) { int score = (26 - (s.charAt(i) - 'a')) * (i + 1); result += score; } r...
0
0
['Java']
0
reverse-degree-of-a-string
reverseIndexString
reverseindexstring-by-aditya_211-gpo4
IntuitionApproachComplexity Time complexity: Space complexity: Code
Aditya_211
NORMAL
2025-04-01T17:35:43.710724+00:00
2025-04-01T17:35:43.710724+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
['Java']
0
maximum-product-of-three-numbers
Java O(1) space O(n) time solution beat 100%
java-o1-space-on-time-solution-beat-100-wung3
Simply find out the three largest numbers and the two smallest numbers using one pass.\n\n public int maximumProduct(int[] nums) {\n int max1 = Intege
dreamchase
NORMAL
2017-06-25T17:10:41.283000+00:00
2018-10-16T15:01:25.567757+00:00
53,928
false
Simply find out the three largest numbers and the two smallest numbers using one pass.\n```\n public int maximumProduct(int[] nums) {\n int max1 = Integer.MIN_VALUE, max2 = Integer.MIN_VALUE, max3 = Integer.MIN_VALUE, min1 = Integer.MAX_VALUE, min2 = Integer.MAX_VALUE;\n for (int n : nums) {\n ...
315
2
[]
47
maximum-product-of-three-numbers
[Python] O(N) and 1 line
python-on-and-1-line-by-lee215-g80f
My first solution using sort\n\ndef maximumProduct(self, nums):\n nums.sort()\n return max(nums[-1] * nums[-2] * nums[-3], nums[0] * nums[1] * num
lee215
NORMAL
2017-06-28T19:15:59.247000+00:00
2018-09-02T20:50:07.670914+00:00
29,058
false
My first solution using ```sort```\n````\ndef maximumProduct(self, nums):\n nums.sort()\n return max(nums[-1] * nums[-2] * nums[-3], nums[0] * nums[1] * nums[-1])\n`````\nI found a exactly same solution in discuss. Anyway, O(NlogN) is not adorable and O(N) is possible.\n````\ndef maximumProduct(self, nums...
148
8
[]
21
maximum-product-of-three-numbers
General solution for any K
general-solution-for-any-k-by-kale_kale_-gyt1
This is the first solution that can be used to solve the problem, Maximum Prodoct of K Numbers.\nHope it can help others when encountering a follow up question.
kale_kale_kale
NORMAL
2018-05-05T02:49:19.018294+00:00
2018-09-25T06:07:12.515578+00:00
6,183
false
This is the first solution that can be used to solve the problem, Maximum Prodoct of K Numbers.\nHope it can help others when encountering a follow up question.\n```\n public int maximumProduct(int[] nums) {\n Arrays.sort(nums);\n // if signs of the minimum and maximum number are the same, simply retur...
74
0
[]
11
maximum-product-of-three-numbers
[C++] Two Solutions
c-two-solutions-by-pankajgupta20-6wyf
Sorting Solution\n\tclass Solution {\n\tpublic:\n\t\tint maximumProduct(vector& nums) {\n\t\t\tint n = nums.size();\n\t\t\tsort(nums.begin(), nums.end());\n\t\t
pankajgupta20
NORMAL
2021-05-13T12:42:16.670192+00:00
2021-05-13T12:43:19.470746+00:00
11,171
false
##### Sorting Solution\n\tclass Solution {\n\tpublic:\n\t\tint maximumProduct(vector<int>& nums) {\n\t\t\tint n = nums.size();\n\t\t\tsort(nums.begin(), nums.end());\n\t\t\treturn max(nums[n - 1] * nums[n - 2] * nums[n - 3], nums[0] * nums[1] * nums[n - 1]);\n\t\t}\n\t};\n##### Without Sorting Solution\n\tclass Solutio...
60
3
['C', 'Sorting', 'C++']
4
maximum-product-of-three-numbers
Java Easy AC...
java-easy-ac-by-leiyu-j91a
\n public int maximumProduct(int[] nums) {\n \n Arrays.sort(nums);\n //One of the Three Numbers is the maximum value in the array.\n\n
leiyu
NORMAL
2017-06-25T03:00:34.488000+00:00
2018-10-16T04:15:09.312973+00:00
17,561
false
```\n public int maximumProduct(int[] nums) {\n \n Arrays.sort(nums);\n //One of the Three Numbers is the maximum value in the array.\n\n int a = nums[nums.length - 1] * nums[nums.length - 2] * nums[nums.length - 3];\n int b = nums[0] * nums[1] * nums[nums.length - 1];\n ...
59
3
[]
11
maximum-product-of-three-numbers
easiest two lines of code#python3
easiest-two-lines-of-codepython3-by-moha-m2dp
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
Mohammad_tanveer
NORMAL
2023-03-18T05:04:19.034291+00:00
2023-03-18T05:04:19.034336+00:00
5,698
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)$$ --...
50
0
['Python3']
4
maximum-product-of-three-numbers
Share my python solution: one pass, O(n) time O(1) space
share-my-python-solution-one-pass-on-tim-sl33
\n max1,max2,max3,min1,min2 = float('-Inf'),float('-Inf'),float('-Inf'),float('Inf'),float('Inf')\n for num in nums:\n if num >= max1:\
kiiiid
NORMAL
2017-07-16T05:06:19.580000+00:00
2018-10-25T06:15:52.574047+00:00
5,208
false
```\n max1,max2,max3,min1,min2 = float('-Inf'),float('-Inf'),float('-Inf'),float('Inf'),float('Inf')\n for num in nums:\n if num >= max1:\n max3,max2,max1 = max2,max1,num\n elif num >= max2:\n max3,max2 = max2,num\n elif num > max3:\n ...
44
1
[]
5
maximum-product-of-three-numbers
C++ DP solution
c-dp-solution-by-wofainta-i4q2
O(n) time, O(1) space\n\nclass Solution {\npublic:\n int maximumProduct(vector<int>& nums) {\n int f[2][4], i, j;\n f[0][0] = f[1][0] = 1;\n
wofainta
NORMAL
2018-09-24T21:59:08.737154+00:00
2018-10-14T18:49:25.282190+00:00
4,733
false
O(n) time, O(1) space\n```\nclass Solution {\npublic:\n int maximumProduct(vector<int>& nums) {\n int f[2][4], i, j;\n f[0][0] = f[1][0] = 1;\n for (j = 3; j > 0; --j) {\n f[0][j] = INT_MIN;\n f[1][j] = INT_MAX;\n } \n \n for (i = 0; i < nums.siz...
39
1
[]
6
maximum-product-of-three-numbers
Time: O(n), Space: O(1)
time-on-space-o1-by-riyakushwaha-iso1
Base: Maximum product of three numbers is possible only when all three numbers are positive or two numbers are negative and one is positive.\n\nApproach1: \n1.
riyakushwaha
NORMAL
2021-12-03T10:53:25.994318+00:00
2021-12-03T10:53:25.994347+00:00
3,360
false
Base: Maximum product of three numbers is possible only when all three numbers are positive or two numbers are negative and one is positive.\n\nApproach1: \n1. Sort the array, so three max numbers are in the end of the array, two negative numbers whose product will be max will be on the start of the array.\n2. return m...
33
1
['Java']
2
maximum-product-of-three-numbers
C++ Solution with explanation
c-solution-with-explanation-by-princeerj-881v
Either product of 3 biggest positive values will be maxProduct or if there are negative values then pick the 2 biggest negative values and multiply with biggest
princeerjain
NORMAL
2017-06-25T03:03:49.183000+00:00
2018-08-17T04:37:24.140252+00:00
9,395
false
Either product of 3 biggest positive values will be maxProduct or if there are negative values then pick the 2 biggest negative values and multiply with biggest positive value\n\nSort the Array and compare above mentioned products\n\n\n int maximumProduct(vector<int>& nums) {\n sort(nums.begin(), nums.end());...
31
2
[]
7
maximum-product-of-three-numbers
Begineer Friendly || O(nlogn) -> O(n)
begineer-friendly-onlogn-on-by-himanshuc-06t1
IDEA : Product is going to be maximum if we take product of top 3 maximum number. and also negative*negative became Positive so we will also consider a combinat
himanshuchhikara
NORMAL
2021-03-19T15:06:26.591642+00:00
2021-03-19T15:29:07.187379+00:00
1,215
false
IDEA : Product is going to be maximum if we take product of top 3 maximum number. and also **negative*negative became Positive** so we will also consider a combination of 2 most negative with maximum .\nanswer = Math.max(max1*max2*max3,max1*min1*min2)\n**min1:** minimum element of array\n**min2:** 2nd minimum element o...
30
0
[]
0
maximum-product-of-three-numbers
✅✅Two Java Solution || Easy Explanation 🔥 🔥
two-java-solution-easy-explanation-by-ri-ydyb
Approach 1\nThe code starts by sorting the input array, "nums," in ascending order using the Arrays.sort() method. Sorting the array allows us to consider diffe
rirefat
NORMAL
2023-05-30T16:52:09.456002+00:00
2023-05-30T16:52:09.456047+00:00
6,349
false
# Approach 1\nThe code starts by sorting the input array, "nums," in ascending order using the **Arrays.sort()** method. Sorting the array allows us to consider different cases and calculate the maximum product.\n\nThe next step involves calculating two potential maximum products:\n\n1. "case1" represents the product o...
29
0
['Array', 'Math', 'Sorting', 'Java']
2
maximum-product-of-three-numbers
Beats 100% of users with C++ || Step By Step Explain || Easy to Understand || Best Approach ||
beats-100-of-users-with-c-step-by-step-e-duu1
Abhiraj Pratap Singh\n\n---\n\n# if you like the solution please UPVOTE it...\n\n---\n\n# Intuition\n Describe your first thoughts on how to solve this problem.
abhirajpratapsingh
NORMAL
2024-02-16T18:41:02.047144+00:00
2024-02-16T18:41:02.047173+00:00
3,627
false
# Abhiraj Pratap Singh\n\n---\n\n# if you like the solution please UPVOTE it...\n\n---\n\n# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n- The problem asks for the maximum product that can be obtained by multiplying three integers from the given array. To achieve this, we can observe ...
28
0
['Array', 'Math', 'Sorting', 'C++']
3
maximum-product-of-three-numbers
Python O(n) time O(1) space
python-on-time-o1-space-by-leeteatsleep-0nx7
\nclass Solution:\n def maximumProduct(self, nums: List[int]) -> int:\n smallestTwo = [float(\'inf\')]*2\n largestThree = [float(\'-inf\')]*3\n
leeteatsleep
NORMAL
2020-07-13T20:21:05.997910+00:00
2020-07-13T20:21:05.997946+00:00
4,851
false
```\nclass Solution:\n def maximumProduct(self, nums: List[int]) -> int:\n smallestTwo = [float(\'inf\')]*2\n largestThree = [float(\'-inf\')]*3\n for num in nums:\n if num <= smallestTwo[0]:\n smallestTwo[0] = num\n smallestTwo.sort(reverse=True)\n ...
25
1
['Python', 'Python3']
2
maximum-product-of-three-numbers
Java solution with sorting
java-solution-with-sorting-by-2020-pkkg
In a sorted array, the maximum product will be either the last three largest elements or the first two (negative elements) multiplied by the last (largest) elem
2020
NORMAL
2020-05-27T00:52:42.079298+00:00
2020-05-27T00:52:42.079345+00:00
2,020
false
In a sorted array, the maximum product will be either the last three largest elements or the first two (negative elements) multiplied by the last (largest) element.\n```\nclass Solution {\n public int maximumProduct(int[] nums) {\n Arrays.sort(nums);\n int len = nums.length;\n \n return M...
23
0
['Java']
3
maximum-product-of-three-numbers
2-liner Python solution with explanations
2-liner-python-solution-with-explanation-nxgw
There are two possible ways to get the largest number:\n1. biggest number * 2nd biggest * 3rd biggest\n2. biggest number * smallest number * 2nd smallest number
yangshun
NORMAL
2017-06-25T04:41:36.936000+00:00
2018-10-14T18:51:34.465828+00:00
2,667
false
There are two possible ways to get the largest number:\n1. biggest number * 2nd biggest * 3rd biggest\n2. biggest number * smallest number * 2nd smallest number (if the two smallest numbers are negative)\n\nThis formula will also work in the case there are all negative numbers, in which the smallest negative number wil...
22
0
[]
1
maximum-product-of-three-numbers
JavaScript O(n) time (1) space
javascript-on-time-1-space-by-shengdade-zrdr
javascript\n/**\n * @param {number[]} nums\n * @return {number}\n */\nvar maximumProduct = function(nums) {\n let max1 = -Infinity;\n let max2 = -Infinity;\n
shengdade
NORMAL
2020-02-06T21:59:07.898885+00:00
2020-02-06T21:59:07.898923+00:00
2,547
false
```javascript\n/**\n * @param {number[]} nums\n * @return {number}\n */\nvar maximumProduct = function(nums) {\n let max1 = -Infinity;\n let max2 = -Infinity;\n let max3 = -Infinity;\n let min2 = Infinity;\n let min1 = Infinity;\n for (let i = 0; i < nums.length; i++) {\n if (nums[i] > max1) {\n [max1, ma...
20
0
['JavaScript']
2
maximum-product-of-three-numbers
✅ EASIEST || 💯 BEAST || 🧑‍💻 3 LINES CODE || ⭐ JAVA
easiest-beast-3-lines-code-java-by-mukun-93wb
\n\n# Intuition\n Describe your first thoughts on how to solve this problem. \nThe goal is to find the maximum product of three numbers in the array. There are
mukund_rakholiya
NORMAL
2024-09-27T11:28:49.418833+00:00
2024-09-27T11:28:49.418870+00:00
4,341
false
```\n```\n# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n**The goal is to find the maximum product of three numbers in the array. There are two potential scenarios:**\n1. The three largest numbers yield the maximum product.\n2. In cases where there are negative numbers, the product of...
19
0
['Array', 'Math', 'Sorting', 'Java']
2
maximum-product-of-three-numbers
c++ solution | with proper explaination | O(n) solution
c-solution-with-proper-explaination-on-s-uo5e
The basic approach that we all will first click is that just find the largest three numbers from the given vector nums and calculate the product-> and this wor
kritika_12
NORMAL
2021-07-03T15:31:53.497150+00:00
2021-07-03T15:59:01.277368+00:00
1,536
false
The **basic approach** that we all will first click is that just find the largest three numbers from the given vector nums and calculate the product-> and this works to some extent only if the given vector nums is having positive elements\nbut what if there are negative elements too this basic approach will fail hence...
16
0
['C', 'C++']
1
maximum-product-of-three-numbers
👏Beats 98.57% of users with Java || ✅Simple & Easy Well Explained Solution without Sorting 🔥💥
beats-9857-of-users-with-java-simple-eas-qls0
Intuition\nFind First 3 Maximum number and 2 minimum numbers and return maximum of 3 max numbers or 2 min number multiply max number.\n\n# I Think This Can Help
Rutvik_Jasani
NORMAL
2024-04-04T07:48:55.134122+00:00
2024-04-04T07:48:55.134147+00:00
2,287
false
# Intuition\nFind First 3 Maximum number and 2 minimum numbers and return maximum of 3 max numbers or 2 min number multiply max number.\n\n# I Think This Can Help You(For Proof Click on the Image)\n[![Screenshot 2024-02-24 232407.png](https://assets.leetcode.com/users/images/ca61190e-31c0-413b-8b2b-b1632beae1ca_1712215...
15
0
['Array', 'Math', 'Sorting', 'Java']
1
maximum-product-of-three-numbers
JAVA | USED JUST LOGIC✔EXPLAINATION
java-used-just-logicexplaination-by-rj07-ozym
\nclass Solution {\n public int maximumProduct(int[] nums) {\n Arrays.sort(nums);\n int n = nums.length;\n int ans = Integer.MIN_VALUE;\
rj0711
NORMAL
2022-09-08T18:00:21.166314+00:00
2022-09-12T10:02:33.125057+00:00
3,769
false
```\nclass Solution {\n public int maximumProduct(int[] nums) {\n Arrays.sort(nums);\n int n = nums.length;\n int ans = Integer.MIN_VALUE;\n \n ans = Math.max(nums[0]*nums[1]*nums[n-1], nums[n-1]*nums[n-2]*nums[n-3]);\n \n return ans;\n }\n}\n```
14
0
['Math', 'Java']
2
maximum-product-of-three-numbers
Python O( n log n ) sol. based on sorting. run-time 80%+
python-o-n-log-n-sol-based-on-sorting-ru-lrqr
Python O( n log n ) sol. based on sorting\n\n\nclass Solution:\n def maximumProduct(self, nums: List[int]) -> int:\n\n # sort the nums with ascending
brianchiang_tw
NORMAL
2020-01-06T06:11:22.197875+00:00
2020-01-06T06:11:22.197921+00:00
1,536
false
Python O( n log n ) sol. based on sorting\n\n```\nclass Solution:\n def maximumProduct(self, nums: List[int]) -> int:\n\n # sort the nums with ascending order \n nums.sort()\n \n # for possible solution_#1: First three largest positive numbers\n candidate_1 = nums[-1] * nums...
13
0
['Sorting', 'Python']
1
maximum-product-of-three-numbers
Easy solution for js
easy-solution-for-js-by-ahmedrithas48-1gvj
Approach\n Describe your approach to solving the problem. \n- First we have to sort it out by descending.\n- We have two case to get max number with three numbe
ahmedrithas48
NORMAL
2024-04-05T12:38:39.582654+00:00
2024-04-05T12:38:39.582679+00:00
700
false
# Approach\n<!-- Describe your approach to solving the problem. -->\n- First we have to sort it out by descending.\n- We have two case to get max number with three numbers.\n- we have two cases -\n### If array contains only postive/negative numbers \n- take first 3 numbers .\n- for example if we sort this [4,2,15,6] de...
12
0
['JavaScript']
0
maximum-product-of-three-numbers
Simple Java || C++ Code ☠️
simple-java-c-code-by-abhinandannaik1717-9wy6
java []\nclass Solution {\n public int maximumProduct(int[] nums) {\n int n = nums.length;\n Arrays.sort(nums);\n int m1 = nums[n-1]*num
abhinandannaik1717
NORMAL
2024-06-25T16:57:33.077575+00:00
2024-06-25T16:57:33.077601+00:00
3,059
false
```java []\nclass Solution {\n public int maximumProduct(int[] nums) {\n int n = nums.length;\n Arrays.sort(nums);\n int m1 = nums[n-1]*nums[n-2]*nums[n-3];\n int m2 = nums[0]*nums[1]*nums[n-1];\n if(m1>m2){\n return m1;\n }\n else{\n return m2;\...
10
0
['Java']
4
maximum-product-of-three-numbers
2 Lines of Code-->Powerful Heap Concept
2-lines-of-code-powerful-heap-concept-by-uk9p
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
GANJINAVEEN
NORMAL
2023-03-18T05:36:17.220860+00:00
2023-03-18T05:36:17.220895+00:00
2,056
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)$$ --...
10
0
['Python3']
0
maximum-product-of-three-numbers
[Java] 3-pointer Method {99.73%} faster than orther solutions
java-3-pointer-method-9973-faster-than-o-2r7o
If you do like solution please upvote it , so it could be helpful to orthers\nSorting Method :\n\nclass Solution {\n public int maximumProduct(int[] nums) {\
salmanshaikssk007
NORMAL
2021-12-09T06:44:30.211296+00:00
2021-12-09T07:04:42.539924+00:00
945
false
**If you do like solution please upvote it , so it could be helpful to orthers**\nSorting Method :\n```\nclass Solution {\n public int maximumProduct(int[] nums) {\n \n Arrays.sort(nums);\n int n = nums.length;\n return Math.max(nums[n-1]*nums[n-2]*nums[n-3] , nums[0]*nums[1]*nums[n-1]);\n...
10
0
['Sorting', 'Java']
0
maximum-product-of-three-numbers
🏆💢💯 Faster✅💯 Lesser🧠 🎯 C++✅Python3🐍✅Java✅C✅Python🐍✅💥🔥💫Explained☠💥🔥 Beats 💯
faster-lesser-cpython3javacpythonexplain-69nu
Intuition\n\n\n\n\n\nC++ []\nclass Solution {\npublic:\n int maximumProduct(vector<int>& nums) {\n sort(nums.begin(), nums.end());\n int n = nu
Edwards310
NORMAL
2024-05-29T03:01:36.719656+00:00
2024-05-29T03:01:36.719673+00:00
3,337
false
# Intuition\n![0ehh83fsnh811.jpg](https://assets.leetcode.com/users/images/0d6bf656-8dfc-42b6-83f6-9cc3796ce182_1716951518.6194615.jpeg)\n![Screenshot 2024-05-29 082750.png](https://assets.leetcode.com/users/images/bf18f4aa-9835-4861-b2e3-80b5c3721fd8_1716951527.686214.png)\n![Screenshot 2024-05-29 082756.png](https://...
9
0
['Array', 'Math', 'C', 'Sorting', 'Python', 'C++', 'Java', 'Python3']
5
maximum-product-of-three-numbers
JavaScript solution
javascript-solution-by-jagdish7908-j7mw
\n/**\n * @param {number[]} nums\n * @return {number}\n */\nvar maximumProduct = function(nums) {\n nums = nums.sort((a,b) => b-a)\n return Math.max(nums[
jagdish7908
NORMAL
2021-10-24T08:25:10.839421+00:00
2021-10-24T08:26:54.493698+00:00
1,491
false
```\n/**\n * @param {number[]} nums\n * @return {number}\n */\nvar maximumProduct = function(nums) {\n nums = nums.sort((a,b) => b-a)\n return Math.max(nums[0]*nums[1]*nums[2], nums[nums.length-1]*nums[nums.length-2]*nums[0])\n};\n```
9
0
['Sorting', 'JavaScript']
2
maximum-product-of-three-numbers
C++ {Speed,Mem} = {O(n), O(1)} simple
c-speedmem-on-o1-simple-by-crab_10legs-c2c1
\nclass Solution {\npublic:\n int maximumProduct(vector<int>& nums) {\n \n \n int min_c = INT_MAX;\n int min_n = INT_MAX;\n
crab_10legs
NORMAL
2020-07-19T05:31:17.445005+00:00
2020-07-19T05:35:34.442758+00:00
1,529
false
```\nclass Solution {\npublic:\n int maximumProduct(vector<int>& nums) {\n \n \n int min_c = INT_MAX;\n int min_n = INT_MAX;\n int max_c = INT_MIN;\n int max_n = INT_MIN;\n int max_n_n = INT_MIN;\n \n for(int i=0; i < nums.size(); i++){\n // 2...
9
1
['C', 'C++']
3
maximum-product-of-three-numbers
Best Solution in C++ for Trees 🚀 || 100% working
best-solution-in-c-for-trees-100-working-8ykh
IntuitionTo find the maximum product, we should consider the largest numbers. But what if the array has negative numbers? 🤔 Negative numbers can flip the result
BladeRunner150
NORMAL
2024-12-31T06:05:32.222778+00:00
2024-12-31T06:05:32.222778+00:00
1,554
false
# Intuition To find the maximum product, we should consider the largest numbers. But what if the array has negative numbers? 🤔 Negative numbers can flip the result! So, we also check the smallest two negatives multiplied with the largest positive number. 🚀 # Approach 1. Sort the array. 🧹 2. Compare: - Th...
8
0
['Array', 'Math', 'Sorting', 'C++']
0
maximum-product-of-three-numbers
[Python3] O(N) and O(NlogN) solutions
python3-on-and-onlogn-solutions-by-ye15-yoif
The maximum can be one of below \n1) multiplying the three largest number;\n2) multiplying the largest number with two negative numbers largest in magnitude. \n
ye15
NORMAL
2019-08-12T03:02:50.896669+00:00
2020-06-29T19:49:20.721427+00:00
1,134
false
The maximum can be one of below \n1) multiplying the three largest number;\n2) multiplying the largest number with two negative numbers largest in magnitude. \n\nSo to loop through the list and keep track of the three largest and two smallest numbers is enough to compute the maximum. \n\n```\nclass Solution:\n def m...
8
0
['Python3']
1
maximum-product-of-three-numbers
Python, Straightforward with Explanation
python-straightforward-with-explanation-g0i4c
Sort the array. Any "middle" numbers not in the first 3 or last 3 cannot be used in the final answer. If we are using a middle number, it must have both a lef
awice
NORMAL
2017-06-25T03:06:12.043000+00:00
2017-06-25T03:06:12.043000+00:00
4,850
false
Sort the array. Any "middle" numbers not in the first 3 or last 3 cannot be used in the final answer. If we are using a middle number, it must have both a left-neighbor and a right-neighbor, and switching to one of these neighbors will increase the product. \n\n```\ndef maximumProduct(self, A):\n A.sort()\n if ...
8
0
[]
2
maximum-product-of-three-numbers
🎯SUPER EASY FOR BEGINNERS 👏
super-easy-for-beginners-by-vigneshvaran-32qf
Code
vigneshvaran0101
NORMAL
2025-02-03T17:30:37.394114+00:00
2025-02-03T17:30:37.394114+00:00
1,115
false
# Code ```python3 [] class Solution: def maximumProduct(self, nums: List[int]) -> int: a = sorted(nums) return max(a[-1]*a[-2]*a[-3], a[0]*a[1]*a[-1]) # nums[-1]*nums[-2]*nums[-3] gives the product of 3 maximum number (positive) # nums[0]*nums[1]*nums[-1] gives the produ...
7
0
['Python3']
0
maximum-product-of-three-numbers
Python O(NlogN) Solution Beat 100%
python-onlogn-solution-beat-100-by-tliu7-64os
Sort the array first, then check the product of (3 largest positive numbers) and (2 largest negative numbers and largest positive numbers).\n\n\nclass Solution:
tliu77
NORMAL
2019-11-29T02:55:45.130846+00:00
2019-11-29T02:56:02.189072+00:00
1,307
false
Sort the array first, then check the product of (3 largest positive numbers) and (2 largest negative numbers and largest positive numbers).\n\n```\nclass Solution:\n def maximumProduct(self, nums: List[int]) -> int:\n nums.sort()\n return max(nums[0]*nums[1]*nums[-1], nums[-1]*nums[-2]*nums[-3])\n```
7
0
['Python', 'Python3']
0
maximum-product-of-three-numbers
Java sort, 3 lines
java-sort-3-lines-by-cubicon-otm8
\npublic int maximumProduct(int[] a) {\n Arrays.sort(a);\n int len = a.length;\n return Math.max(a[0] * a[1] * a[len-1], a[len-1] * a[len-2
Cubicon
NORMAL
2017-06-25T03:07:39.140000+00:00
2017-06-25T03:07:39.140000+00:00
1,499
false
```\npublic int maximumProduct(int[] a) {\n Arrays.sort(a);\n int len = a.length;\n return Math.max(a[0] * a[1] * a[len-1], a[len-1] * a[len-2] * a[len-3]);\n\n }\n```
7
2
[]
3
maximum-product-of-three-numbers
Easy To Understand | 3 Lines 🚀🚀
easy-to-understand-3-lines-by-sanket_des-07uh
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Use this test case for better understanding --> [-100,-98,-1,2,3,4]\n\n#
The_Eternal_Soul
NORMAL
2023-10-17T13:03:42.620490+00:00
2023-10-17T13:03:42.620509+00:00
2,952
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n Use this test case for better understanding --> [-100,-98,-1,2,3,4]\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 comple...
6
0
['Array', 'Math', 'C', 'Sorting', 'C++', 'Java', 'Python3']
0
maximum-product-of-three-numbers
Maximum Product of Three Numbers Solution in C++
maximum-product-of-three-numbers-solutio-vrju
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
The_Kunal_Singh
NORMAL
2023-05-02T16:52:49.674136+00:00
2023-05-02T16:52:49.674179+00:00
1,450
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(nlogn)\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O...
6
0
['C++']
0
maximum-product-of-three-numbers
Python O(n) solution || NO fancy one liner
python-on-solution-no-fancy-one-liner-by-gasn
\n\n# Complexity\n- Time complexity: O(n)\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
Augus7
NORMAL
2023-01-31T16:06:52.400746+00:00
2023-01-31T16:09:57.733218+00:00
2,325
false
\n\n# Complexity\n- Time complexity: $$O(n)$$\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```\nclass Solution:\n def maximumProduct(self, vec: List[int]) -> int:\n if len(vec) == 3:\n retur...
6
0
['Array', 'Math', 'Python3']
3
maximum-product-of-three-numbers
Most Efficient and Optimized || Fully Explained || O(n) || Java😊
most-efficient-and-optimized-fully-expla-hsz6
\n# Approach :\n\n1. Scan the array and compute Maximum, second maximum and third maximum element present in the array.\n2. Scan the array and compute Minimum a
N7_BLACKHAT
NORMAL
2022-12-05T12:46:43.214826+00:00
2022-12-05T12:46:43.214867+00:00
1,850
false
\n# Approach :\n\n1. Scan the array and compute Maximum, second maximum and third maximum element present in the array.\n2. Scan the array and compute Minimum and second minimum element present in the array.\n3. Return the maximum of product of Maximum, second maximum and third maximum and product of Minimum, second mi...
6
0
['Array', 'Math', 'Java']
2
maximum-product-of-three-numbers
c++ | Two approaches | Fast solution | Asked in interview
c-two-approaches-fast-solution-asked-in-8ie8y
\n\n\n////Sorting method\n\nclass Solution {\npublic:\n int maximumProduct(vector<int>& a) {\n sort(a.begin(),a.end());\n int n=a.size();\n
srv-er
NORMAL
2021-09-28T01:27:07.099334+00:00
2021-09-28T01:27:07.099460+00:00
916
false
\n\n```\n////Sorting method\n\nclass Solution {\npublic:\n int maximumProduct(vector<int>& a) {\n sort(a.begin(),a.end());\n int n=a.size();\n return max(a[n-1]*a[n-2]*a[n-3],max(a[0]*a[1]*a[2],a[0]*a[1]*a[n-1]));\n \n }\n};\n\n////linear solution \n\nclass Solution {\npublic:\n int...
6
0
['C', 'Sorting']
0
maximum-product-of-three-numbers
Java || Easy To Understand || nlog(n)
java-easy-to-understand-nlogn-by-vishal_-2u90
Code\n\nclass Solution {\n public int maximumProduct(int[] nums) {\n int n=nums.length;\n Arrays.sort(nums);\n return Math.max(nums[0]*n
vishal_niet
NORMAL
2023-03-21T05:27:20.946538+00:00
2023-03-21T05:27:20.946585+00:00
1,741
false
# Code\n```\nclass Solution {\n public int maximumProduct(int[] nums) {\n int n=nums.length;\n Arrays.sort(nums);\n return Math.max(nums[0]*nums[1]*nums[n-1],nums[n-1]*nums[n-2]*nums[n-3]);\n // return max_product;\n \n }\n}\n```
5
0
['Sorting', 'Java']
0
maximum-product-of-three-numbers
2 Approach 🔥 || Easy C++ ✅ Solution || Brute Force [Sorting] and Optimized Approach ⚡
2-approach-easy-c-solution-brute-force-s-q0lm
Hint\n\nHint 1: Scan the array and compute Maximum, second maximum, third maximum element, and minimum and second minimum element present in the array.\n\nHint
Vishal_Singh7
NORMAL
2023-03-10T09:21:38.183202+00:00
2023-03-10T09:21:38.183254+00:00
721
false
# Hint\n\n**Hint 1:** Scan the array and compute Maximum, second maximum, third maximum element, and minimum and second minimum element present in the array.\n\n**Hint 2:** The answer will always be maximum of product of Maximum, second maximum and third maximum and product of Minimum, second minimum and Maximum elemen...
5
0
['Sorting', 'C++']
1
maximum-product-of-three-numbers
Easiest C++ Solution
easiest-c-solution-by-harsh_1818-kvfk
Intuition\nwe will sort the vector.\n\n# Approach\nAfter sorting answer will always be product of first 2numbers and last number or last 3numbers.\n# Complexity
harsh_1818
NORMAL
2023-02-02T09:26:42.901282+00:00
2023-02-02T09:26:42.901335+00:00
2,132
false
# Intuition\nwe will sort the vector.\n\n# Approach\nAfter sorting answer will always be product of first 2numbers and last number or last 3numbers.\n# Complexity\n- Time complexity:\nnlogn\n\n- Space complexity:\nO(1)\n\n# Code\n```\nclass Solution {\npublic:\n int maximumProduct(vector<int>& nums) {\n\n sor...
5
0
['C++']
1
maximum-product-of-three-numbers
4 Lines of Python code
4-lines-of-python-code-by-prernaarora221-132a
```\nclass Solution:\n def maximumProduct(self, nums: List[int]) -> int:\n nums.sort()\n l1 = nums[-1]nums[-2]nums[-3]\n l2 = nums[0]num
prernaarora221
NORMAL
2022-06-06T18:23:04.847104+00:00
2022-06-06T18:23:04.847176+00:00
2,165
false
```\nclass Solution:\n def maximumProduct(self, nums: List[int]) -> int:\n nums.sort()\n l1 = nums[-1]*nums[-2]*nums[-3]\n l2 = nums[0]*nums[1]*nums[-1]\n return max(l1,l2)
5
0
['Python', 'Python3']
1
maximum-product-of-three-numbers
C++ Simple and clean solution for Beginners || Brute force
c-simple-and-clean-solution-for-beginner-87kd
Please Upvote if it helped you !!!\nHappy Coding :) \n \n \n\nint maximumProduct(vector<int>& nums) \n {\n sort(nums.begin(),nums.end());\n int
rahulrajguru
NORMAL
2022-01-13T10:48:25.632376+00:00
2022-07-13T12:35:50.318519+00:00
459
false
Please Upvote if it helped you !!!\nHappy Coding :) \n \n \n```\nint maximumProduct(vector<int>& nums) \n {\n sort(nums.begin(),nums.end());\n int n=nums.size();\n int max= nums[n-1]*nums[n-2]*nums[n-3];\n if(max > nums[0]*nums[1]*nums[n-1])\n return max;\n return nums[...
5
0
['C']
1
maximum-product-of-three-numbers
C++ code with Explanation
c-code-with-explanation-by-vishal_shady2-2f87
Explanation:\nFirst we sort the array. Since the largest 3 numbers will make the largest product, we can look for the last 3 digits and multiply them. if the nu
Vishal_Shady23
NORMAL
2021-07-07T07:01:53.015764+00:00
2021-07-07T07:01:53.015792+00:00
612
false
**Explanation:**\n*First we sort the array. Since the largest 3 numbers will make the largest product, we can look for the last 3 digits and multiply them. if the number contains more than 2 negative numbers with maximum magnitide. Then their product will yield maximum value along with the largest positive number. Exam...
5
0
['C']
0
maximum-product-of-three-numbers
Java | 2ms | 99.33% faster
java-2ms-9933-faster-by-aish9-lerd
\n\nclass Solution {\n public int maximumProduct(int[] nums) {\n if(nums.length==3)\n return nums[0]*nums[1]*nums[2];\n int max1st=I
aish9
NORMAL
2021-06-09T15:14:51.174975+00:00
2021-06-09T15:14:51.175025+00:00
660
false
![image](https://assets.leetcode.com/users/images/9e06bc71-6bb9-497f-9e46-ee5d5fca5ca5_1623251680.127314.png)\n```\nclass Solution {\n public int maximumProduct(int[] nums) {\n if(nums.length==3)\n return nums[0]*nums[1]*nums[2];\n int max1st=Integer.MIN_VALUE,max2nd=Integer.MIN_VALUE,max3rd...
5
0
['Java']
1
maximum-product-of-three-numbers
python 3 with only 2 lines(easy to understand)
python-3-with-only-2-lineseasy-to-unders-ozq0
\nclass Solution:\n def maximumProduct(self, nums: List[int]) -> int:\n a = sorted(nums)\n return(max(a[-1] *a[-2]*a[-3],a[0]*a[1]*a[-1]))\n
zhuanhuan
NORMAL
2019-08-14T02:40:19.062308+00:00
2019-08-14T02:40:19.065222+00:00
1,520
false
```\nclass Solution:\n def maximumProduct(self, nums: List[int]) -> int:\n a = sorted(nums)\n return(max(a[-1] *a[-2]*a[-3],a[0]*a[1]*a[-1]))\n```
5
0
['Python', 'Python3']
1
maximum-product-of-three-numbers
JavaScript solution beat 100%
javascript-solution-beat-100-by-zhenximi-una9
\n/**\n * @param {number[]} nums\n * @return {number}\n */\nvar maximumProduct = function(nums) {\n let max1 = max2 = max3 = Number.NEGATIVE_INFINITY;\n l
zhenximi
NORMAL
2018-06-13T02:29:38.697194+00:00
2018-06-13T02:29:38.697194+00:00
747
false
```\n/**\n * @param {number[]} nums\n * @return {number}\n */\nvar maximumProduct = function(nums) {\n let max1 = max2 = max3 = Number.NEGATIVE_INFINITY;\n let min1 = min2 = Number.POSITIVE_INFINITY;\n for (var i = 0; i < nums.length; i++) {\n var n = nums[i];\n if(n >= max1) {\n max3 ...
5
0
[]
1
maximum-product-of-three-numbers
Max Product Trio: Navigating Negatives for Maximum Gain Using C++
max-product-trio-navigating-negatives-fo-lmkb
Intuition\nThe problem requires finding the maximum product of three numbers from the list. The key observation is that the maximum product could either come fr
Krishnaa2004
NORMAL
2024-09-07T13:33:39.189013+00:00
2024-09-07T13:33:39.189043+00:00
742
false
# Intuition\nThe problem requires finding the maximum product of three numbers from the list. The key observation is that the maximum product could either come from the three largest numbers or from two smallest (negative) numbers and the largest number.\n\n# Approach\n1. Sort the array.\n2. Calculate the product of th...
4
0
['C++']
0
maximum-product-of-three-numbers
Superb Logic in java and Python(Heap concept)
superb-logic-in-java-and-pythonheap-conc-t9ng
\n\n# Superb Solution in JAVA\n\nclass Solution {\n public int maximumProduct(int[] nums) {\n Arrays.sort(nums);\n int n=nums.length;\n return
GPraveen
NORMAL
2023-05-08T03:52:36.531127+00:00
2023-05-08T03:52:36.531169+00:00
1,161
false
\n\n# Superb Solution in JAVA\n```\nclass Solution {\n public int maximumProduct(int[] nums) {\n Arrays.sort(nums);\n int n=nums.length;\n return Math.max(nums[0]*nums[1]*nums[n-1],nums[n-1]*nums[n-2]*nums[n-3]); \n }\n}\n```\n# Excellent Solution in Python Using Heap Concept\n```\nclass Solution:...
4
0
['Heap (Priority Queue)', 'Java', 'Python3']
0
maximum-product-of-three-numbers
Simple C++ Solution
simple-c-solution-by-divyanshu_singh_cs-zbf3
Intuition\n Describe your first thoughts on how to solve this problem. \nFirst we sort the vector then we return the product of first 2 element and last element
Divyanshu_singh_cs
NORMAL
2023-03-10T04:19:15.737575+00:00
2023-03-10T04:19:15.737607+00:00
3,187
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nFirst we sort the vector then we return the product of first 2 element and last element or product of last three element\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add ...
4
0
['C++']
1
maximum-product-of-three-numbers
Java Easy using sorting
java-easy-using-sorting-by-shailendranir-uppq
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
shailendraniranjan771
NORMAL
2023-02-20T15:17:10.420247+00:00
2023-02-20T15:17:10.420295+00:00
398
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)$$ --...
4
0
['Java']
1
maximum-product-of-three-numbers
Maximum Product of 3 Numbers - O(n) Time Complexity
maximum-product-of-3-numbers-on-time-com-mjff
Intuition\nTo reduce the time complexity\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n- There are two approaches Brute Force App
Vanshika78
NORMAL
2023-02-02T20:44:22.105674+00:00
2023-02-02T20:44:22.105715+00:00
1,536
false
# Intuition\nTo reduce the time complexity\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n- There are two approaches Brute Force Approach and the other one is the refined one that is using sorting.\n- I have used sorting approach to reduce the time complexity. \n<!-- Describe your a...
4
0
['Array', 'Dynamic Programming', 'Sorting', 'C++']
0
maximum-product-of-three-numbers
Java Simple Solution, using Sorting
java-simple-solution-using-sorting-by-sh-01qh
Intuition\n Describe your first thoughts on how to solve this problem. \nIntuition was to sort the array and get the product\n\n# Approach\n Describe your appro
ShivaniSinghh
NORMAL
2022-12-01T23:04:28.302165+00:00
2022-12-01T23:04:28.302201+00:00
977
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nIntuition was to sort the array and get the product\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nI used sorting because we know that after sorting largest 3 elements will have maximum product or 2 leftmost eleme...
4
0
['Java']
0
maximum-product-of-three-numbers
easiest c++ soution
easiest-c-soution-by-anish25-d08e
class Solution {\npublic:\n int maximumProduct(vector<int>& nums) {\n sort(nums.rbegin(),nums.rend());\n int l=nums.size();\n if(nums[0]*n
Anish25
NORMAL
2022-11-21T07:52:10.187334+00:00
2022-11-21T07:52:10.187363+00:00
720
false
```class Solution {\npublic:\n int maximumProduct(vector<int>& nums) {\n sort(nums.rbegin(),nums.rend());\n int l=nums.size();\n if(nums[0]*nums[1]*nums[2]>nums[0]*nums[l-1]*nums[l-2]){\n return nums[0]*nums[1]*nums[2];\n }\n else{\n return nums[0]*nums[l-1]*nums[l-...
4
0
[]
1
maximum-product-of-three-numbers
python||233ms||simplest approach
python233mssimplest-approach-by-2stellon-4ocz
\t\tclass Solution:\n\t\t\tdef maximumProduct(self, a: List[int]) -> int:\n\t\t\t\ta.sort(reverse=True)\n\t\t\t\tv1=a[0]a[1]a[2]\n\t\t\t\tv2=a[0]a[-1]a[-2]\n\t\
2stellon7
NORMAL
2022-10-01T05:14:22.348948+00:00
2022-10-01T05:14:22.348982+00:00
1,316
false
\t\tclass Solution:\n\t\t\tdef maximumProduct(self, a: List[int]) -> int:\n\t\t\t\ta.sort(reverse=True)\n\t\t\t\tv1=a[0]*a[1]*a[2]\n\t\t\t\tv2=a[0]*a[-1]*a[-2]\n\t\t\t\treturn max(v1,v2)\n
4
0
['Python']
2
maximum-product-of-three-numbers
100% easy || Maximum Product of Three Numbers || C++ Solution
100-easy-maximum-product-of-three-number-13x3
\nclass Solution {\npublic:\n int maximumProduct(vector<int>& nums) {\n sort(nums.begin(),nums.end());\n int a=nums[nums.size()-1]*nums[nums.siz
StArK19
NORMAL
2022-08-25T21:16:52.734466+00:00
2022-08-25T21:16:52.734514+00:00
958
false
```\nclass Solution {\npublic:\n int maximumProduct(vector<int>& nums) {\n sort(nums.begin(),nums.end());\n int a=nums[nums.size()-1]*nums[nums.size()-2]*nums[nums.size()-3];\n int b=nums[0]*nums[1]*nums[nums.size()-1];\n return max(a,b);\n }\n \n};\n```
4
0
['C', 'C++']
0
maximum-product-of-three-numbers
C++ simplest, O(N), easy understand, no sorting
c-simplest-on-easy-understand-no-sorting-8hz4
\n//We should keep 3 biggest and 2 smallest elements of the array\n//max product is either product of 3 bigger or 2 smallest(negatives) and the biggest\nclass S
Moldoteck
NORMAL
2022-05-12T08:46:14.916492+00:00
2022-05-12T08:46:14.916518+00:00
268
false
```\n//We should keep 3 biggest and 2 smallest elements of the array\n//max product is either product of 3 bigger or 2 smallest(negatives) and the biggest\nclass Solution {\npublic:\n int maximumProduct(vector<int>& nums) {\n int max1=INT_MIN, max2=INT_MIN, max3=INT_MIN;\n int min1=INT_MAX, min2=INT_MA...
4
0
[]
0
maximum-product-of-three-numbers
C++ || 100% faster O(n) without sorting || 2 solutions ✔
c-100-faster-on-without-sorting-2-soluti-8bbi
Logic :\nMax product of three no. come from\n\t\t1. product of 3 maximum positive no.\n\t\t2. product of 2 minimum negative no. and 1 maximum positive no.\n\nSo
AJAY_MAKVANA
NORMAL
2021-07-30T09:30:30.233970+00:00
2021-08-12T15:29:42.824781+00:00
243
false
### **Logic :**\n**Max product of three no. come from**\n\t\t**1. product of `3 maximum positive no.`**\n\t\t**2. product of `2 minimum negative no.` and `1 maximum positive no.`**\n\n*So bellow **two** solution is based on this logic :)*\n\n### **1. Sort based solution**\n**TC = O(nlogn)\nSC = O(1)**\n```\nclass Solut...
4
0
[]
1
maximum-product-of-three-numbers
Javascript Solution With Explanation
javascript-solution-with-explanation-by-pi24l
Explanation :-\nExample : - [-4 ,-3, -2, -1, 60]\nWe first sort the array in increasing order\nIf the above example had all positive integers, we would have sim
gaurang9
NORMAL
2020-09-25T17:54:37.471172+00:00
2020-09-25T17:54:37.471218+00:00
451
false
Explanation :-\nExample : - [-4 ,-3, -2, -1, 60]\nWe first sort the array in increasing order\nIf the above example had all positive integers, we would have simply done the product of 3 largest numbers.\nBut since it also has negative numbers , and we know negative multiplied by negative is positive , we can consider t...
4
0
['JavaScript']
2
maximum-product-of-three-numbers
Easy JS Solution
easy-js-solution-by-hbjorbj-d8hq
\n/**\n * @param {number[]} nums\n * @return {number}\n */\nvar maximumProduct = function(nums) {\n let sorted = nums.sort((a,b) => a-b), len = nums.length;\
hbjorbj
NORMAL
2020-06-22T09:46:40.807051+00:00
2020-06-22T09:46:40.807084+00:00
555
false
```\n/**\n * @param {number[]} nums\n * @return {number}\n */\nvar maximumProduct = function(nums) {\n let sorted = nums.sort((a,b) => a-b), len = nums.length;\n let res1 = sorted[0]*sorted[1]*sorted[len-1],\n res2 = sorted[len-1]*sorted[len-2]*sorted[len-3]\n return Math.max(res1,res2);\n}; \n```
4
0
['JavaScript']
0
maximum-product-of-three-numbers
C# solutions w/ explaination
c-solutions-w-explaination-by-newbiecode-sno3
There are 3 cases of the input array. And the conclusion is the maximun product is generated by either the 3 largest number or the largest number and 2 smallest
newbiecoder1
NORMAL
2020-03-27T20:10:42.685673+00:00
2020-04-23T04:17:12.596244+00:00
254
false
There are 3 cases of the input array. And the conclusion is **the maximun product is generated by either the 3 largest number or the largest number and 2 smallest numbers.**\n1. All numbers are negative.\n\tmax product is generated by **the 3 largest negative numbers**.\n\te.g. [-4,-3,-2,-1]. max product = -3 * -2 * -...
4
0
[]
0
maximum-product-of-three-numbers
Javascript - O(n) time & O(1) space
javascript-on-time-o1-space-by-achandel-cz9d
\nvar maximumProduct = function(nums) {\n // get top 3 max and top 2 min in one pass\n let max1 = -Infinity, \n max2 = -Infinity,\n max3 = -
achandel
NORMAL
2019-11-28T14:00:30.094690+00:00
2019-11-28T14:00:30.094741+00:00
806
false
```\nvar maximumProduct = function(nums) {\n // get top 3 max and top 2 min in one pass\n let max1 = -Infinity, \n max2 = -Infinity,\n max3 = -Infinity,\n min1 = Infinity,\n min2 = Infinity;\n \n for(let num of nums){\n // fetch max\n if(num > max1){\n ...
4
0
['JavaScript']
0
maximum-product-of-three-numbers
Share my Python solution
share-my-python-solution-by-wangruinju-68tv
Sort the array, the maximum product happens in two situations:\nthe last three or the first two with the last one.\nHere is the Python code!\n\nclass Solution(o
wangruinju
NORMAL
2017-06-25T18:49:38.269000+00:00
2017-06-25T18:49:38.269000+00:00
1,259
false
Sort the array, the maximum product happens in two situations:\nthe last three or the first two with the last one.\nHere is the Python code!\n```\nclass Solution(object):\n def maximumProduct(self, nums):\n """\n :type nums: List[int]\n :rtype: int\n """\n nums.sort()\n retu...
4
0
[]
2
maximum-product-of-three-numbers
Very simple Javascript and typescript solution. Do check it out👍
very-simple-javascript-and-typescript-so-qjqf
Intuition\nThe maximum product can either come from the three largest numbers or from two smallest negative numbers and the largest positive number.\n\n# Approa
meathirarosejohn
NORMAL
2024-10-20T05:40:06.575578+00:00
2024-10-20T05:41:36.507311+00:00
281
false
# Intuition\nThe maximum product can either come from the three largest numbers or from two smallest negative numbers and the largest positive number.\n\n# Approach\nTrack the three largest and two smallest numbers while iterating through the array. The result is the maximum product of either the three largest numbers ...
3
0
['Array', 'Math', 'TypeScript', 'JavaScript']
1
maximum-product-of-three-numbers
🔍Very Easy, Simple and Short Solution🚀
very-easy-simple-and-short-solution-by-s-4l1k
Intuition\nThe key intuition is that the maximum product can arise from:\n\nThree largest positive numbers.\nTwo smallest negative numbers and the largest posit
shoaibkhalid65
NORMAL
2024-09-10T00:03:15.839947+00:00
2024-09-10T00:03:15.839975+00:00
731
false
# Intuition\nThe key intuition is that the maximum product can arise from:\n\nThree largest positive numbers.\nTwo smallest negative numbers and the largest positive number.\n\n# Approach\nSort the array: Sort the array in ascending order.\n\nCalculate products:\n\nCalculate the product of the three largest elements.\n...
3
0
['Java']
2
maximum-product-of-three-numbers
Python Easy Solution || Sorting
python-easy-solution-sorting-by-sumedh07-ojge
Code\n\nclass Solution:\n def maximumProduct(self, nums: List[int]) -> int:\n nums.sort()\n n=len(nums)\n return max(nums[n-1]*nums[n-2]
Sumedh0706
NORMAL
2023-07-17T05:45:05.030156+00:00
2023-07-17T05:45:05.030182+00:00
858
false
# Code\n```\nclass Solution:\n def maximumProduct(self, nums: List[int]) -> int:\n nums.sort()\n n=len(nums)\n return max(nums[n-1]*nums[n-2]*nums[n-3],nums[0]*nums[1]*nums[n-1])\n \n```
3
0
['Sorting', 'Python3']
0
maximum-product-of-three-numbers
Super Logical Solution Using Java
super-logical-solution-using-java-by-gpr-333c
\n\n# Superb Solution using JAVA\n\nclass Solution {\n public int maximumProduct(int[] nums) {\n Arrays.sort(nums);\n int n=nums.length;\n ret
GPraveen
NORMAL
2023-05-08T03:07:48.487576+00:00
2023-05-08T03:07:48.487621+00:00
1,834
false
\n\n# Superb Solution using JAVA\n```\nclass Solution {\n public int maximumProduct(int[] nums) {\n Arrays.sort(nums);\n int n=nums.length;\n return Math.max(nums[0]*nums[1]*nums[n-1],nums[n-1]*nums[n-2]*nums[n-3]); \n }\n}\n```
3
0
['Java']
3
maximum-product-of-three-numbers
C++ Solution || Easy || Brute Force ✔✔
c-solution-easy-brute-force-by-akanksha9-fi4f
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. O(n) \n\n
akanksha984
NORMAL
2023-05-06T11:27:53.014835+00:00
2023-05-13T05:21:43.459184+00:00
2,274
false
# 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. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n int maximumProduct(vector<int>& nums) {\n int n= nums.size();\n sort(n...
3
0
['Array', 'Math', 'Sorting', 'C++']
2
maximum-product-of-three-numbers
Solution
solution-by-deleted_user-jqed
C++ []\nclass Solution {\npublic:\n int maximumProduct(vector<int>& nums) {\n int max1 = INT32_MIN, max2 = INT32_MIN, max3 = INT32_MIN;\n int m
deleted_user
NORMAL
2023-04-14T13:16:33.554001+00:00
2023-04-14T14:34:13.241539+00:00
4,005
false
```C++ []\nclass Solution {\npublic:\n int maximumProduct(vector<int>& nums) {\n int max1 = INT32_MIN, max2 = INT32_MIN, max3 = INT32_MIN;\n int min1 = INT32_MAX, min2 = INT32_MAX;\n for(int& num : nums) {\n if(num > max1) {\n max3 = max2, max2 = max1, max1 = num;\n ...
3
0
['C++', 'Java', 'Python3']
0
maximum-product-of-three-numbers
Simple solution in python using sort
simple-solution-in-python-using-sort-by-bgfzt
\n\n# Code\n\nclass Solution:\n def maximumProduct(self, A: List[int]) -> int:\n A.sort()\n return max(A[0]*A[1]*A[-1], A[-1]*A[-2]*A[-3])\n
tryingall
NORMAL
2023-03-30T07:23:34.055965+00:00
2023-03-30T07:23:34.055997+00:00
1,082
false
\n\n# Code\n```\nclass Solution:\n def maximumProduct(self, A: List[int]) -> int:\n A.sort()\n return max(A[0]*A[1]*A[-1], A[-1]*A[-2]*A[-3])\n```
3
0
['Python3']
1
maximum-product-of-three-numbers
Brute Solution
brute-solution-by-anurag_rathore-rfpp
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
Anurag_Rathore
NORMAL
2023-03-01T11:52:47.228429+00:00
2023-03-01T11:52:47.228470+00:00
1,287
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
maximum-product-of-three-numbers
python 2 liner code faster
python-2-liner-code-faster-by-raghunath_-c3yc
\n def maximumProduct(self, nums: List[int]) -> int:\n nums.sort()\n return max((nums[-1]*nums[-2]*nums[-3]),(nums[0]*nums[1]*nums[-1]))\n
Raghunath_Reddy
NORMAL
2022-09-27T11:39:26.624394+00:00
2022-09-27T11:39:26.624436+00:00
1,421
false
```\n def maximumProduct(self, nums: List[int]) -> int:\n nums.sort()\n return max((nums[-1]*nums[-2]*nums[-3]),(nums[0]*nums[1]*nums[-1]))\n```
3
0
['Python', 'Python3']
1
maximum-product-of-three-numbers
JS simple solution with sorting
js-simple-solution-with-sorting-by-kunkk-lexv
\nvar maximumProduct = function(nums) {\n nums = nums.sort((a,b) => a - b);\n \n return Math.max(nums[0] * nums[1] * nums[nums.length - 1], nums[nums.l
kunkka1996
NORMAL
2022-08-26T10:05:57.751759+00:00
2022-08-26T10:05:57.751794+00:00
624
false
```\nvar maximumProduct = function(nums) {\n nums = nums.sort((a,b) => a - b);\n \n return Math.max(nums[0] * nums[1] * nums[nums.length - 1], nums[nums.length - 1] * nums[nums.length - 2] * nums[nums.length - 3]);\n};\n```
3
0
['Sorting', 'JavaScript']
1
maximum-product-of-three-numbers
Python - Easy to understand on the basis of testcases!!
python-easy-to-understand-on-the-basis-o-w2u1
\ndef maximumProduct(self, nums):\n n = len(nums)\n nums.sort()\n return max(nums[0] * nums[1] * nums[n - 1], nums[n-3] * nums[n - 2] * num
kartikkulshreshtha
NORMAL
2022-08-23T06:33:49.712253+00:00
2022-08-23T06:33:49.712299+00:00
1,084
false
```\ndef maximumProduct(self, nums):\n n = len(nums)\n nums.sort()\n return max(nums[0] * nums[1] * nums[n - 1], nums[n-3] * nums[n - 2] * nums[n-1])\n```
3
0
['Python']
0
maximum-product-of-three-numbers
my python solution with clear explanation
my-python-solution-with-clear-explanatio-nznm
\nclass Solution:\n def maximumProduct(self, nums: List[int]) -> int:\n nums.sort()\n max1 = nums[-1]*nums[-2]*nums[-3]\n max2 = nums[0]
CodeHunter_Sankar
NORMAL
2022-07-08T12:36:06.992255+00:00
2022-07-08T12:36:06.992302+00:00
278
false
```\nclass Solution:\n def maximumProduct(self, nums: List[int]) -> int:\n nums.sort()\n max1 = nums[-1]*nums[-2]*nums[-3]\n max2 = nums[0]*nums[1]*nums[-1]\n if max1 >= max2:\n return max1\n else:\n return max2\n""""\nexplanation: example \n list1=[1,2,3,4...
3
0
['Python']
0
maximum-product-of-three-numbers
Maximum product of three Numbers || simple || efficient || sorting
maximum-product-of-three-numbers-simple-cfm1n
\nclass Solution {\npublic:\n \n static int cmp(int a,int b) // This cmp function to sort in descending order\n { // To wri
babasaheb256
NORMAL
2022-06-10T03:52:28.894480+00:00
2022-06-10T03:54:41.336600+00:00
891
false
```\nclass Solution {\npublic:\n \n static int cmp(int a,int b) // This cmp function to sort in descending order\n { // To write this type of function concept is simple\n \n\t\treturn a>b; // Try to think what you want like you basically \n ...
3
0
['C', 'Sorting', 'C++']
2
maximum-product-of-three-numbers
Two lines of Code || Java || C++
two-lines-of-code-java-c-by-chiragvohra-p8kn
class Solution {\n public int maximumProduct(int[] nums) {\n\t\n\t//As we know there is only two possibilties \n\t//1st possibilty: All numbers are positive
chiragvohra
NORMAL
2022-05-13T21:39:35.001248+00:00
2022-05-13T21:39:35.001274+00:00
183
false
class Solution {\n public int maximumProduct(int[] nums) {\n\t\n\t//As we know there is only two possibilties \n\t//1st possibilty: All numbers are positive in that case we have return product of last three number of sorted array.\n \t// 2nd possibilty : There may be negative numbers also in that case we have to ret...
3
0
['Array', 'Sorting']
0
maximum-product-of-three-numbers
c++ || max product of 3 no.|| Basic || n* logn
c-max-product-of-3-no-basic-n-logn-by-sh-uw08
Time complexity= n*log(n)\nn=size of given vector\n\nclass Solution {\npublic:\n int maximumProduct(vector<int>& nums) {\n int ans=INT_MIN,n=nums.size
sheetaljoshi
NORMAL
2021-12-17T11:09:44.143630+00:00
2021-12-17T11:16:43.525334+00:00
352
false
Time complexity= n*log(n)\nn=size of given vector\n```\nclass Solution {\npublic:\n int maximumProduct(vector<int>& nums) {\n int ans=INT_MIN,n=nums.size();\n sort(nums.begin(),nums.end());\n \n int x=nums[n-3];\n int y=nums[n-2];\n int z=nums[n-1];\n int a=nums[0];\...
3
1
['C', 'C++']
1
maximum-product-of-three-numbers
python3
python3-by-saurabht462-971z
```\nimport math\nclass Solution:\n def maximumProduct(self, nums: List[int]) -> int:\n if len(nums)==3:return math.prod(nums)\n nums.sort(reve
saurabht462
NORMAL
2021-04-16T14:17:45.878546+00:00
2021-04-16T14:17:45.878583+00:00
159
false
```\nimport math\nclass Solution:\n def maximumProduct(self, nums: List[int]) -> int:\n if len(nums)==3:return math.prod(nums)\n nums.sort(reverse=True)\n print(nums)\n return max(math.prod(nums[:3]),math.prod([nums[-1],nums[-2],nums[0]]))
3
0
[]
0
maximum-product-of-three-numbers
python || very simple solution
python-very-simple-solution-by-risky_cod-5qm0
\n# Written by : Dhruv Vavliya\nnums = [1,2,3,4]\n\ndef max_product(nums):\n nums.sort(reverse=True)\n a = nums[0]*nums[1]*nums[2]\n b = nums[0]*nums[-
risky_coder
NORMAL
2020-12-29T11:36:07.300888+00:00
2020-12-29T11:36:07.300930+00:00
727
false
```\n# Written by : Dhruv Vavliya\nnums = [1,2,3,4]\n\ndef max_product(nums):\n nums.sort(reverse=True)\n a = nums[0]*nums[1]*nums[2]\n b = nums[0]*nums[-1]*nums[-2]\n return max(a,b)\n\nprint(max_product(nums))\n```
3
0
['Math', 'Python', 'Python3']
1
maximum-product-of-three-numbers
628-Maximum Product of Three Numbers-Py All-in-One By Talse
628-maximum-product-of-three-numbers-py-a00z2
Get it Done, Make it Better, Share the Best -- Talse\nI). Naive Sort\n| O(T): O(nlgn) | O(S): O(1) | Rt: 284ms | \npython\n def maximumProduct(self, nums: Li
talse
NORMAL
2019-12-03T18:59:47.272360+00:00
2019-12-03T19:00:11.348926+00:00
177
false
**Get it Done, Make it Better, Share the Best -- Talse**\n**I). Naive Sort**\n| O(T): O(nlgn) | O(S): O(1) | Rt: 284ms | \n```python\n def maximumProduct(self, nums: List[int]) -> int:\n nums.sort()\n return max(nums[-1] * nums[-2] * nums[-3], nums[0] * nums[1] * nums[-1])\n```\n\n\n**II). Limit State*...
3
0
[]
0