Question: Please help this simple coding problem in Java , use starter coding (below). Thanks JE Given an integer N, you are asked to divide N

Please help this simple coding problem in Java, use starter coding (below). Thanks

Please help this simple coding problem in Java, use starter coding (below).

Thanks JE Given an integer N, you are asked to divide N

into a sum of a maximal number of positive even integers. All

JE Given an integer N, you are asked to divide N into a sum of a maximal number of positive even integers. All the numbers should also be different. Keyt For example, for N = 12, the following splits are valid: (2 + 10), (2 + 4 + 6) and (4 + 8). Among them, (2 + 4 + 6) contains the maximal number of integers. Note that N cannot be split into (2+2 +4 + 4) as all the numbers should be different. omvOnAWN- 10 Write a function: class Solution { public int[] solution (int N); } which, given a positive integer number N, returns an array containing the numbers from any maximal possible answer (any valid combination may be returned). If N cannot be divided in such a way, return an empty array Result array should be returned as an array of integers. Examples: + Add test case possible answer (any valid combination may be returned). If N cannot be divided in such a way, return an empty array Result array should be returned as an array of integers. Examples: 1. Given N = 6, your function should return [2, 4] or [4, 2]. 2. Given N = 7, your function should return ( (an empty array) as there is no valid split. 3. Given N = 22, your function should return (2, 4, 6, 10] in any order. 4. Given N = 4, your function should return [4]. Write an efficient algorithm for the following assumptions: W N is an integer within the range [1..100,000,000). Java Keyboard navigation: Use Tab to advance the cursor. To exit the editor, press the ctrl and [keys. 1 import java.util.ArrayList; import java.util.List; 3 4 5 6 7 8 9 10 11 class Solution { public static List solution(int N) { System.err.println("Tip: Use System.err.println() to write debug messages on the output tab."); ArrayList answer = new ArrayList(); return answer; } }

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!