Please solve the programming task below using a self-contained code snippet in a markdown code block.

You are given a string text. You can swap two of the characters in the text.
Return the length of the longest substring with repeated characters.
 
Please complete the following python code precisely:
```python
class Solution:
    def maxRepOpt1(self, text: str) -> int:
```