[LeetCode]521. Longest Uncommon Subsequence I

Python与西门子PLC数据交互实战:基于Snap7的跨平台工业通信指南 本文详细介绍了如何使用Python和Snap7库实现与西门子PLC的数据交互。内容涵盖跨平台环境搭建、连接参数配置、数据读写实战及性能优化技巧,为工业自动化、数据采集和智能制造场景提供了一套轻量、灵活且高效的通信解决方案。 阅读详情

[LeetCode]521. Longest Uncommon Subsequence I

题目描述

这里写图片描述

思路

题目描述大坑
看到要求最长非公共子序列,我以为意思是求出的子序列中不能和输入的字符串有公共子序列,动归都写好了,然后发现a不了

代码

实际ac代码

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

class Solution {
public:
    int findUSlength(string a, string b) {
        if (a == b)
            return -1;
        return max(a.size(), b.size());
    }
};

int main() {
    Solution s;
    cout << s.findUSlength("aefawfawfawfaw", "aefawfeawfwafwaef") << endl;

    system("pause");
    return 0;
}

动归代码

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

class Solution {
public:
    int findUSlength(string a, string b) {
        int m = a.size(), n = b.size(), maxSub = 0;
        vector<vector<int>> dp(m, vector<int>(n));
        for (int i = 0; i < m; ++i) {
            for (int j = 0; j < n; ++j) {
                if (i == 0 || j == 0)
                    dp[i][j] = a[i] == b[j];
                else
                    dp[i][j] = (a[i] == b[j]) + dp[i - 1][j - 1];
                maxSub = max(maxSub, dp[i][j]);
            }
        }
        return max(m, n) - maxSub != 0 ? min(m, n) - maxSub : -1;
    }
};

int main() {
    Solution s;
    cout << s.findUSlength("aefawfawfawfaw", "aefawfeawfwafwaef") << endl;

    system("pause");
    return 0;
}
华为防火墙双线路配置实战:5分钟搞定主备自动切换(含健康检查避坑指南) 本文详细介绍了华为防火墙双线路配置实战,包括主备自动切换和健康检查机制的优化技巧。通过智能健康检查机制,华为防火墙能实现毫秒级故障自动切换,确保网络高可用性。文章提供了从架构设计到实战配置的全流程指南,并分享了常见配置误区与解决方案,帮助中小企业快速搭建稳定可靠的网络架构。 阅读详情

相关推荐

Spring AI + RAG 构建电商智能客服:从 PDF 文档解析到精准问答的全链路实战

