0001、两数之和
class Solution(object):
def twoSum(self, nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: List[int]
"""
l = len(nums)
for i in range(l):
for j in range(i+1, l):
if nums[i] + nums[j] == target:
return [i,j]
1929、数组串联
class Solution(object):
def getConcatenation(self, nums):
"""
:type nums: List[int]
:rtype: List[int]
"""
return 2*nums
0771、宝石与石头
class Solution(object):
def numJewelsInStones(self, jewels, stones):
"""
:type jewels: str
:type stones: str
:rtype: int
"""
jewel_kind=dict()
for jewel in jewels:
jewel_kind[jewel]=1
count=0
for stone in stones:
if stone in jewel_kind:
count=count+1
return count