Bloomberg Interview Question

Find the maximum sequence of the same letters

Interview Answer

Anonymous

Jun 13, 2017

O(n) int max_sequence(const std::string& str) { auto last = str[0]; auto max_count = 1; auto current_count = 1; for (auto i = 1; i max_count) max_count = current_count; } else { last = str[i]; current_count = 1; } } return max_count; } void run() { auto count = max_sequence("aabaaaccbbccdddeeeffffffggccdddaaamnpqrs"); }