Without using a built-in string join method, implement a join(arr, s) method, which receives an array of strings, arr, and a string, s, and returns a single string consisting of the strings in arr with s in between them.
Examples:
- arr = ["join", "by", "space"], s = " "
- Output: "join by space"
- arr = ["b", "", "k", "", "p", "r n", "", "d", "d"], s = "ee"
- Output: "beekeepeerneeeeddeed!!"
If strings in your language are immutable, assume that you have access to a function array_to_string(arr), which takes an array of individual characters and returns a string with those characters in time.
,
0
s = ","
arr=["a", "b"]
s=,
res=
Step 1 / 5
Step 1:
Initialize result buffer
Focus: default
s=","res=""