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

 

nSwapAB


Given a String 's' and a non-negative integer 'n' change the first n occurrences of "a" to "b" or "b" to "a". For example: "aaron braskin" and "2" yields: "bbron braskin" because the first two occurrences and 'a' or 'b' have been swapped but the third occurrence has been left alone.


nSwapAB("aaron braskin", 0) → "aaron braskin"
nSwapAB("aaron braskin", 1) → "baron braskin"
nSwapAB("aaron braskin", 2) → "bbron braskin"

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

public String nSwapAB(String s, int n) { }

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

Copyright Nick Parlante 2017 - privacy