a few solutions
Perform a linear scan of the input string s to find the maximum size of the same consecutive characters as the best answer.\n\n---\n\nKotlin\n\nclass Solution {
Perform a linear scan of the input string `s` to find the maximum `size` of the same consecutive characters as the `best` answer.\n\n---\n\n*Kotlin*\n```\nclass Solution {\n    fun maxPower(s: String): Int {\n        var (best, size) = listOf(1, 1)\n        for (i in 1 until s.length)\n            if (s[i - 1] == s[i])\n                best = Math.max(best, ++size)\n            else\n                size = 1\n        return best\n    }\n}\n```\n\n*Javascript*\n```\nlet maxPower = s => {\n    let [best, size] = [1, 1];\n    for (let i = 1; i < s.length; ++i)\n        if (s[i - 1] == s[i])\n            best = Math.max(best, ++size);\n        else\n            size = 1;\n    return best;\n};\n```\n\n*Python3*\n```\nclass Solution:\n    def maxPower(self, s: str) -> int:\n        best, size = 1, 1\n        for i in range(1, len(s)):\n            if s[i - 1] == s[i]:\n                size += 1\n                best = max(best, size)\n            else:\n                size = 1\n        return best\n```\n\n*C++*\n```\nclass Solution {\npublic:\n    int maxPower(string s) {\n        auto [best, size] = make_tuple(1, 1);\n        for (auto i{ 1 }; i < s.size(); ++i)\n            if (s[i - 1] == s[i])\n                best = max(best, ++size);\n            else\n                size = 1;\n        return best;\n    }\n};\n```
[]