O(n)time, O(1)space C++ solution, interesting.......


  • 1
    M
    int findLUSlength(string a, string b) {
            if(a.size()!=b.size()) return max(a.size(), b.size());
            else {
                if(a!=b) return b.size();
            }
            return -1;
        }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.