248. Number of Distinct Substrings (Count)

MediumStringString

Given a string s, return the number of distinct non-empty substrings of s.

Input: A quoted string s.

Output: Integer — count of distinct substrings.

Examples

Example 1
Input: "abc"
Output: 6
Explanation: a,b,c,ab,bc,abc.
Example 2
Input: "aaa"
Output: 3
Explanation: a,aa,aaa.
Example 3
Input: "aba"
Output: 5
Explanation: a,b,ab,ba,aba.

Constraints

Asked by

AmazonMicrosoftGoogleAdobeFlipkart
Solve this problem in the editor →