Four is the number of letters in the ...: Difference between revisions

m
Reduce memory usage
m (const correctness fix)
m (Reduce memory usage)
Line 140:
return result;
}
 
const char* words[] = {
"Four", "is", "the", "number", "of", "letters", "in", "the",
"first", "word", "of", "this", "sentence,"
};
 
size_t count_letters(const std::string& str) {
Line 156 ⟶ 151:
 
std::vector<std::string> sentence(size_t count) {
static const char* words[] = {
"Four", "is", "the", "number", "of", "letters", "in", "the",
"first", "word", "of", "this", "sentence,"
};
std::vector<std::string> result;
result.reserve(count + 10);
size_t n = std::size(words);
for (size_t i = 0; i < n && i < count; ++i) {
1,777

edits