力扣(leetcode)第389题找不同(Python)

389.找不同

题目链接:389.找不同

给定两个字符串 s 和 t ,它们只包含小写字母。

字符串 t 由字符串 s 随机重排,然后在随机位置添加一个字母。

请找出在 t 中被添加的字母。

示例 1:

输入:s = "abcd", t = "abcde"

输出:"e"

解释:'e' 是那个被添加的字母。
示例 2:

输入:s = "", t = "y"

输出:"y"

提示:

0 <= s.length <= 1000

t.length == s.length + 1

s 和 t 只包含小写字母

解答

python 复制代码
class Solution:
    def findTheDifference(self, s: str, t: str) -> str:
        s = list(s)
        t = list(t)
        for i in s:
            t.pop(t.index(i))
        return t[0]

最后,我写了一篇MySQL教程,里面详细的介绍了MySQL的基本概念以及操作指令等内容,欢迎阅读!
MySQL数据库万字保姆级教程

相关推荐
alexhilton6 小时前
端侧RAG实战指南
android·kotlin·android jetpack
helloweilei12 小时前
python 抽象基类
python
用户83562907805112 小时前
Python 实现 PPT 转 HTML
后端·python
CoovallyAIHub14 小时前
语音AI Agent编排框架!Pipecat斩获10K+ Star,60+集成开箱即用,亚秒级对话延迟接近真人反应速度!
深度学习·算法·计算机视觉
二流小码农14 小时前
鸿蒙开发:路由组件升级,支持页面一键创建
android·ios·harmonyos
xq952716 小时前
Android 手游SDK组件化开发实战指南
android
木心月转码ing16 小时前
Hot100-Day14-T33搜索旋转排序数组
算法
zone773918 小时前
004:RAG 入门-LangChain读取PDF
后端·python·面试
煤球王子18 小时前
学习记录:Android14中的WiFi-wpa_supplicant(1)
android
zone773918 小时前
005:RAG 入门-LangChain读取表格数据
后端·python·agent