lintcode-55(comparestrings)
来源:互联网 发布:nokia5230软件下载 编辑:程序博客网 时间:2024/06/07 22:23
比较两个字符串A和B,确定A中是否包含B中所有的字符。字符串A和B中的字符都是 大写字母点击打开链接
给出 A = "ABCD"
B = "ACD"
,返回 true
给出 A = "ABCD"
B = "AABC"
, 返回 false
结题思路如下:
首先,给定特定条件,如果A和B都为空字符串,return True。如何A等于空字符串,而B不是,return False。如果B是空字符串
lst_a = list(A)for i in B: if i in lst_a: lst_a.remove(i) else: return Falsereturn True
先将A变为一个列表,因为后面我们要用到remove。然后遍历B, 达到效果
0 0
- lintcode-55(comparestrings)
- lintcode-比较字符串-55
- lintCode 55:比较字符串
- LintCode
- lintcode--
- lintcode
- LintCode
- Lintcode
- LintCode-第55题 比较字符串
- Lintcode - Median
- Lintcode - MedianII
- Lintcode - Heapify
- LintCode-组合
- LintCode 子树
- LintCode-加油站
- lintcode-422
- lintcode-189
- lintcode-103
- WEB项目的相对路径与绝对路径
- Python tarfile模块解压报错 invalid mode ('wb') or filename
- TCP/IP协议栈初始化(五) 再向下,找到了IP协议的好队友ARP
- 三种线性问题的优化
- CentOS+Nginx+Tomcat集群及负载均衡
- lintcode-55(comparestrings)
- Logistic逻辑回归
- mysql刷新权限命令
- Longest Ordered Subsequence(最长上升子序列)
- 2016.12.03【初中部 NOIP提高C组】模拟赛
- TCP三次握手与四次挥手的全过程
- android查远程网关mac
- sublime 中文乱码解决方法
- LPT算法--时间调度问题