Link to home
Start Free TrialLog in
Avatar of gudii9
gudii9Flag for United States of America

asked on

makeMiddle Challenge

Hi,

I am working on below challenge and wrote as below

http://codingbat.com/prob/p199519

public int[] makeMiddle(int[] nums) {
int len=nums.length;
int[] numsNew=new int[2];
numsNew[0]=nums[(len/2)-1];
numsNew[1]=nums[(len/2)];
  return numsNew;
}

Open in new window


i passed all tests. How to improve my code, laternate ways of doing it effectively. please advise
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial