LeetCode 521. 最长特殊序列 Ⅰ
原题链接
简单
作者:
bruce
,
2021-01-03 00:56:42
,
所有人可见
,
阅读 364
#include <iostream>
#include <vector>
#include <string>
using namespace std;
/**
* 521 给定两个字符串,然后判断最长公共子序列是多少
* Input: a = "aba", b = "cdc"
* Output: 3
* Explanation: One longest uncommon subsequence is "aba" because "aba" is a subsequence of "aba" but not "cdc".
* Note that "cdc" is also a longest uncommon subsequence
*/
/**
* 方法 1,两个字符串要是不等,那么就返回最长的那个,否则返回-1
*/
int findLUSlength(string a, string b)
{
return a == b ? -1 : max(a.size(), b.size());
}