21. Count Number of Homogenous Substrings
Given a string s
, return the number of homogenous substrings of s
. Since the answer may be too large, return it modulo 109 + 7
.
A string is homogenous if all the characters of the string are the same.
A substring is a contiguous sequence of characters within a string.
Solution:
Approach: No of substring of a string n:- (Σn = n * (n+1)/2 ) We would find the length of homogeneous substring and count no ways possible
Time Complexity: O(n)
Last updated