Must add output screenshot, editable code Write a java program for the following question. Consider a non-empty array inarr of positive integers containing at least two elements and an integer innum where 0

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Must add output screenshot, editable code

 

Write a java program for the following question.

Consider a non-empty array inarr of positive integers containing at least two elements and an integer innum where 0<innum. Identify and print an integer outnum as per the logic below:

Identify the various combinations in which the elements of inarr

can be divided into maximum of innum groups such that: o each element occurs exactly in one group and o each group will contain elements which are adjacent to

each other in inarr

• For each combination identify the group whose sum of elements is maximum.

Assign the minimum value from the above identified maximum

sums to outnum.

Input format:

First line would contain the elements of inarr separated by ','(comma)

Second line would contain the integer value innum.

Read the inputs from the standard input stream

Output format:

Print outnum to the standard output stream.

 
Sample Input
Sample Output
Explanation
5,10,30,20, 15
35
For the given
3
inputs, inarr is [5,
10, 30, 20, 15] and
innum is 3. Few of
the possible
combinations(C1,C
2,C3 & C4) are:
C1:
Group 1: {5,10}
sum=15
Group 2: {30,20,15}
sum=65
the group with
maximum sum of
elements is Group
2: {30,20,15} and
the sum is 65
C2:
Group 1:{5} sum3D5
Transcribed Image Text:Sample Input Sample Output Explanation 5,10,30,20, 15 35 For the given 3 inputs, inarr is [5, 10, 30, 20, 15] and innum is 3. Few of the possible combinations(C1,C 2,C3 & C4) are: C1: Group 1: {5,10} sum=15 Group 2: {30,20,15} sum=65 the group with maximum sum of elements is Group 2: {30,20,15} and the sum is 65 C2: Group 1:{5} sum3D5
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY