{"id":"10b76bb5-3a27-4ce3-a1fb-9410ae52fd98","name":"Max Product Of Three Numbers","description":"1. Given an integer array 'arr',\r\n2. Find three numbers whose product is maximum and return the maximum product.\r\n","inputFormat":"(Already managed for you)\r\n4\r\n1 2 3 4\r\n","outputFormat":"(Already managed for you)\r\n24","constraints":"1. 3 &lt;= nums.length &lt;= 10^4\r\n2. -1000 &lt;= nums[i] &lt;= 1000\r\n","sampleCode":{"cpp":{"code":"#include<bits/stdc++.h>\nusing namespace std;\n\nint maximumProduct(vector<int> & arr){\n //Write your code here\n}\n\nint main(){\n int n;\n cin>>n;\n vector<int> arr(n,0);\n for(int i=0; i<n; i++){\n cin>>arr[i];\n }\n int prod = maximumProduct(arr);\n cout<<prod<<endl;\n}"},"java":{"code":"import java.util.*;\r\n\r\npublic class Main {\r\n\r\n // ~~~~~~~~~~~~~~~~User Section~~~~~~~~~~~\r\n public static int maximumProduct(int[] arr) {\r\n // write your code here\r\n }\r\n\r\n // ~~~~~~~~~~~~~~~~Input Management~~~~~~~~~~~\r\n public static void main(String[] args) {\r\n Scanner scn = new Scanner(System.in);\r\n int n = scn.nextInt();\r\n int[] arr = new int[n];\r\n\r\n for(int i = 0; i < n; i++) {\r\n arr[i] = scn.nextInt();\r\n }\r\n\r\n int prod = maximumProduct(arr);\r\n System.out.println(prod);\r\n }\r\n}"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"6\r\n3 2 -4 -6 5 1","sampleOutput":"120","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"35f2cfb0-6f25-4967-b0c9-92f2384b9260","name":"Arrays And Strings For Intermediate","slug":"arrays-and-strings-for-intermediate-732","type":0},{"id":"adf6b900-bc13-4da8-bb16-cdd886ec5442","name":"Max Product Of Three Numbers","slug":"max-product-of-three-numbers","type":1}],"next":{"id":"f4ed615c-e334-4c97-a08e-9b59f56ee327","name":"Max Product Of Three Numbers","type":3,"slug":"max-product-of-three-numbers"},"prev":{"id":"1d4342a6-4b4f-4d07-b89e-78414f6e4cda","name":"Majority Element General MCQ","type":0,"slug":"majority-element-general-mcq"}}}

Max Product Of Three Numbers

1. Given an integer array 'arr', 2. Find three numbers whose product is maximum and return the maximum product.

{"id":"10b76bb5-3a27-4ce3-a1fb-9410ae52fd98","name":"Max Product Of Three Numbers","description":"1. Given an integer array 'arr',\r\n2. Find three numbers whose product is maximum and return the maximum product.\r\n","inputFormat":"(Already managed for you)\r\n4\r\n1 2 3 4\r\n","outputFormat":"(Already managed for you)\r\n24","constraints":"1. 3 &lt;= nums.length &lt;= 10^4\r\n2. -1000 &lt;= nums[i] &lt;= 1000\r\n","sampleCode":{"cpp":{"code":"#include<bits/stdc++.h>\nusing namespace std;\n\nint maximumProduct(vector<int> & arr){\n //Write your code here\n}\n\nint main(){\n int n;\n cin>>n;\n vector<int> arr(n,0);\n for(int i=0; i<n; i++){\n cin>>arr[i];\n }\n int prod = maximumProduct(arr);\n cout<<prod<<endl;\n}"},"java":{"code":"import java.util.*;\r\n\r\npublic class Main {\r\n\r\n // ~~~~~~~~~~~~~~~~User Section~~~~~~~~~~~\r\n public static int maximumProduct(int[] arr) {\r\n // write your code here\r\n }\r\n\r\n // ~~~~~~~~~~~~~~~~Input Management~~~~~~~~~~~\r\n public static void main(String[] args) {\r\n Scanner scn = new Scanner(System.in);\r\n int n = scn.nextInt();\r\n int[] arr = new int[n];\r\n\r\n for(int i = 0; i < n; i++) {\r\n arr[i] = scn.nextInt();\r\n }\r\n\r\n int prod = maximumProduct(arr);\r\n System.out.println(prod);\r\n }\r\n}"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"6\r\n3 2 -4 -6 5 1","sampleOutput":"120","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"35f2cfb0-6f25-4967-b0c9-92f2384b9260","name":"Arrays And Strings For Intermediate","slug":"arrays-and-strings-for-intermediate-732","type":0},{"id":"adf6b900-bc13-4da8-bb16-cdd886ec5442","name":"Max Product Of Three Numbers","slug":"max-product-of-three-numbers","type":1}],"next":{"id":"f4ed615c-e334-4c97-a08e-9b59f56ee327","name":"Max Product Of Three Numbers","type":3,"slug":"max-product-of-three-numbers"},"prev":{"id":"1d4342a6-4b4f-4d07-b89e-78414f6e4cda","name":"Majority Element General MCQ","type":0,"slug":"majority-element-general-mcq"}}}
plane

Editor


Loading...

Max Product Of Three Numbers

easy

1. Given an integer array 'arr', 2. Find three numbers whose product is maximum and return the maximum product.

Constraints

1. 3 <= nums.length <= 10^4 2. -1000 <= nums[i] <= 1000

Format

Input

(Already managed for you) 4 1 2 3 4

Output

(Already managed for you) 24

Example

Sample Input

6 3 2 -4 -6 5 1

Sample Output

120

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode