Advertisement
1988coder

521. Longest Uncommon Subsequence I

Jan 5th, 2019
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.57 KB | None | 0 0
  1. // LeetCode URL: https://leetcode.com/problems/longest-uncommon-subsequence-i/
  2. /**
  3.  * Refer:
  4.  * https://leetcode.com/problems/longest-uncommon-subsequence-i/discuss/99410/I-feel-this-problem-is-just-perfect-for-April-Fools'-day/103474
  5.  *
  6.  * Time Complexity: (min(A, B))
  7.  *
  8.  * Space Complexity: O(1)
  9.  *
  10.  * A = Length of string a. B = Length of string b.
  11.  */
  12. class Solution {
  13.     public int findLUSlength(String a, String b) {
  14.         if (a == null || b == null || a.equals(b)) {
  15.             return -1;
  16.         }
  17.         return Math.max(a.length(), b.length());
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement