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

 

apcsaArraysSwapLeastWithFirst


This function returns the input array (or a copy of the input array) where the first element has been swapped with the least element. If the first element is the least element, the array is returned unchanged.


If there are multiple elements tied for the "least value" crown, swap with the tied element that has the lowest index.

HINT: this algorithm combines two prior algorithms from this problem set.

apcsaArraysSwapLeastWithFirst([0, 1, 2, 3]) → [0, 1, 2, 3]
apcsaArraysSwapLeastWithFirst([-1, -3, 5]) → [-3, -1, 5]
apcsaArraysSwapLeastWithFirst([0]) → [0]

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

public int[] apcsaArraysSwapLeastWithFirst(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: 240

Copyright Nick Parlante 2017 - privacy