brute-force [c++]🔥
Complexity

Time complexity:
O(n2)


Space complexity:
O(1)

Code
# Complexity
- Time complexity:
$$O(n^2)$$

- Space complexity:
$$O(1)$$

# Code
```cpp []
class Solution {
public:
    int maxLengthBetweenEqualCharacters(string s) {
        int maxi = -1;

        for (int i = 0; i < s.length(); ++i) {
            for (int j = i + 1; j < s.length(); ++j) {
                if (s[i] == s[j]) {
                    maxi = max((j - i) - 1, maxi);
                }
            }
        }

        return maxi;
    }
};
```
['String', 'C++']