Example code (regardless of the pros and cons of the code):
Note: I use an online platform compiler
Problem1
- NameError:name ‘List’ is not defined
- Solution: Add the following code:
from typing import List
Problem2
- TypeError: threeSumClosest() missing 1 required positional argument: ‘target’
- Solution:
S = Solution()
- Analysis: In Python, the class should be instantiated first, and then the class should be applied. Note that the instantiation process should be parenthesized.