【leetcode】521. Longest Uncommon Subsequence I
problem
521. Longest Uncommon Subsequence I
题意:
两个字符串的情况很少,如果两个字符串相等,那么一定没有非共同子序列,反之,如果两个字符串不等,那么较长的那个字符串就是最长非共同子序列。
solution:
class Solution {
public:
int findLUSlength(string a, string b) {
if(a==b) return -;
return max(a.size(), b.size());
}
};
or
class Solution {
public:
int findLUSlength(string a, string b) {
//if(a==b) return -1;
return a==b ? - : max(a.size(), b.size());
}
};
参考
1. Leetcode_521. Longest Uncommon Subsequence I;
2. Grandyang_最长非共同子序列之一;
完
【leetcode】521. Longest Uncommon Subsequence I的更多相关文章
- 【LeetCode】521. Longest Uncommon Subsequence I 解题报告(Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 日期 题目地址:https://leetcode.c ...
- 【LeetCode】522. Longest Uncommon Subsequence II 解题报告(Python)
[LeetCode]522. Longest Uncommon Subsequence II 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemin ...
- 【leetcode】522. Longest Uncommon Subsequence II
题目如下: 解题思路:因为given list长度最多是50,我的解法就比较随意了,直接用一个嵌套的循环,判断数组中每个元素是否是其他的subsequence,最后找出不属于任何元素subsequen ...
- LeetCode: 521 Longest Uncommon Subsequence I(easy)
题目: anysubsequence of the other strings. A subsequence is a sequence that can be derived from one se ...
- 【leetcode】300.Longest Increasing Subsequence
Given an unsorted array of integers, find the length of longest increasing subsequence. For example, ...
- 【LeetCode】594. Longest Harmonious Subsequence 解题报告(Python & C++)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 统计次数 日期 题目地址:https://leetc ...
- 【LeetCode】516. Longest Palindromic Subsequence 最长回文子序列
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题思路 代码 刷题心得 日期 题目地址:https://le ...
- 【LeetCode】300. Longest Increasing Subsequence 解题报告(Python & C++)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 日期 题目地址:https://leetcode.c ...
- 【leetcode】1218. Longest Arithmetic Subsequence of Given Difference
题目如下: Given an integer array arr and an integer difference, return the length of the longest subsequ ...
随机推荐
- Array 和 ArrayList 有何区别?(未完成)
Array 和 ArrayList 有何区别?(未完成)
- tp5 左连接
db('detainform')->alias('d')->join("information i",'i.z_id=d.z_id','LEFT')->where ...
- PHP获取不到url传递参数中#&等特殊字符解决方法
有些符号在URL中是不能直接传递的,无法传入PHP处理,比如#&等符号,通过$_GET是获取不到的,比如一个域名https://localhost/url.php?url=yangyufei+ ...
- adb连接MUMU模拟器
参考:http://mumu.163.com/2017/12/19/25241_730476.html?type=notice 通过adb就可以像操作linux一样来看看模拟器的文件什么的,难道刷机就 ...
- Qt中使用匿名函数lambda表达式
一.为什么要使用匿名函数lamdba 首先,lambda表达式可以使代码变得简单,C++中,一个lambda表达式表示一个可调用的代码单元.如代码: #include <QCoreApplica ...
- lnmp安装xdebug ,配合phpstorm断点调试
先下载xdebug wget http://www.xdebug.org/files/xdebug-2.2.3.tgz 然后开始编译(权限不够的加上 sudo 提成权限) tar xzf xdebug ...
- [cf1138BCircus][枚举,列等式]
https://codeforc.es/contest/1138/problem/B B. Circus time limit per test 1 second memory limit per t ...
- [Google Guava] 2.4-集合扩展工具类
原文链接 译文链接 译者:沈义扬,校对:丁一 简介 有时候你需要实现自己的集合扩展.也许你想要在元素被添加到列表时增加特定的行为,或者你想实现一个Iterable,其底层实际上是遍历数据库查询的结果集 ...
- 解决每次执行Java等命令时都要重新source /etc/profile后才能执行,否则找不到命令
linux mint 我们通常将环境变量设置在/etc/profile这个文件中,这个文件是全局的. /etc/profile:在登录时,操作系 统定制用户环境时使用的第一个文件 ,此文件为系统的每个 ...
- Python 15__屏幕抓取