What to do if class is not given in question

On leetcode, we typically write solutions in classes. This allows us to update a class variable in recursion and other type of questions by using "self".

ex:

class Solution:
    def findMode(self, root: Optional[TreeNode]) -> List[int]:
        
        self.max_find = 0
        self.prev = root

For onsite interviews, how do you get by without using the self properties to answer solutions?

Comments (1)