question:

Given two strings s and t which consist of only lowercase letters.

String t is generated by random shuffling string s and then add one more letter at a random position.

Find the letter that was added in t.

my answer:

代码看起来有些长,目前还没有想到更好的办法

思路:

将两个字符串分别变成list, 再将list一个个的遍历,获得每个字母对应的个数的字典,再比较两个字典之间的差异。

出错点:

在比较两个字典之间的差异时,是两个条件,一开始忽略了i not in s 这个条件

leetcode笔记--7 Find the Difference的更多相关文章

  1. Leetcode 笔记 113 - Path Sum II

    题目链接:Path Sum II | LeetCode OJ Given a binary tree and a sum, find all root-to-leaf paths where each ...

  2. Leetcode 笔记 112 - Path Sum

    题目链接:Path Sum | LeetCode OJ Given a binary tree and a sum, determine if the tree has a root-to-leaf ...

  3. Leetcode 笔记 110 - Balanced Binary Tree

    题目链接:Balanced Binary Tree | LeetCode OJ Given a binary tree, determine if it is height-balanced. For ...

  4. Leetcode 笔记 100 - Same Tree

    题目链接:Same Tree | LeetCode OJ Given two binary trees, write a function to check if they are equal or ...

  5. Leetcode 笔记 99 - Recover Binary Search Tree

    题目链接:Recover Binary Search Tree | LeetCode OJ Two elements of a binary search tree (BST) are swapped ...

  6. Leetcode 笔记 98 - Validate Binary Search Tree

    题目链接:Validate Binary Search Tree | LeetCode OJ Given a binary tree, determine if it is a valid binar ...

  7. Leetcode 笔记 101 - Symmetric Tree

    题目链接:Symmetric Tree | LeetCode OJ Given a binary tree, check whether it is a mirror of itself (ie, s ...

  8. Leetcode 笔记 36 - Sudoku Solver

    题目链接:Sudoku Solver | LeetCode OJ Write a program to solve a Sudoku puzzle by filling the empty cells ...

  9. Leetcode 笔记 35 - Valid Soduko

    题目链接:Valid Sudoku | LeetCode OJ Determine if a Sudoku is valid, according to: Sudoku Puzzles - The R ...

随机推荐

  1. cin,get,getline

    一.cin 1.cin使用空白(空格.制表符和换行符)来确定字符串结束的位置,并且对于换行符,cin会把换行符留在输入队列.cin读取字符串放到数组中,并自动在结尾添加空字符. 例如: ]; cin& ...

  2. MyBatis(2)增删改查

    本次全部学习内容:MyBatisLearning   查: 根据id查询用户信息,得到一个用户信息   在User.xml文件中添加代码: <mapper namespace="tes ...

  3. ASP.NET CORE 边学边记之 SwaggerUI简单配置

    前言 当使用 ASP.NET CORE 开发WebApi程序时候,一般使用SwaggerUI生成接口文档.本文记录最简单的一个配置.(生成的文档无注释) 操作 首先安装Nuget包. 然后在Start ...

  4. maven编译package慢

    mvn package编译出现连接不上mvn库的问题: [root@localhost nnnnn]# mvn package[INFO] Scanning for projects...Downlo ...

  5. Learning by doing——获黄色领骑衫之感

    获奖感言 能拿到这件黄色的领骑衫,心里真的非常高兴.仔细看了一下,扣子.领子.各种图案各种细节十分精致.可以说这件领骑衫既有纪念意义,又有实用意义,真的很棒. 背后的故事 其实开始接触博客的时候,我是 ...

  6. 如何在github上实现预览

    这个问题在网络上有很多答案,但是真正能解决的寥寥无几!接下来我就来尝试一下网络上疯传的几种方法.准备好了吗?我要开车了!!! PS:以下实验上传到github的demo采取导入本地css,js和网络上 ...

  7. Oracle语句(一)之简单查询

    1.查询数据表的所有列: select * from 表名; 程序员正常用法:select 列名,列名... form 表名; 2.起别名: select 列名 [AS 别名],列名 别名...fro ...

  8. SQL注入点的类型

    1.数字型注入点 形如“http://****?ID=55”,这类注入的参数是“数字”,因此称为“数字型注入点”. 此类注入点提交的SQL语句,其原形大致为:Select * from 表名 wher ...

  9. 20181029NOIP模拟赛T2

    2.追捕 [题目背景] Duan2baka:“jmsyzsfq天下第一蠢!” jmsyzsfq:“你说什么?!” [题目描述] 于是Duan2baka开始了逃亡的旅程,而jmsyzsfq也开始追捕Du ...

  10. 洛谷P4383 [八省联考2018]林克卡特树lct(DP凸优化/wqs二分)

    题目描述 小L 最近沉迷于塞尔达传说:荒野之息(The Legend of Zelda: Breath of The Wild)无法自拔,他尤其喜欢游戏中的迷你挑战. 游戏中有一个叫做“LCT” 的挑 ...