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. 顺利通过EMC实验(17)

  2. Vue的computed(计算属性)使用实例之TodoList

    最近倒腾了一会vue,有点迷惑其中methods与computed这两个属性的区别,所以试着写了TodoList这个demo,(好土掩面逃~); 1. methods methods类似react中组 ...

  3. 基于canvas和web audio实现低配版MikuTap

    导言 最近发掘了一个特别happy的网页小游戏--MikuTap.打开之后沉迷了一下午,导致开发工作没做完差点就要删库跑路了,还好boss瞥了我一眼就没下文了.于是第二天我就继续沉迷,随着一阵抽搐,这 ...

  4. 【SpringBoot实战】数据访问

    前言 在开发中我们通常会对数据库的数据进行操作,SpringBoot对关系性和非关系型数据库的访问操作都提供了非常好的整合支持.SpringData是spring提供的一个用于简化数据库访问.支持云服 ...

  5. php代码审计之——phpstorm动态调试

    xdebug调试 调试环境部署 xdebug的版本需要与PHP版本相对于,所以不要轻易改变PHP环境版本. 0 配置php解析器 1 下载对应版本的xdebug xdebug官网下载地址:https: ...

  6. Java学习day31

    同步方法的机制:synchronized,包括synchronized方法和synchronized块 同步方法:public synchronized void method(int args){ ...

  7. Linux的软件安装tomcat 以及jdk

    因为tomcat的启动需要jdk,所以我们先安装jdk,安装完成后再安装tomcat 具体的文件大家可以到官网下载,下面介绍安装步骤 目录 jdk安装 1.通过xftp或者其他方式将安装包传到我们的L ...

  8. async异步函数的执行顺序

    1 async function async1(){ 2 console.log('async1 start') //2 3 await async2() 4 //await async2()后面的内 ...

  9. oracle创建dblink注意事项 ORA-04052

    BEGIN; oracle创建dblink语句: create database link dblink名称 connect to 用户名 identified by 密码 using '(DESCR ...

  10. 终极套娃 2.0|云原生 PaaS 平台的可观测性实践分享

    某个周一上午,小涛像往常一样泡上一杯热咖啡 ️,准备打开项目协同开始新一天的工作,突然隔壁的小文喊道:"快看,用户支持群里炸锅了 -" 用户 A:"Git 服务有点问题, ...