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的更多相关文章

  1. 【LeetCode】521. Longest Uncommon Subsequence I 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 日期 题目地址:https://leetcode.c ...

  2. 【LeetCode】522. Longest Uncommon Subsequence II 解题报告(Python)

    [LeetCode]522. Longest Uncommon Subsequence II 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemin ...

  3. 【leetcode】522. Longest Uncommon Subsequence II

    题目如下: 解题思路:因为given list长度最多是50,我的解法就比较随意了,直接用一个嵌套的循环,判断数组中每个元素是否是其他的subsequence,最后找出不属于任何元素subsequen ...

  4. LeetCode: 521 Longest Uncommon Subsequence I(easy)

    题目: anysubsequence of the other strings. A subsequence is a sequence that can be derived from one se ...

  5. 【leetcode】300.Longest Increasing Subsequence

    Given an unsorted array of integers, find the length of longest increasing subsequence. For example, ...

  6. 【LeetCode】594. Longest Harmonious Subsequence 解题报告(Python & C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 统计次数 日期 题目地址:https://leetc ...

  7. 【LeetCode】516. Longest Palindromic Subsequence 最长回文子序列

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题思路 代码 刷题心得 日期 题目地址:https://le ...

  8. 【LeetCode】300. Longest Increasing Subsequence 解题报告(Python & C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 日期 题目地址:https://leetcode.c ...

  9. 【leetcode】1218. Longest Arithmetic Subsequence of Given Difference

    题目如下: Given an integer array arr and an integer difference, return the length of the longest subsequ ...

随机推荐

  1. Windows10官方正版系统的安装、激活、升级、U盘制作,无毒无害无捆绑无风险教程

    一般电脑系统出了其他问题或电脑用久太卡了,可以选择此类方法解决系统卡顿问题,重置电脑系统或也可以恢复出厂设置 如果出现重置找不到恢复环境问题 可以通过下载系统镜像来解决,进入 MSDN 网站下载所需系 ...

  2. selenium 显示等待wait.until 常用封装 及下拉框的选择操作等

    from selenium.webdriver.common.by import Byfrom selenium.webdriver.support.ui import WebDriverWait a ...

  3. python3 pyinstaller

    一.安装python.pywin32.pyinstaller库 二.官网:https://pyinstaller.readthedocs.io/en/v3.3.1/usage.html#general ...

  4. 修改HTTPS加密协议TLS1.0为TLS1.2

    一:首先为什么要改为TLS1.2 因为各大浏览器相继发布声明将停止支持 TLS 1.0 和 TLS 1.1 https://www.cnblogs.com/jpush88/p/9846047.html ...

  5. 场效应管种类-场效应管N、P沟道与增强、耗尽型工作原理等知识详解 如何选用晶体三极管与场效应管的技巧

    http://www.kiaic.com/article/detail/1308.html 场效应管种类场效应管 场效应晶体管(Field Effect Transistor缩写(FET))简称场效应 ...

  6. redis在linux服务器部署

    0)参考资料 http://www.cnblogs.com/liuling/p/2014-4-19-02.html 1)下载安装包地址 http://download.redis.io/release ...

  7. web超大文件上传

    文件夹数据库处理逻辑 publicclass DbFolder { JSONObject root; public DbFolder() { this.root = new JSONObject(); ...

  8. const char*p,char const*p,char *const p

    转自 http://blog.csdn.net/todd911/article/details/7911995 const char*, char const*, char*const的区别问题几乎是 ...

  9. Asp.Net跨平台 Jexus 5.8.1 独立版

    在Linux上运行ASP.NET网站或WebApi的传统步骤是,先安装libgdiplus,再安装mono,然后安装Jexus.在这个过程中,虽然安装Jexus是挺简便的一件事,但是安装mono就相对 ...

  10. c++ 容器反转并且拷贝到一个新容器中

    // reverse_copy example #include <iostream> // cout #include <algorithm> // reverse_copy ...