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. 四·安装mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz(基于Centos7源码安装)

    1.在Linux中创建用户mysql和主目录,并创建密码 2.解压缩tar.gz并拷贝到/usr/local/mysql目录下面 3.把/usr/local/mysql文件夹拥有者改为mysql 进入 ...

  2. 【[AHOI2009]中国象棋】

    计数类dp还是要多写啊 看上去并没有什么思路,加上被题解里状压的标签迷惑了,于是就去看了一眼题解里设计的状态 之后就很好做了 首先先搞明白这道题的本质,就是对于任何一行任何一列炮的个数都不能超过\(2 ...

  3. Codeforces Round #540 (Div. 3) F1. Tree Cutting (Easy Version) 【DFS】

    任意门:http://codeforces.com/contest/1118/problem/F1 F1. Tree Cutting (Easy Version) time limit per tes ...

  4. viewsate用法

    ViewState["名称"]="ssss";直接赋值取值只能在同一个页面使用, 离开页面就会失效

  5. 强大的Windows 10数字权利获取工具HWIDGEN

    前言: 每当windows 10 系统过期就是头疼的key激活,更奇怪的是每次激活的方式不同,上次有效下次就不知道有没有效了,今天发现一种更改数字权利的工具脚本,不要太牛逼!!! 安装之前的准备工作: ...

  6. POJ 3122 Pie(二分+贪心)

    Pie Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 22684   Accepted: 7121   Special Ju ...

  7. libstagefright 音视频同步方案

    1:音视频数据都有一个list,用于存放解码后的数据:    List mFilledBuffers; 2:解码后的音视频数据不断的往list中存放,不做音视频同步方面的时间上控制    mFille ...

  8. 使用PIE.htc让万恶的IE内核浏览器IE6\7\8支持CSS3部分属性

    万恶的IE内核浏览器,这是多少前端程序员头疼的事情... 今天给大家介绍一下如何用 PIE.htc 来让IE浏览器支持CSS3的 border-radius.box-shadow.CSS3 Backg ...

  9. lable随堂笔记

    lable标签与属性 lable标签:for属性,让标签与指定的input元素建立标签:将input元素包含在lable标签中. <table border="2" alig ...

  10. trunc(sysdate)的含义是什么

    1.ORACLE中TRUNC是截取的函数