Loading... > https://leetcode.cn/problems/longest-uncommon-subsequence-i/description/?envType=daily-question&envId=2024-05-02 简单题,如果两个字符串相等,那么结果肯定是 $-1$ ;如果两个字符串不等,那么结果肯定是较长那个字符串的长度。 ```c++ class Solution { public: int findLUSlength(string a, string b) { return a == b ? -1 : std::max(a.length(), b.length()); } }; ``` - 时间复杂度:$O(1)$ 。 - 空间复杂度:$O(1)$ 。 最后修改:2024 年 06 月 17 日 © 允许规范转载 赞 如果觉得我的文章对你有用,请随意赞赏