-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsplitString.cpp
More file actions
19 lines (13 loc) · 479 Bytes
/
splitString.cpp
File metadata and controls
19 lines (13 loc) · 479 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <string>
#include <vector>
std::vector<std::string> solution(const std::string &s){
auto inputString = std::move(s);
auto const subrangeLength = 2;
auto const sizeOdd = inputString.size() % 2;
std::vector<std::string> ranges;
if (sizeOdd) { inputString += "_"; }
for (size_t position = 0; position < inputString.size(); position += subrangeLength) {
ranges.push_back(inputString.substr(position,subrangeLength));
}
return ranges;
}