力扣(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数据库万字保姆级教程

相关推荐
兵慌码乱6 小时前
基于 MediaPipe 与 PySide2 的手势交互音乐控制系统实现:轻量化视觉交互全流程解析
python·opencv·计算机视觉·人机交互·手势识别·mediapipe·pyside2
恋猫de小郭7 小时前
Android 限制侧载新进展,谷歌联合国内厂商推验证计划
android·前端·flutter
恋猫de小郭7 小时前
解读 Android 17 全新内存限制,有没有“豁免”后门?
android·前端·flutter
luckdewei8 小时前
FastAPI 资产管理系统实战:复杂 ORM 关联、Alembic 迁移与 N+1 查询优化
python
贾艺驰9 小时前
实战Android Framework: 新增一个系统权限
android
alexhilton14 小时前
使用Android Archive进行打包
android·kotlin·android jetpack
aqi0014 小时前
15天学会AI应用开发(八)使用向量数据库实现RAG功能
人工智能·python·大模型·ai编程·ai应用
Csvn15 小时前
`functools.lru_cache` —— 一行代码搞定缓存加速
后端·python
badhope16 小时前
做了几年安卓开发,这些坑我帮你踩过了
android·android studio