NameError is not defined in leetcode problem

Please bear with me, I'm still getting used to OOP in python. I'm preparing for coding interviews, and find that Leetcode problems generally have the following structure. class Solution: def