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的更多相关文章

  1. [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 ...

  2. [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 ...

  3. [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 ...

  4. [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 ...

  5. [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 ...

  6. [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 ...

  7. [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 ...

  8. [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 ...

  9. [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 ...

随机推荐

  1. C# 中web如何定时同步数据

    之前做定时器同步方法试过很多方法, 不过都有些问题 1)quartz + IIS 方式(web项目发布到IIS上,出现IIS应用池回收问题) 2)用线程Timer方式 (出现多个线程同步同个任务问题) ...

  2. css3 居中(推荐弹性盒模型方式)

    参考  http://www.zhihu.com/question/20774514 http://caibaojian.com/demo/flexbox/align-items.html 例子:ht ...

  3. nginx:负载均衡实战(二) keepalived入门

    1.keepalived介绍 顾名思义,keepalived就是保持网络在线的,用来保证集群高可用HA的服务软件.主要防止出现单点故障(坏了一个点导致整个系统架构不可用) 2.详解keepalived ...

  4. Saiku的基本使用介绍(三)

    Saiku的基本使用介绍(这里都是使用Admin用户登录系统) 1.启动安装好的Saiku  ( ./start-saiku.sh ) ,浏览器使用访问系统 http://localhost:8080 ...

  5. js onclick函数中传字符串参数的问题

    规则: 外变是“”,里面就是‘’外边是‘’,里边就是“”   示例: var a="111"; var html="<a onclick='selecthoods( ...

  6. MicroBlaze核的串行接口实验:SPI UART

    reference : https://blog.csdn.net/weixin_42413559/article/details/80720566 串行接口:SPI UART XPS->SDK ...

  7. Centos7创建用户su登录后显示为 bash-4.1$

    useradd name [root@localhost data]# su name bash-4.2$ [root@localhost ~]# cp -a /etc/skel/. /home/na ...

  8. 一、TCP扫描技术

    一.TCP扫描技术 常用的端口扫描技术有很多种,如 TCP connect() 扫描 .TCP SYN 扫描.TCP FIN 扫描 等,网络上也有很多文章专门介绍,比如 :http://www.ant ...

  9. exists 的使用

    SELECT u.login_id, ( from mdp_user_login_info muli where muli.BIZ_SYS = 'admin' and u.login_id=muli. ...

  10. [从Paxos到ZooKeeper][分布式一致性原理与实践]<二>一致性协议[Paxos算法]

    Overview 在<一>有介绍到,一个分布式系统的架构设计,往往会在系统的可用性和数据一致性之间进行反复的权衡,于是产生了一系列的一致性协议. 为解决分布式一致性问题,在长期的探索过程中 ...