Holiday Season
Practice
3.8 (102 votes)
Easy
Searching
Problem
91% Success 20580 Attempts 30 Points 2s Time Limit 256MB Memory 1024 KB Max Code

It's a holiday season for all school students around the world! Unfortunately, Mahamba is busy preparing for International Olympiad in Informatics, which will be held in Tehran, Iran. He is now facing a new challenge from his teacher Aceka, and it goes something like this:

You have a string x of length N, which consists of small English letters. You have to find the number of indexes a, b, c and d, such that \(1 <= a < b < c < d <= N\) and \(x_a == x_c\), as well as \(x_b == x_d\).

He is baffled and definitely needs some help. So, you, the best programmer in Lalalandia, decided to give him a hand!

Input format

The first line contains the number N - the length of a string x. The second line contains the string x itself.

Output format

The first and only line should contain the answer to the problem.

Constraints

\(1 <= N <= 2000\)

The string x only contains small English letters.

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
20 votes
Tags:
AlgorithmsLinear SearchSimulation
Points:30
135 votes
Tags:
AlgorithmsEasySearchingdifferentiation
Points:30
128 votes
Tags:
EasyPointerSearchingSets