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

 

norm.krumpe@muohio.edu arrays274 > sortedInsert
prev  |  next  |  chance

Given an integer, insert it into an already sorted array so that the resulting array is still sorted. Arrays will be and should be sorted in ascending order. If the original array is empty, return an array containing the one new value.


sortedInsert(5, [2, 2, 3, 6]) → [2, 2, 3, 5, 6]
sortedInsert(5, [2, 2, 3, 5, 6]) → [2, 2, 3, 5, 5, 6]
sortedInsert(7, []) → [7]

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

int[] sortedInsert(int n, 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: 250

Copyright Nick Parlante 2017 - privacy