We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e9d3dd2 commit f9b7ec8Copy full SHA for f9b7ec8
2109. Adding Spaces to a String
@@ -0,0 +1,15 @@
1
+class Solution {
2
+public:
3
+ string addSpaces(string s, vector<int>& spaces) {
4
+ int ind = 0;
5
+ string ans = "";
6
+ for (int i = 0; i < s.size(); i++) {
7
+ if (ind < spaces.size() && i == spaces[ind]) {
8
+ ans += " ";
9
+ ind++;
10
+ }
11
+ ans += s[i];
12
13
+ return ans;
14
15
+};
0 commit comments