about | help | code help+videos | done | prefs |
test2020_10_15_APP1SLHL_swap
Write a method that swaps the first and last 'swapNum' number of characters of the input parameter string 'str'. For example, if str="swap these" and swapNum=2 you would return "seap thesw" (because you swapped the first and last two characters. As a precondition, you may assume that swapNum will be less than or equal to half the length of str and that str will have at least two characters. test2020_10_15_APP1SLHL_swap("abcdefghijklmnop", 3) → "nopdefghijklmabc" test2020_10_15_APP1SLHL_swap("abcdefghijklmnop", 5) → "lmnopfghijkabcde" test2020_10_15_APP1SLHL_swap("xyz", 1) → "zyx" ...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