Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 461ddd8

Browse files
committed
Add solution #521
1 parent b6314b4 commit 461ddd8

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* 521. Longest Uncommon Subsequence I
3+
* https://leetcode.com/problems/longest-uncommon-subsequence-i/
4+
* Difficulty: Easy
5+
*
6+
* Given two strings a and b, return the length of the longest uncommon subsequence between
7+
* a and b. If no such uncommon subsequence exists, return -1.
8+
*
9+
* An uncommon subsequence between two strings is a string that is a subsequence of exactly
10+
* one of them.
11+
*/
12+
13+
/**
14+
* @param {string} a
15+
* @param {string} b
16+
* @return {number}
17+
*/
18+
var findLUSlength = function(a, b) {
19+
return a === b ? -1 : Math.max(a.length, b.length);
20+
};

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@
227227
507|[Perfect Number](./0507-perfect-number.js)|Easy|
228228
509|[Fibonacci Number](./0509-fibonacci-number.js)|Easy|
229229
520|[Detect Capital](./0520-detect-capital.js)|Easy|
230+
521|[Longest Uncommon Subsequence I](./0521-longest-uncommon-subsequence-i.js)|Easy|
230231
541|[Reverse String II](./0541-reverse-string-ii.js)|Easy|
231232
542|[01 Matrix](./0542-01-matrix.js)|Medium|
232233
547|[Number of Provinces](./0547-number-of-provinces.js)|Medium|

0 commit comments

Comments
 (0)