To me the easiest and fastest way was to use hashes for the dreaded "tree
structure". excerpt:

root = {}

def mkdir(path):
    # return number of mkdir needed, considering current state
    nn = 0
    cd = root
    for dir in path.split('/'):
        if dir not in cd:
            cd[dir] = {} # mkdir
            nn += 1
        cd = cd[dir] # chdir
    return nn





On Sun, May 23, 2010 at 10:55 AM, Lev Neiman <[email protected]> wrote:

>
> The easiest and fastest way to solve this for me was to just use a set that
> keeps track of full path names of already created folders, and all of their
> parents until root folder.  This way you don't need to have any tree data
> structure, and you can still do large input well under time limit.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-codejam" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-code?hl=en.

Reply via email to