Question

521. Longest Uncommon Subsequence I

Solution

题目大意:给两个字符串,找出非共同子串的最大长度

思路:字符串相等就返回-1,不等就返回长度大的那个长度

Java实现:

public int findLUSlength(String a, String b) {
int aLength = a.length();
int bLength = b.length();
if (aLength != bLength) return Math.max(aLength, bLength);
if (a.equals(b)) return -1;
return aLength;
}

2

public int findLUSlength(String a, String b) {
if (a.equals(b)) return -1;
return Math.max(a.length(), b.length());
}

521. Longest Uncommon Subsequence I - LeetCode的更多相关文章

  1. Leetcode#521. Longest Uncommon Subsequence I(最长特殊序列 Ⅰ)

    题目描述 给定两个字符串,你需要从这两个字符串中找出最长的特殊序列.最长特殊序列定义如下:该序列为某字符串独有的最长子序列(即不能是其他字符串的子序列). 子序列可以通过删去字符串中的某些字符实现,但 ...

  2. 【leetcode】521. Longest Uncommon Subsequence I

    problem 521. Longest Uncommon Subsequence I 最长非共同子序列之一 题意: 两个字符串的情况很少,如果两个字符串相等,那么一定没有非共同子序列,反之,如果两个 ...

  3. 521. Longest Uncommon Subsequence I【easy】

    521. Longest Uncommon Subsequence I[easy] Given a group of two strings, you need to find the longest ...

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

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

  5. LeetCode 521 Longest Uncommon Subsequence I 解题报告

    题目要求 Given a group of two strings, you need to find the longest uncommon subsequence of this group o ...

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

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

  7. *521. Longest Uncommon Subsequence I (bit manipulation 2^n)

    Given a group of two strings, you need to find the longest uncommon subsequence of this group of two ...

  8. 521 Longest Uncommon Subsequence I 最长特殊序列 Ⅰ

    给定两个字符串,你需要从这两个字符串中找出最长的特殊序列.最长特殊序列定义如下:该序列为某字符串独有的最长子序列(即不能是其他字符串的子序列).子序列可以通过删去字符串中的某些字符实现,但不能改变剩余 ...

  9. 521. Longest Uncommon Subsequence I

    static int wing=[]() { std::ios::sync_with_stdio(false); cin.tie(NULL); ; }(); class Solution { publ ...

随机推荐

  1. 1、Jetson Nano 远程桌面XP问题

    jeston nano上网 方法3(最简单的方法) 最简单的方法真的特简单,用USB数据线连接主板的USB接口以及手机,打开手机的USB共享即可,若要使用静态IP,可在主板上修改配置文件,接口一般为u ...

  2. USB3.0接口EMC设计标准电路

  3. Qunee for HTML5 v1.6新版本发布

    Qunee for HTML5 V1.6正式发布,修复了一些 BUG,增加了滚动条支持,改进了编辑器,增加了JSON 导入导出.告警冒泡.连线流动,UI 定制等扩展示例,欢迎 访问 导航面板 增加了滚 ...

  4. 【译】客户端存储(Client-Side Storage)

    本文转载自:众成翻译译者:文蔺链接:http://www.zcfy.cc/article/660原文:http://www.html5rocks.com/en/tutorials/offline/st ...

  5. HTML5与类有关的扩充

    对于传统HTML而言,HTML5是一个叛逆.所有之前的版本对JavaScript接口的描述都不过三言两语,主要篇幅都用于定义标记,与JavaScript相关的内容一概交由DOM规范去定义. 而HTML ...

  6. Linux安装JDK报错

    报错内容: tar (child): jdk-8u141-linux-x64.tar.gz: Cannot open: No such file or directory tar (child): E ...

  7. [ Vim ] 自动重载文件

    https://www.cnblogs.com/yeungchie/ 手动重载 :e 或者 :! 自动重载 set autoread 一般情况下,vim 切换缓冲区或者重新聚焦的时候会触发重载. 如果 ...

  8. OpenHarmony 3.1 Beta版本关键特性解析——HiStreamer框架大揭秘

    ​(以下内容来自开发者分享,不代表 OpenHarmony 项目群工作委员会观点)​ 陈国栋 数字多媒体技术在过去的数十年里得到了飞速的发展,多媒体终端设备如智能音箱.智能门锁.智能手表广泛应用于人们 ...

  9. 2021.11.03 P6175 无向图的最小环问题

    2021.11.03 P6175 无向图的最小环问题 P6175 无向图的最小环问题 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn) 题意: 给定一张无向图,求图中一个至少包含 33 ...

  10. 《图解UE4渲染体系》Part 0 引擎基础

    在介绍UE4渲染体系前,我们有必要来先看一下UE4是用什么样的方式来构建游戏场景数据的. 1 Object 在UE4中当我们说Object,通常是指代引擎代码中的UObject类,它是引擎里管理绝大部 ...