leetcode 算法题 (python),从易到难,发到博客,促进自己坚持刷题!
class Solution:
def numJewelsInStones(self, J, S):
"""
:type J: str
:type S: str
:rtype: int
"""
time = 0
for i in J:
for k in S:
if i is k:
time+=1
return time
本篇博客分享了LeetCode算法题的Python实现,通过具体示例——计数宝石和石头,展示了如何使用双重循环遍历字符串进行匹配计数的方法。这不仅是一次算法学习的实践,也是对Python编程技巧的深入探索。
leetcode 算法题 (python),从易到难,发到博客,促进自己坚持刷题!
class Solution:
def numJewelsInStones(self, J, S):
"""
:type J: str
:type S: str
:rtype: int
"""
time = 0
for i in J:
for k in S:
if i is k:
time+=1
return time

被折叠的 条评论
为什么被折叠?