leetcode 刷題的時候,遇到下列錯誤。
1 class Solution: ----> 2 def kidsWithCandies(self, candies: List[int], extraCandies: int) -> List[bool]: 3 #遍歷所有的孩子 4 #增加糖果數量 5 #查看是否是最多的糖果,是,if_max,增加True NameError: name 'List' is not defined
在最前部增加:
from typing import List
解決問題。