leetcode笔记--7 Find the Difference
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的更多相关文章
- 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 ...
- Leetcode 笔记 112 - Path Sum
题目链接:Path Sum | LeetCode OJ Given a binary tree and a sum, determine if the tree has a root-to-leaf ...
- Leetcode 笔记 110 - Balanced Binary Tree
题目链接:Balanced Binary Tree | LeetCode OJ Given a binary tree, determine if it is height-balanced. For ...
- Leetcode 笔记 100 - Same Tree
题目链接:Same Tree | LeetCode OJ Given two binary trees, write a function to check if they are equal or ...
- Leetcode 笔记 99 - Recover Binary Search Tree
题目链接:Recover Binary Search Tree | LeetCode OJ Two elements of a binary search tree (BST) are swapped ...
- Leetcode 笔记 98 - Validate Binary Search Tree
题目链接:Validate Binary Search Tree | LeetCode OJ Given a binary tree, determine if it is a valid binar ...
- Leetcode 笔记 101 - Symmetric Tree
题目链接:Symmetric Tree | LeetCode OJ Given a binary tree, check whether it is a mirror of itself (ie, s ...
- Leetcode 笔记 36 - Sudoku Solver
题目链接:Sudoku Solver | LeetCode OJ Write a program to solve a Sudoku puzzle by filling the empty cells ...
- Leetcode 笔记 35 - Valid Soduko
题目链接:Valid Sudoku | LeetCode OJ Determine if a Sudoku is valid, according to: Sudoku Puzzles - The R ...
随机推荐
- UVa 753 - A Plug for UNIX(最大流)
链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- Powershell split file
#网上所得非原创 function split($inFile, $outPrefix, [Int32] $bufSize){ $stream = [System.IO.File]::OpenRead ...
- 【[HNOI2006]超级英雄】
看到楼下有大佬说了网络流做法,来给大佬配个代码 我们只有我可能都觉得如果不动态加边的话\(dinic\)可能跑不了这种需要中途退出的二分图匹配 正当我准备去敲匈牙利的时候突然想到这个题可以二分啊 于是 ...
- java根据数据库自动生成代码
出现这个已经创建成功 出现这个情况,没有使用DBUtil,引入即可 已经创建完成 代码下载:https://github.com/weibanggang/tool 项目实例下载:https://pan ...
- ORA-04044: 此处不允许过程, 函数, 程序包或类型和
用Orale代码建表时,出现 SQL> comment on column SCORE.cno 2 is '学号(外键)';comment on column SCORE.cno is '学号( ...
- AWS backup
shadowsocks ssserver -c /etc/shadowsocks/config.json start/stop/reset
- 如何在html中插入图片
HTML内容元素中图片元素 使用img元素:src属性:图片路径. alt属性:图片无法显示的时候使用替代文本,title属性:鼠标悬停时显示文本内容. 在同一张图片上点击不同的位置链接到不同的页面上 ...
- maven中的坐标和仓库
1.坐标 pom.xml中的groupId.artifactId和version都可以构成项目的坐标. <dependency> <groupId></groupI ...
- HP-UNIX平台修改Oracle processes参数报错:ORA-27154、ORA-27300、ORA-27301、ORA-27302
OS 版本 :HP-UX B.11.31Oracle版本:11.2.0.4 (RAC) (一)问题描述 最近发现无法连接上数据库,报错信息为“ORA-00020:maximum number ...
- oracle本地安装注意事项
这两天组员在本地windows上安装oracle数据库,安装完各种问题,pl/sql developer以及tns_admin配置以及tnsnames.ora和sqlnet.ora listener. ...