Question
Finds ALL runs of X consecutive positive integers that sum to a given number for all X in a specified range. * The range bounds
Finds ALL runs of X consecutive positive integers that sum to a given number for all X in a specified range.
* The range bounds are inclusive.
*
* Examples:
* runs(9,2,3) -> [ [4,5], [2,3,4] ] // two runs found
* runs(9,1,1) -> [ [9] ] // one run found
* runs(9,4,8) -> [ ] // no runs found!
* runs(125,1,8) -> [ [125], [62,63], [23,24,25,26,27]] // 3 runs!
*
* number must be a positive integer
* start is lower bound for the range (of consecutive numbers in the sum). It is a positive integer.
* end is the upper bound for the range (of consecutive numbers in the sum). It is a positive
* integer that is not smaller than start.
* return an array of arrays. Each inner array is a sequence of consecutive positive
* integers that sum to the input number. The ordering inside the arrays is that
* is the natural ordering (increasing order by value), and the ordering of the inside arrays
* is by increasing length.
*/
public static int[][] runs(int number, int start, int end){
return null;
}
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