You are viewing a single comment's thread. Return to all comments →
C++:
long singleStringChars{0}; for (char c : s) { if (c == 'a') { singleStringChars++; } } if (singleStringChars > 0) { signed long long numberOfOccurrences = n/s.size() * singleStringChars; signed long long numberOfMissingChar = n - ((n/s.size()) * s.size()); for (auto i{0}; i < numberOfMissingChar; i++) { if ('a' == s[i]) { numberOfOccurrences++; } } return numberOfOccurrences; } else { return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
Repeated String
You are viewing a single comment's thread. Return to all comments →
C++: