【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 ...
随机推荐
- JS 禁用按钮10秒方法
方式一:禁用10秒,10秒钟后可用 /** * 按钮禁用10秒 * @param submitButtonName 按钮ID名 */ function disabledSubmitButton(sub ...
- 如何DIY个性PE
前言:有时候在网络上能找到很不错的PE(无忧启动论坛),但是有时候PE的功能仍不能满足自己的需要(软件过旧,缺少某些功能),这时候就显得自己DIYPE的重要性 需要的工具: WIMTOOL(必备) 软 ...
- Java 实现简单的SQL动态组装工具类
第一版 package com.zh.oukele.util; import java.util.HashMap; import java.util.Iterator; import java.uti ...
- centos 7.3 开放端口并对外开放
查看已打开的端口 # netstat -anp 查看想开的端口是否已开 # firewall-cmd --query-port=666/tcp 若此提示 FirewallD is not runnin ...
- 为什么添加了@Aspect 还要加@Component(转)
官方文档中有写: You may register aspect classes as regular beans in your Spring XML configuration, or autod ...
- 13、Spring Boot 2.x 多数据源配置
1.13 Spring Boot 2.x 多数据源配置 完整源码: Spring-Boot-Demos
- ckeditor不能粘贴word的问题
在之前在工作中遇到在富文本编辑器中粘贴图片不能展示的问题,于是各种网上扒拉,终于找到解决方案,在这里感谢一下知乎中众大神以及TheViper. 通过知乎提供的思路找到粘贴的原理,通过TheViper找 ...
- uname/hostname
uname 显示操作系统相关信息的命令. hostname 显示或者设置当前系统的主机名 修改hostname
- 数据分析九:互联网征信中的信用评分模型(用户APP使用行为分析)
用户APP使用行为数据分析: 一. 背景及数据介绍: 1. 移动互联网发展背景: 网民规模7.72亿,手机网民规模7.53亿: 2. APP使用热点: 商务交易类应用规模高速增长(网络购物,网上外卖, ...
- Bzoj 3036: 绿豆蛙的归宿(期望)
3036: 绿豆蛙的归宿 Time Limit: 2 Sec Memory Limit: 128 MB Description 随着新版百度空间的下线,Blog宠物绿豆蛙完成了它的使命,去寻找它新的归 ...