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

 

Array-1 > frontPiece
prev  |  next  |  chance

Given an int array of any length, return a new array of its first 2 elements. If the array is smaller than length 2, use whatever elements are present.


frontPiece([1, 2, 3]) → [1, 2]
frontPiece([1, 2]) → [1, 2]
frontPiece([1]) → [1]

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

public int[] frontPiece(int[] nums) { }

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: 172.0

Copyright Nick Parlante 2017 - privacy