leetcode 1624. 两个相同字符之间的最长子字符串

it2026-01-02  9

class Solution { public: int maxLengthBetweenEqualCharacters(string s) { int res = -1; for(int i = 0; i < size(s); i ++){ for(int j = i + 1; j < size(s); j ++){ if(s[i] == s[j]) res = max(res, j - i - 1); } } return res; } };
最新回复(0)