521. Longest Uncommon Subsequence I
来源:互联网 发布:plsql打开sql文件乱码 编辑:程序博客网 时间:2024/05/17 06:38
For strings A, B, when len(A) > len(B), the longest possible subsequence of either A or B is A, and no subsequence of B can be equal to A. Answer: len(A).
When len(A) == len(B), the only subsequence of B equal to A is B; so as long as A != B, the answer remains len(A).
When A == B, any subsequence of A can be found in B and vice versa, so the answer is -1.
class Solution(object): def findLUSlength(self, a, b): """ :type a: str :type b: str :rtype: int """ if a == b: return -1 else: return max(len(a),len(b))
0 0
- 521. Longest Uncommon Subsequence I
- 521. Longest Uncommon Subsequence I
- 521. Longest Uncommon Subsequence I
- 521. Longest Uncommon Subsequence I
- 521. Longest Uncommon Subsequence I
- 521.Longest Uncommon Subsequence I
- 521. Longest Uncommon Subsequence I
- 521. Longest Uncommon Subsequence I
- 521. Longest Uncommon Subsequence I
- 521. Longest Uncommon Subsequence I
- 521. Longest Uncommon Subsequence I
- 521. Longest Uncommon Subsequence I
- 521. Longest Uncommon Subsequence I
- 521. Longest Uncommon Subsequence I
- 521. Longest Uncommon Subsequence I
- 521. Longest Uncommon Subsequence I
- Longest Uncommon Subsequence I
- Longest Uncommon Subsequence I
- 2017.4.26 补天挖洞
- Ubuntu 16.04 安装mysql并设置远程访问
- Caffe学习:pycaffe接口配置
- php如何实现递归遍历文件目录?
- 常见的中间件有哪些?
- 521. Longest Uncommon Subsequence I
- 读书笔记《Effective C++》条款06:若不想使用编译器自动生成的函数,就该明确拒绝
- 【微信小程序源码案例】小程序项目开发案例经验分享
- 意象与文化符号、哲学范畴
- CentOS 6.3虚拟机网络环境配置
- c++第五次实验
- 极简的dp代码
- Java设计模式笔记之解释器模式
- pyenv+virtualenv+virtualenvwrapper轻量级python环境管理