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 arr

    array of positive integers

  • [output] an integer

maximum possible leftover

Puzzles

Stats:

CreatedFeb 10, 2017
PublishedFeb 10, 2017
Warriors Trained1094
Total Skips38
Total Code Submissions1939
Total Times Completed166
JavaScript Completions74
Python Completions98
Total Stars28
% of votes with a positive feedback rating96% of 48
Total "Very Satisfied" Votes44
Total "Somewhat Satisfied" Votes4
Total "Not Satisfied" Votes0
Total Rank Assessments5
Average Assessed Rank
5 kyu
Highest Assessed Rank
3 kyu
Lowest Assessed Rank
6 kyu
Ad
Contributors
  • myjinxin2015 Avatar
  • Blind4Basics Avatar
  • user9644768 Avatar
  • mauro-1 Avatar
Ad