id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

apcsaArraysGetFirstMiddleLastElements


Given an array of ints, return a new array of ints containing the first element, the "middle" element and the last element from the input array, in their original order. The "middle" element is defined as the element with index value of length / 2. Precondition: the input array will have length >= 3.

HINT
Don't modify the parameter.

apcsaArraysGetFirstMiddleLastElements([3, 4, 9, 2]) → [3, 9, 2]
apcsaArraysGetFirstMiddleLastElements([0, 2, 3]) → [0, 2, 3]
apcsaArraysGetFirstMiddleLastElements([1, 2, 3, 4]) → [1, 3, 4]

...Save, Compile, Run (ctrl-enter)

public int[] apcsaArraysGetFirstMiddleLastElements(int[] arr) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 130

Copyright Nick Parlante 2017 - privacy