Python simple solution


  • 0
    class Solution(object):
        def deserialize_core(self, data_list):
            if isinstance(data_list, list):
                nested_integer = NestedInteger()
                for n in data_list:
                    nested_integer.add(self.deserialize_core(n))
                return nested_integer
            else:
                return NestedInteger(data_list)
    
        def deserialize(self, s):
            data = eval(s)
            return self.deserialize_core(data)
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.