X

DAYS

:

HOUR

:

MINS

:

SEC

Copied to Clipboard
Distinct Substrings
Easy Accuracy: 61.39% Submissions: 953 Points: 2

Given a string s consisting of uppercase and lowercase alphabetic characters. Return the  number of distinct substrings of size 2 that appear in s as contiguous substrings.

Example

Input :
s = "ABCAB"
Output :
3
Explanation:  For "ABCAB", the
three distinct substrings of size
2 are "AB", "BC" and "CA". 

Example

Input :
s = "XYZ"
Output :
2
Explanation: For "XYZ", the
two distinct substrings of size 2 are
"XY" and "YZ".


You don't need to read input or print anything. You have to complete the function fun() which takes the string s as input parameter and returns the number of distinct contiguous substring of size 2.

Expected Time Complexity : O(|s|)
Expected Auxilliary Space : O(|s|)

Constraints:
1<=|s|<=100

|s| denotes the length of the string s.

We are replacing the old Disqus forum with the new Discussions section given below.