Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Python/Longest_Uncommon_Subsequence.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#Link Of Question :https://leetcode.com/problems/longest-uncommon-subsequence-i/
#134. Longest Uncommon Subsequence I
#Given two strings a and b, return the length of the longest uncommon subsequence between a and b. If the longest uncommon subsequence does not exist, return -1
#Solution :

class Solution:
def findLUSlength(self, a: str, b: str) -> int:
if a!=b:
return max(len(a),len(b))
return -1



#Sample Input 1 : a = "aaa", b = "bbb"
#Sample output 1 : 3

#Sample input 2 : a = "aaa", b = "aaa"
#Sample output 1 : -1
1 change: 1 addition & 0 deletions Python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
2 : Missing Number<br>
3 : Peak Element <br>
7 : Reverse Integer<br>
521 : Longest Uncommon Subsequence I<br>