gudii9
asked on
fizzArray3 challenge
Hi,
I am working on below challenge
http://codingbat.com/prob/p142539
Psedo code description of approach :
1. find length of new array by subtracting end-start
2. create new array with above lenght
3. assign each element 0f new array using numbers between start(inclusive) and end(exclusive)
I wrote my code as below
I am passing all tests
How to improve my design, approach, code? please advise
I am working on below challenge
http://codingbat.com/prob/p142539
Psedo code description of approach :
1. find length of new array by subtracting end-start
2. create new array with above lenght
3. assign each element 0f new array using numbers between start(inclusive) and end(exclusive)
I wrote my code as below
public int[] fizzArray3(int start, int end) {
int len=end-start;
int[] arr=new int[len];
for(int i=0;i<len;i++){
arr[i]=start+i;
}
return arr;
}
I am passing all tests
Expected Run
fizzArray3(5, 10) → [5, 6, 7, 8, 9] [5, 6, 7, 8, 9] OK
fizzArray3(11, 18) → [11, 12, 13, 14, 15, 16, 17] [11, 12, 13, 14, 15, 16, 17] OK
fizzArray3(1, 3) → [1, 2] [1, 2] OK
fizzArray3(1, 2) → [1] [1] OK
fizzArray3(1, 1) → [] [] OK
fizzArray3(1000, 1005) → [1000, 1001, 1002, 1003, 1004] [1000, 1001, 1002, 1003, 1004] OK
other tests
OK
How to improve my design, approach, code? please advise
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.