|
||
|
||||
|
Given an int array, return a new array with double the length where its last element is the same as the original array, and all the other elements are 0. The original array will be length 1 or more. Note: by default, a new int array contains all 0's.
makeLast({4, 5, 6}) → {0, 0, 0, 0, 0, 6} makeLast({1, 2}) → {0, 0, 0, 2} makeLast({3}) → {0, 3} can anyone try this? i cannot get the end number. thanks. i cant make it. ![]() ![]() Java Code
public int[] makeLast(int[] nums){
int len = nums.length-1;
int[] integerArray = new int[(nums.length * 2 -1) ];
return integerArray;
}
you can simulate it here: JavaBat Array-1 makeLast
|
|
||||
|
Hello Truffy,
Sorry I wasn't around to offer a solution. I'm glad you found the answer.
__________________
Don't forget to add syntax highlighted code tags around your code: [highlight=Java] code here [/highlight] Forum Tip: Add to peoples reputation ( ) by clicking the button on their useful posts.
|
|
||||
|
Quote:
Good morning. Its okay. I know youre not around because the forum is quiet. But glad you're here again. ![]() Cheers, Truffy.
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
|
100 most searched terms
Search Cloud
|
| 2d arraylist java actionlistener actionlistener in java actionlistener java addactionlistener addactionlistener in java addactionlistener java applications of oops could not create java virtual machine xp double format java double to int double to int java double to integer in java double to integer java eclipse shortcut keys eclipse tutorial for beginners exception in thread "awt-eventqueue-0" java.lang.outofmemoryerror: java heap space exception in thread "main" java.lang.nullpointerexception exception in thread "main" java.lang.outofmemoryerror: java heap space format double java get mouse position java java 2d arraylist java actionlistener java addactionlistener java convert list to map java double format java double formatting java double to int java double to integer java format double java forum java forums java get mouse position java list to map java mouse position java programming forum java programming forums java programming help java sendkeys java two dimensional arraylist java.lang.classformaterror: truncated class file java.lang.outofmemoryerror: java heap space java.util.arraylist jbutton actionlistener jtextarea font jtextfield font size jxl.read.biff.biffexception: unable to recognize ole stream programming mutators and generics two dimensional arraylist java writing ipod apps |