diff options
author | Jack Sangdahl <[email protected]> | 2025-06-27 12:23:02 -0600 |
---|---|---|
committer | Jack Sangdahl <[email protected]> | 2025-06-27 12:23:02 -0600 |
commit | a96b65cbfad7f62f3db6b2eab105e4e25c0414c5 (patch) | |
tree | e2a2b3f49f9fb741be81415266ac93e74cff42ec /other/add_space_string.cpp | |
parent | 694ad5ed71edcb1deccab54b72d706b779918276 (diff) | |
download | leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.tar.gz leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.zip |
chore: remove old cpp and rust solutions
Diffstat (limited to 'other/add_space_string.cpp')
-rw-r--r-- | other/add_space_string.cpp | 36 |
1 files changed, 0 insertions, 36 deletions
diff --git a/other/add_space_string.cpp b/other/add_space_string.cpp deleted file mode 100644 index 9a9b7ea..0000000 --- a/other/add_space_string.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// 2109. Adding Spaces to a String -#include "leetcode.h" - -/* - * given a 0-indexed string 's' and a 0-indexed integer array 'spaces' that - * describes the indices in the original string where spaces will be added. each - * space should be inserted before the character at the given index. return the - * modified string after the spaces have been added - */ - -class Solution { -public: - string addSpaces(string s, vector<int> &spaces) { - int n = spaces.size(), m = s.size(), i = 0, j = 0; - string ans = ""; - while (i < m) { - if (j < n && i == spaces[j]) { - ans += ' '; - j++; - } - ans += s[i]; - i++; - } - return ans; - } -}; - -int main() { - Solution obj; - vector<int> s1 = {8, 13, 15}, s2 = {1, 5, 7, 9}, s3 = {0, 1, 2, 3, 4, 5, 6}; - cout << obj.addSpaces("LeetcodeHelpsMeLearn", s1) - << endl; // expect: Leetcode Helps Me Learn - cout << obj.addSpaces("icodeinpython", s2) - << endl; // expect: i code in py thon - cout << obj.addSpaces("spacing", s3) << endl; // expect: s p a c i n g -} |