Question: 4 Product target Input array target Output results function results myProduct (array, target) Type 1xK double 1x1 double Type Mx3 double or empty array Description
4 Product target Input array target Output results function results myProduct (array, target) Type 1xK double 1x1 double Type Mx3 double or empty array Description An array of numbers in ascending order The desired prodtuct of any three elemeuts of array escription A Mx3 double array with all the 1x3 arrays of values in array that multiply up to target. Empty if none found Details Write a function that takes an array of K integers and a single desired value to serve as a target product. Are there three elements a, b, c in the array such that a x bx c target? Find all unique triplets in the array which give the target product. Note: Each row in the solution should be listed in ascending order and no duplicate rows should be listed. See the code below as an example: Sarray[, 1, 5, 6, 7, 8, 101 SSresults myProduct (array, 30) results 1 5 6 array1, 2, 3, 4, 5, 6, 7, 8, 101 results myProduct (array, 24) results array 10, 1, 1, 2, 3, 4 Sresults myProduct (array, 10) results Tips . The order of rows in results doesn't matter. For example, [1, 2, 4; 2, 3, 5; 1, 1, 3] and (1, 1, 3; 1, 2, 4; 2, 3, 5) are both correct for the second example problem. . This problem is better solved with iteration
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
