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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started