Leetcode - Consecutive Characters
https://leetcode.com/problems/consecutive-characters/
Given a string s
, the power of the string is the maximum length of a non-empty substring that contains only one unique character.
Return the power of the string.
Example 1:
Input: s = "leetcode" Output: 2 Explanation: The substring "ee" is of length 2 with the character 'e' only.
func maxPower(s string) int { i := 0 count := 1 for i < len(s) { j := i + 1 for j < len(s) && s[j] == s[i] { j++ } if j - i > count { count = j - i } i = j } return count }
Sep 24, 2022 12:16:13 AM
In modern days, Computer Education is most important for everyone and its one of the fastest growing career fields. A career in the field of computer science has been proven to be a worthwhile direction for any young enthusiast. It helps them to aim for excellent jobs in the future and succeed in it. NCERT Computer Question Paper Class 9 The computer has become a standard of education throughout the world. This makes computer education important.In modern days, Computer Education is most important for everyone and its one of the fastest growing career fields.