Isaac Emmanuel
15 Jun 2024•EasyC++ / Python / TypeScript

Longest Uncommon Subsequence I

C++, Python and TypeScript solutions for Longest Uncommon Subsequence I.

The Longest Uncommon Subsequence I solutions are below.

Solution files

Python•longest-uncommon-subsequence-i/synced-solution.py
class Solution:
    def findLUSlength(self, a: str, b: str) -> int:
        return -1 if a == b else max(len(a), len(b))
C++•longest-uncommon-subsequence-i/synced-solution.cpp
class Solution {
public:
    int findLUSlength(string a, string b) {
        return a == b ? -1 : max(a.size(), b.size());
    }
};
TypeScript•longest-uncommon-subsequence-i/synced-solution.ts
function findLUSlength(a: string, b: string): number {
    return a === b ? -1 : Math.max(a.length, b.length);
}