Four is the number of letters in the ...: Difference between revisions
Content added Content deleted
m (const correctness fix) |
m (Reduce memory usage) |
||
Line 140: | Line 140: | ||
return result; |
return result; |
||
} |
} |
||
⚫ | |||
⚫ | |||
⚫ | |||
}; |
|||
size_t count_letters(const std::string& str) { |
size_t count_letters(const std::string& str) { |
||
Line 156: | Line 151: | ||
std::vector<std::string> sentence(size_t count) { |
std::vector<std::string> sentence(size_t count) { |
||
⚫ | |||
⚫ | |||
⚫ | |||
}; |
|||
std::vector<std::string> result; |
std::vector<std::string> result; |
||
result.reserve(count + 10); |
|||
size_t n = std::size(words); |
size_t n = std::size(words); |
||
for (size_t i = 0; i < n && i < count; ++i) { |
for (size_t i = 0; i < n && i < count; ++i) { |