Largest Product from Array

Welcome to the first of what’s planned to be a weekly series of online coding challenges.

This week is a Java challenge. You’re going to iterate through an array of integers and determine the largest possible product using the array values.


Largest Product

Calculate the largest possible product using any 3 elements from an array of integers.

largestProduct( [1, 2, 3] ) => 6
largestProduct( [0, 0, 0, 3] ) => 0
largestProduct( [4, 7, 2, 3, 6, 4] ) => 168

You may assume that nums.length >= 3


Why ClassCube?

Are you spending too much time grading your students' source code?

ClassCube is an online tool for Computer Science teachers that allows you to create lab assignments for your students. They'll submit their code online and ClassCube will automatically grade it for you.

Teaching with ClassCube…

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>