-
SLPHPython:
class Solution(object): def findLUSlength(self, a, b): """ :type a: str :type b: str :rtype: int """ return a != b and max(len(a), len(b)) or -1
-
SLPHJava:
public class Solution { public int findLUSlength(String a, String b) { int lenA = a.length(); int lenB = b.length(); if (lenA != lenB) return Math.max(lenA, lenB); else if (!a.equals(b)) return lenA; else return -1; } }
-
SLPHC++:
class Solution { public: int findLUSlength(string a, string b) { int n = a.size() , m = b.size() ; if ( n != m ) return max ( n , m ) ; if ( a == b ) return -1 ; return n ; } };
-