LeetCode 刷题(python)之 宝石与石头
2018-04-06 15:56
405 查看
给定字符串J 代表石头中宝石的类型,和字符串 S代表你拥有的石头。 S 中每个字符代表了一种你拥有的石头的类型,你想知道你拥有的石头中有多少是宝石。J 中的字母不重复,J 和 S中的所有字符都是字母。字母区分大小写,因此"a"和"A"是不同类型的石头。示例 1:输入: J = "aA", S = "aAAbbbb"输出: 3示例 2:输入: J = "z", S = "ZZ"输出: 0注意:S 和 J 最多含有50个字母。
J 中的字符不重复。
J 中的字符不重复。
class Solution: def numJewelsInStones(self, J, S): """ :type J: str :type S: str :rtype: int """ n=0 for i in J: n+=S.count(i) return n
相关文章推荐
- 【LeetCode】宝石与石头
- [LeetCode]题解(python):133-Clone Graph
- Leetcode 12. Integer to Roman(python)
- 【LeetCode】208. Implement Trie (Prefix Tree) 解题报告(Python)
- Leetcode-Maximum Subarray-Python
- 【leetcode】88. Merge Sorted Array(Python & C++)
- 【LeetCode】Python requests模拟Leetcode登陆
- Leetcode 15. 3Sum(python)
- [leetcode, python] Pascal's Triangle II 杨辉三角
- [LeetCode]题解(python):014-Longest Common Prefix
- [LeetCode]题解(python):106-Construct Binary Tree from Inorder and Postorder Traversal
- Leetcode 3. Longest Substring Without Repeating Characters(python)
- 52. N-Queens II Leetcode Python
- [LeetCode]题解(python):110-Balanced Binary Tree
- leetcode-python 第七周
- LeetCode 70 — Climbing Stairs(C++ Java Python)
- 【Leetcode】【python】Minimum Depth of Binary Tree
- [LeetCode]题解(python):028-Implement strStr()
- leetcode_[python/C++] 17.Letter Combinations of a Phone Number(手机号码字符组合)
- leetcode 227. basic calculator 计算字符串表达式的值 python