about | help | code help+videos | done | prefs |
Write a method that helps two characters "time travel" to new locations in a string. Find the first occurance of 'first' and the last occurance of 'last'. Return a new string where these two characters have been swapped. For example: drWhoCharacterTimeTravel("This is a test",'i','t') will result in "Thts is a tesi". If either 'first' or 'last' does not occur in the string, then just return the original string unchanged. drWhoLetterTimeTravel("I am The Doctor", "o", "m") → "I ao The Dmctor" drWhoLetterTimeTravel("But it has always made that noise. I LIKE that noise.", "i", "n") → "But nt has always made that noise. I LIKE that ioise." drWhoLetterTimeTravel("tardis blue", "e", "a") → "terdis blua" ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 290
Copyright Nick Parlante 2017 - privacy