15 Jun 2024C++ / Python / TypeScriptEasy

Longest Uncommon Subsequence I

Collected C++, Python, TypeScript solutions for longest uncommon subsequence i. Add a dedicated write-up later if you want deeper notes.

auto-generated entry for Longest Uncommon Subsequence I. the solution files are available below.

solution files

  • C++ longest-uncommon-subsequence-i/synced-solution.cpp
  • Python longest-uncommon-subsequence-i/synced-solution.py
  • TypeScript longest-uncommon-subsequence-i/synced-solution.ts

Solution files

Pythonlongest-uncommon-subsequence-i/synced-solution.py
class Solution:
    def findLUSlength(self, a: str, b: str) -> int:
        return -class="syntax-number">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 ? -class="syntax-number">1 : max(a.size(), b.size());
    }
};
TypeScriptlongest-uncommon-subsequence-i/synced-solution.ts
function findLUSlength(a: string, b: string): number {
    return a === b ? -class="syntax-number">1 : Math.max(a.length, b.length);
}