[LeetCode&Python] Problem 389. Find the Difference
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.
Example:
Input:
s = "abcd"
t = "abcde" Output:
e Explanation:
'e' is the letter that was added.
from collections import Counter
class Solution(object):
def findTheDifference(self, s, t):
"""
:type s: str
:type t: str
:rtype: str
"""
cs=Counter(s)
ct=Counter(t) for k in ct:
if cs[k]!=ct[k]:
return k
[LeetCode&Python] Problem 389. Find the Difference的更多相关文章
- [LeetCode&Python] Problem 530. Minimum Absolute Difference in BST
Given a binary search tree with non-negative values, find the minimum absolute difference between va ...
- [LeetCode&Python] Problem 594. Longest Harmonious Subsequence
We define a harmonious array is an array where the difference between its maximum value and its mini ...
- [LeetCode&Python] Problem 563. Binary Tree Tilt
Given a binary tree, return the tilt of the whole tree. The tilt of a tree node is defined as the ab ...
- [LeetCode&Python] Problem 108. Convert Sorted Array to Binary Search Tree
Given an array where elements are sorted in ascending order, convert it to a height balanced BST. Fo ...
- [LeetCode&Python] Problem 492. Construct the Rectangle
For a web developer, it is very important to know how to design a web page's size. So, given a speci ...
- [LeetCode&Python] Problem 387. First Unique Character in a String
Given a string, find the first non-repeating character in it and return it's index. If it doesn't ex ...
- [LeetCode&Python] Problem 783. Minimum Distance Between BST Nodes
Given a Binary Search Tree (BST) with the root node root, return the minimum difference between the ...
- [LeetCode&Python] Problem 427. Construct Quad Tree
We want to use quad trees to store an N x N boolean grid. Each cell in the grid can only be true or ...
- [LeetCode&Python] Problem 371. Sum of Two Integers
Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -. Exam ...
随机推荐
- Sublime Text 3 + phpfmt 插件
Sublime Text 3 + phpfmt 插件 phpfmt 插件参数 ```json{ "autocomplete": true, "enable_auto_al ...
- Linux查看用户属于哪些组/查看用户组下有哪些用户
一.关于/etc/group格式的讨论 在说/etc/group格式的时候,网上很多文章都会说是“组名:组密码:组ID:组下用户列表”,这说法对了解/etc/group格式是没问题的,但如果碰到“查看 ...
- OllyDbg安装教程
1.下载 http://tools.pediy.com/windows/debuggers.htm 我们这里选择OllyDbg1.10下载 2.安装 解压下载的压缩包直接双击启动即可使用 3.插件安装 ...
- wps去除首字母自动大写
首字母大写功能在不是进行英文编写时是个“自作聪明”的功能,我们可能会想把它关掉.
- MVC的前端和后端的Model Binding
1.前端提交JSON 字符串 {"id":13,"title":"这里是标题33","day":"2018-8 ...
- Laravel框架如何去除URL中的/public
laravel/server.php改名为index.php 并且将public目录下的.htaccess拷贝到Larvael根目下 再访问 如有配置不成功的请加群
- 【Loadrunner基础知识】web_get_int_proterty
1.函数作用:记录http请求的响应信息 2.函数参数: HTTP_INFO_RETURN_CODE : http请求返回的状态码: HTTP_INFO_DOWNLOAD_SIZE : 返回页面下载的 ...
- MAVEN ECLIPSE JAR工程
在eclipse 空白处点击鼠标右键选择新建 project 选择maven project: 选择Create a simple project Group ID: Artifact ID:创建项目 ...
- 【oracle常见错误】ora-00119和ora-00132问题的解决方法
oracle11g安装后,本地无法登录!前提:服务全部打开,监听也配置好了! win7 64位 oracle 11g 简单的sql命令: 先登录到sqlplus:sqlplus/nolog; 登录数据 ...
- [Linux]Linux下yaf发送IPV4和IPV6的IPfix
一.IPFIX与NetFlow 一.IPFIX 全称IP Flow Information Export,即IP流信息输出,是网络流量监测的国际标准.IPFIX是IETF的一个工作组,它的主要工作就是 ...