Longest Uncommon Subsequence I

easy string

Problem

Given two strings a and b, return the length of the longest uncommon subsequence — a subsequence of one string that is not a subsequence of the other. Return −1 if none exists.

Inputa = "aba", b = "cdc"
Output3
"aba" itself is a subsequence of a but not of b.

def find_lus_length(a, b):
    if a == b:
        return -1
    return max(len(a), len(b))
function findLUSlength(a, b) {
  if (a === b) return -1;
  return Math.max(a.length, b.length);
}
class Solution {
    public int findLUSlength(String a, String b) {
        if (a.equals(b)) return -1;
        return Math.max(a.length(), b.length());
    }
}
int findLUSlength(string a, string b) {
    if (a == b) return -1;
    return max((int)a.size(), (int)b.size());
}
Time: O(n) Space: O(1)