核心框架:向量数据库:- PostgreSQL + pgvector (生产推荐)- Redis Stack (轻量级方案)- ChromaDB (快速原型)文档解析:- Apache PDFBox: PDF 文本提取- Spring AI Document Readers: 结构化解析大模型:- 阿里云百炼 (DashScope)- 本地部署:Qwen/ChatGLM/*** 电商领域实体*/@Data@Builder@ToString/*** 商品类型。

一起修行,不孤单。这里有编程语言、开发工具、学习方法论和踩坑笔记。用简单的话说复杂的事,陪你从小白到进阶。周更干货,欢迎一起成长! 396

Leetcode 521. 最长特殊序列 Ⅰ C++

Leetcode 521. 最长特殊序列 Ⅰ 题目 给你两个字符串,请你从这两个字符串中找出最长的特殊序列。 「最长特殊序列」定义如下:该序列为某字符串独有的最长子序列(即不能是其他字符串的子序列)。 子序列 可以通过删去字符串中的某些字符实现,但不能改变剩余字符的相对顺序。空序列为所有字符串的子序列,任何字符串为其自身的子序列。 输入为两个字符串,输出最长特殊序列的长度。如果不存在,则返回 -1。 测试样例 示例 1: 输入: "aba", "cdc" 输出: 3 解释: 最长特殊序列可为 "aba" (

weixin_43750513的博客 296

OpenCV机械臂手眼标定

这篇文章总结了手眼标定的原理,利用OpenCV自带的函数套用参数即可完成眼在手上和眼在手外两种标定。

Q先森的博客 6604

LeetCode 521. 最长特殊序列 Ⅰ题解

521. 最长特殊序列 Ⅰ题解 题目来源:521. 最长特殊序列 Ⅰ 2022.03.05 每日一题 每日一题专栏地址:LeetCode 每日一题题解更新中❤️💕

小明不要写Bug的博客 289

ZYNQ学习:PL端DDR3 读写测试

DDR SDRAM 的最大特点是双沿触发,即在时钟的上升沿和下降沿都能进行数据采集和发送,同样的工作时钟, DDR SDRAM 的读写速度可以比传统的 SDRAM 快一倍。本次实验使用的 DDR3 芯片是南亚的 NT5CC256M16ER-EKI, NT5CC256M16ER-EKI 的 bank 位宽为 3,行位宽为 15,列位宽为 10,所以它的地址大小等于 2^3*2^15*2^10(即 2^28=256M),数据位宽为 16bit,所以容量大小为 256M*16bit,也就是 512MByte。

shuidiQAQ的博客 3038

手把手教你用Python 3.11和Node.js 18在Windows 11上搭建Dify开发环境

本文提供了一份详尽的Windows 11本地Dify开发环境搭建指南。文章手把手教你完成从Python 3.11、Node.js 18的安装配置,到PostgreSQL、Redis数据库服务的部署,再到前后端服务的启动与联调的全过程,并包含常见问题排查与效能优化建议,旨在帮助开发者构建一个稳定、可调试的Dify本地开发环境。

fire9的博客 652

Leetcode 521.最长特殊序列 I

思维

cwtnice的博客 948

PHP特性知识点总结

(1)类型转换之前提到过的是字符串转为整型。其实php手册里面提到了各种类型的转换。先把他放在这里。我们按照php手册上的顺序来介绍,只介绍几个比较常用的。①转化为bool②转化为整型int。

m0_73605862的博客 1302

python leetcode刷题 (47):521. 最长特殊序列 Ⅰ

题目描述: 给定两个字符串,你需要从这两个字符串中找出最长的特殊序列。最长特殊序列定义如下:该序列为某字符串独有的最长子序列(即不能是其他字符串的子序列)。 子序列可以通过删去字符串中的某些字符实现,但不能改变剩余字符的相对顺序。空序列为所有字符串的子序列,任何字符串为其自身的子序列。 输入为两个字符串,输出最长特殊序列的长度。如果不存在,则返回 -1。 示例 : 输入: “aba”, “cdc”...

weixin_42785446的博客 335

Unity的粒子系统使用shadergraph(内置管线)制作的一个顶点偏移shader,但是粒子模型移动时,顶点也会偏移?

🏆本文收录于 《全栈Bug调优(实战版)》 专栏,该专栏专注于分享我在真实项目开发中遇到的各类疑难Bug及其深层成因,并系统提供高效、可复现的解决思路和实操方案。无论你是刚入行的新手开发者,还是拥有多年项目经验的资深工程师,本专栏都将为你提供一条系统化、高质量的问题排查与优化路径,助力你加速成长,攻克技术壁垒,迈向技术价值最大化与职业发展的更高峰🚀!

**My Coding Family** 1181

【Python LeetCode 专题】面试经典 150 题

面试经典 150 题

一杯水果茶!足矣~ 1190

leetcode521+最长非共同子序列, trick题目

https://leetcode.com/problems/longest-uncommon-subsequence-i/description/ class Solution { public: int findLUSlength(string a, string b) { return a==b?-1: max(a.size(), b.size()); } ...

小堃哥的专栏 260

Oracle EBS 中美国销售税的实现方式

Oracle EBS通过eBTax引擎实现美国销售税管理,需配置税务管辖区、税率及规则等要素,基于收货地址和商品分类计税。系统支持免税交易和使用税处理,但因美国税率复杂多变,建议集成Vertex等第三方服务自动更新税率。关键配置包括创建USSales Tax制度、维护地点层级及物料税务分类,同时需管理客户免税证书。对于跨国业务,系统也支持欧盟VAT等其他国家税制配置。

金牌架构师 308

LeetCode //C - 521. Longest Uncommon Subsequence I

【代码】LeetCode //C - 521. Longest Uncommon Subsequence I。

Made in Code 1676

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

python leetcode 521. Longest Uncommon Subsequence I

Given a group of two strings, you need to find the longest uncommon subsequence of this group of two strings. The longest uncommon subsequence is defined as the longest subsequence of one of these str...

DreamerLHQ的博客 278

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

【leetcode】521. Longest Uncommon Subsequence I

problem 521.Longest Uncommon Subsequence I 最长非共同子序列之一 题意: 两个字符串的情况很少,如果两个字符串相等,那么一定没有非共同子序列,反之,如果两个字符串不等,那么较长的那个字符串就是最长非共同子序列。 solution: class Solution { public: int findLUSlength(stri...

weixin_30918415的博客 68

[leetcode]: 521. Longest Uncommon Subsequence I

1.题目描述Given a group of two strings, you need to find the longest uncommon subsequence of this group of two strings. The longest uncommon subsequence is defined as the longest subsequence of one of thes

沐沐余风的专栏 387

【Leetcode】521. Longest Uncommon Subsequence I

思路: 比较两个字符串的长度,若不相等,则返回长度的较大值,若相等则再判断两个字符串是否相同,若相同则返回-1,否则返回长度。 public class Solution { public int findLUSlength(String a, String b) { int lenA = a.length(); int lenB = b.length(

筱葭的博客 3285

Leetcode——521. Longest Uncommon Subsequence I

题目原址 https://leetcode.com/problems/longest-uncommon-subsequence-i/description/ 题目描述 Given a group of two strings, you need to find the longest uncommon subsequence of this group of two strings. The...

想当厨子的程序媛 225

【LeetCode】521. Longest Uncommon Subsequence I

Python版本:python3.6.2 521. Longest Uncommon Subsequence I Given a group of two strings, you need to find the longest uncommon subsequence of this group of two strings. The longest uncommon sub

sunflower_kris的博客 349

[leetcode]521. Longest Uncommon Subsequence I

题目链接题目描述 Given a group of two strings, you need to find the longest uncommon subsequence of this group of two strings. The longest uncommon subsequence is defined as the longest subsequence of one of

zsensei的博客 914

LeetCode: 521. Longest Uncommon Subsequence I

LeetCode: 521. Longest Uncommon Subsequence I Given a group of two strings, you need to find the longest uncommon subsequence of this group of two strings. The longest uncommon subsequence is d

qha0731的专栏 408

LeetCode 521. Longest Uncommon Subsequence I

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

Victor Sheng 535

[leetcode] 521. Longest Uncommon Subsequence I

Description Given a group of two strings, you need to find the longest uncommon subsequence of this group of two strings. The longest uncommon subsequence is defined as the longest subsequence of one ...

Learning from the mistakes 128

LeetCode | 521. Longest Uncommon Subsequence I

题目 Given two strings a and b, return the length of the longest uncommon subsequence between a and b. If the longest uncommon subsequence does not exist, return -1. An uncommon subsequence between two strings is a string that is a subsequence of one but not

iLOVEJohnny的博客 487

[Leetcode] 521. Longest Uncommon Subsequence I

Description: Given a group of two strings, you need to find the longest uncommon subsequence of this group of two strings. The longest uncommon subsequence is defined as the longest subsequence of on...

ApRiLLLLLLLLLLLL的博客 238
上一篇: [LeetCode]561. Array Partition I
下一篇: [LeetCode]530. Minimum Absolute Difference in BST
charon____
博客等级 码龄11年 3粉丝 202原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值