Question: Language is in Java, please explain the answer using comments, Thank you. I always rate!!! PLEASE DO NOT import any packages to solve the problem.

Language is in Java, please explain the answer using comments, Thank you. I always rate!!!

PLEASE DO NOT import any packages to solve the problem. PLEASE use classes and methods from java.lang.*, since they are automatically imported without import statement.

build a method called;

public static in[] multbygrp(int[] elems, int grpsize)

This method splits arr into subgroups of (equal) size groupSize, and multiply the contents of each subgroup. It returns the individual product in a new list.

If splitting can't be done properly, returns an empty array.

You can assume groupSize is greater than 0 and less than or equal to the length of arr

Input: [1, 2, -8, 2] , 2

Output: [2, -16]

Input: [1, 2, 3, 4] , 3

Output: []

Input: [5, 6, 7] , 1

Output: [5, 6, 7]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!