583.Space Out the Characters of a String
Easy
Given a string
text with no spaces, return its characters separated by single spaces — for example "h e l l o".
This is the "print every character" exercise, done so the output can be checked: each character is visited in order with an indexString IndexThe position of a character in a string, starting from 0., just like an array. The small catch is the separatorSeparatorText placed between items, such as a comma or a space — but not before the first or after the last.: a space belongs between characters, not after the last one.
Example 1:
Input: text = "hello"
Output: "h e l l o"
Example 2:
Input: text = "A"
Output: "A"
+ 3 hidden test cases run on Submit.
Constraints:
- ●
1 ≤ text.length ≤ 100 - ●
text contains printable ASCII characters and no spaces
text =
hello