Skip to content

Problem of the Days of Geeks for Geeks. Here I try to upload GFG POTD Solutions in Python 3 which I practice everyday

License

Notifications You must be signed in to change notification settings

antilneeraj/GFG-POTD

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 

Repository files navigation

Today's GFG-POTD {Problem Of The Day}

Title - Level order traversal in spiral form

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

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

No packages published

Languages