Class Solution
-
- All Implemented Interfaces:
public final class Solution2213 - Longest Substring of One Repeating Character\.
Hard
You are given a 0-indexed string
s. You are also given a 0-indexed stringqueryCharactersof lengthkand a 0-indexed array of integer indicesqueryIndicesof lengthk, both of which are used to describekqueries.The <code>i<sup>th</sup></code> query updates the character in
sat indexqueryIndices[i]to the characterqueryCharacters[i].Return an array
lengthsof lengthkwherelengths[i]is the length of the longest substring ofsconsisting of only one repeating character after the <code>i<sup>th</sup></code> query is performed.Example 1:
Input: s = "babacc", queryCharacters = "bcb", queryIndices = 1,3,3
Output: 3,3,4
Explanation: - 1<sup>st</sup> query updates s = "bbbacc". The longest substring consisting of one repeating character is "bbb" with length 3.
2<sup>nd</sup> query updates s = "bbbccc". The longest substring consisting of one repeating character can be "bbb" or "ccc" with length 3.
3<sup>rd</sup> query updates s = "bbbbcc". The longest substring consisting of one repeating character is "bbbb" with length 4.
Thus, we return 3,3,4.
Example 2:
Input: s = "abyzz", queryCharacters = "aa", queryIndices = 2,1
Output: 2,3
Explanation: - 1<sup>st</sup> query updates s = "abazz". The longest substring consisting of one repeating character is "zz" with length 2.
2<sup>nd</sup> query updates s = "aaazz". The longest substring consisting of one repeating character is "aaa" with length 3.
Thus, we return 2,3.
Constraints:
<code>1 <= s.length <= 10<sup>5</sup></code>
sconsists of lowercase English letters.k == queryCharacters.length == queryIndices.length<code>1 <= k <= 10<sup>5</sup></code>
queryCharactersconsists of lowercase English letters.0 <= queryIndices[i] < s.length
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
Modifier and Type Method Description final IntArraylongestRepeating(String s, String queryCharacters, IntArray queryIndices)-
-
Method Detail
-
longestRepeating
final IntArray longestRepeating(String s, String queryCharacters, IntArray queryIndices)
-
-
-
-