NewThe Learning module is now liveSee what's new
avatar
danielparkOct 16, 2026

Square onsite, the "Huffman tree" that isn't actually Huffman

Interview Experiences
block

Square onsite, the "Huffman tree" that isn't actually Huffman

Got rejected from Square after the onsite, email came 3 days later. Two coding, hotel booking SD, project deep dive. Pretty sure this coding round is what killed it.

Prompt: given a string of letters, count each char and build a binary tree from the counts. Leaves are the chars with their counts, internal nodes are just '#' with the sum of everything under them. Sounds like Huffman right? Nope. You sort chars by count ascending, ties broken by the char itself, glue the two smallest together (smaller on the left), and then every next char goes on the left with the whole tree so far on the right. So you end up with a lopsided chain.

I burned like 10 min writing a heap because I heard "frequency tree" and my brain went straight there. Then the tie break got me. Uppercase sorts before lowercase, so 'Z' comes before 'a', and I'd been lowercasing stuff in my head while tracing an example. Interviewer just watched me do it lol.

Once it worked he asked how I'd turn it into an actual Huffman tree, and then a height balanced version. Talked through the heap for the first one, ran out of time on the second.

Whatever, on to the next one.

18673k

Replies (4)

avatar
sarah.kimOct 16, 2026

how was the hotel booking SD? that's the one I'm worried about for my loop next week

39
avatar
danielparkOct 16, 2026

honestly fine, interviewer was chill. mostly double booking and how to hold a room during checkout

37
avatar
User-giq6qOct 16, 2026

did they let you run code or was it just tracing by hand?

31
avatar
danielparkOct 16, 2026

could run it, I just tried to trace the example first like an idiot

68
avatar
User-3ao5uOct 16, 2026

the ascii ordering thing is so annoying. I'd 100% have lowercased everything too

17
avatar
danielparkOct 16, 2026

in my head 'a' and 'A' were basically the same letter, they very much are not

17
avatar
User-cbwgfOct 16, 2026

rough, 3 days is actually fast for them though. good luck on the next one

17
No more replies