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

 

dario.sonego@gmail.com esercicci_array > subarray
prev  |  next  |  chance

Dato un array di interi nums ed un numero quanti, creare e restituire un nuovo array che contenga i primi quanti elementi di nums.
Se quanti<0, la funzione restituisce un array vuoto.
Se quanti รจ maggiore del numero di elementi dell'array nums, si copiano tutti gli elementi, evitando errori per accesso ad indici non validi.


subarray([10, 5, 9, 4], 2) → [10, 5]
subarray([10, 5, 9, 4], 1) → [10]
subarray([10, 5, 9, 4], 100) → [10, 5, 9, 4]

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

int[] subarray(int[] nums, int quanti) { }

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

Copyright Nick Parlante 2017 - privacy