5 kyu
Simple Fun #118: Sum Or Product
74 of 166myjinxin2015
Description:
Task
You are given an array of positive integers. While the array has more than one element you can choose two elements and replace them with their sum or product.
Your task is to find the maximum possible number that can remain in the array after multiple such operations.
Example
For arr = [1, 3, 2]
, the result should be 9
.
in order to maximize the answer the first operation will be 1 + 2
(the array changes into [3, 3]
) and the next 3 * 3
(the array changes into [9]
), so the final result is 9.
Input/Output
[input]
integer array arrarray of positive integers
[output]
an integer
maximum possible leftover
Puzzles
Similar Kata:
Stats:
Created | Feb 10, 2017 |
Published | Feb 10, 2017 |
Warriors Trained | 1094 |
Total Skips | 38 |
Total Code Submissions | 1939 |
Total Times Completed | 166 |
JavaScript Completions | 74 |
Python Completions | 98 |
Total Stars | 28 |
% of votes with a positive feedback rating | 96% of 48 |
Total "Very Satisfied" Votes | 44 |
Total "Somewhat Satisfied" Votes | 4 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 5 |
Average Assessed Rank | 5 kyu |
Highest Assessed Rank | 3 kyu |
Lowest Assessed Rank | 6 kyu |