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

 

tmhscs@gmail.com arrays > array_firstMiddleLast
prev  |  next  |  chance

array_firstMiddleLast -- Given an array determine if it has an even or odd number of elements. If it contains an even number of elements return an array containing the first and last elements. If it contains an odd number of elements return an array containing the first, middle, and last elements. If the array only has one or no elements just return the original array.


array_firstMiddleLast([]) → []
array_firstMiddleLast([0]) → [0]
array_firstMiddleLast([1, 2, 3, 4]) → [1, 4]

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

public int[] array_firstMiddleLast(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

Post-solution available

Copyright Nick Parlante 2017 - privacy