DeepSeek Interview Question

How to count all reverse pairs in a string