def findSpiral(root):
depthDict={0:[root.data]}
elems=[root]
newElems=[]
depth=0
while(len(elems)):
depth+=1
depthDict[depth]=[]
for elem in elems:
depthDict[depth].append(elem.left.data) if elem.left else None
depthDict[depth].append(elem.right.data) if elem.right else None
newElems.append(elem.left) if elem.left else None
newElems.append(elem.right) if elem.right else None
elems=newElems
newElems=[]
ans=[]
for depth in depthDict:
for elem in (depthDict[depth] if depth%2==1 else depthDict[depth][::-1]):
ans.append(elem)
return ans
-
Notifications
You must be signed in to change notification settings - Fork 1
Problem of the Days of Geeks for Geeks. Here I try to upload GFG POTD Solutions in Python 3 which I practice everyday
License
antilneeraj/GFG-POTD
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
Problem of the Days of Geeks for Geeks. Here I try to upload GFG POTD Solutions in Python 3 which I practice everyday
Topics
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published