What exactly does single "\n" and spaces mean?

  • 1

    I'm wondering what's the expected answer for these test cases involving \n and spaces? The problem itself didn't mention how to deal with single "\n". This seems to be confusing to me

    file name with space.txt = 25 // so spaces are part of file name and should be counted
    dir\n file.txt = 12 // i suppose it's 4 spaces + file.txt ? how about dir here? why it's not included?
    dir\n file.txt = 16 // i suppose it's 8 spaces + file.txt? same question as above
    a\n\tb.txt\na2\n\tb2.txt=9 // why? what's a2 here? maybe it's a/b.txta2 but i dont see how \n is handled here

    Please advise

  • 1

    Answering myself- \n seems to mean that the folder is on the first layer, so a\n\tb.txt\na2\n\tb2.txt is

    [blank and tabs] b.txt
    [blank and tabs] b2.txt

    it would be helpful if this example can be explained in the problem description...

  • 0

    \n means there will be another file / subdirectory in the same directory
    You don't need to do anything special with space, just treat space as a plain letter
    Also confused by the test cases containing spaces, and just figured it out...

Log in to reply

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