MCPcopy Create free account
hub / github.com/ccagml/leetcode-extension / NestedInteger

Class NestedInteger

resources/debug/entry/python3/entry.py:162–195  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

160
161
162class NestedInteger:
163 def __init__(self, ni):
164 nested = []
165 if (isList(ni)):
166 for i, val in enumerate(ni):
167 nested.append(NestedInteger(val))
168 self.nested = nested
169 self.ni = ni
170
171 def isInteger(self) -> bool:
172 """
173 @return True if this NestedInteger holds a single integer, rather than a nested list.
174 """
175 if (isList(self.ni)):
176 return False
177 return True
178
179 def getInteger(self) -> int:
180 """
181 @return the single integer that this NestedInteger holds, if it holds a single integer
182 Return None if this NestedInteger holds a nested list
183 """
184 if (isList(self.ni)):
185 return None
186 return self.ni
187
188 def getList(self):
189 """
190 @return the nested list that this NestedInteger holds, if it holds a nested list
191 Return None if this NestedInteger holds a single integer
192 """
193 if (isList(self.ni)):
194 return self.nested
195 return None
196
197
198def parseNestedIntegerArray(param):

Callers 2

__init__Method · 0.70
parseNestedIntegerArrayFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected