Leetcode Solution Python Dynamic Attributes