But what if I told you that you work for a fraud detection company and your job is to produce a little server that listens on a socket for a SSN and writes back an integer 1 or 0 depending on whether the SSN was valid (held by a live person). Assume the US Gov sends you a text file every month that has all valid SSN's - one per line. Also assume SSN data is potentially sparse.See, you're providing more information now. :-)
Depends on how fast it *needs* to be, what the machine constraints are, and how much time you want to spend on a solution. If you're bringing stuff in over TCP/IP, then the data is already in string format, for one thing. If efficiency is everything, and you can't afford the RAM, then sure, put it in a numeral. Or if you just want a solution and RAM is not a problem, read the whole thing into a HashSet and get O(1) lookups straight from the string you read in.
Actually, the best way might be: allocate 125M of RAM, and on startup flip the corresponding bit to 1 for each SSN you read in. When you get a request, convert the SSN to long or whatever, divide by 8, look up the byte, and bitmask off the remainder to see if the SSN is valid. That way you don't have to keep any of the actual SSNs in memory at all, and your question is more or less moot. ;-)
I've personally never been in a situation like that with SSNs, though. :-)
Programming puzzles... I don't like them, in general, but it depends on what you're hiring for. When I hire for web developers, I give them a project to do that should take no more than 8 hours of time. They get a CD with a full environment on it, README, install instructions, compiler, Tomcat, JUnit libs, etc., and they're expected to produce a working web application given a spec. They can do it at home, here at the office on a spare machine, whereever. No frameworks allowed, no external libraries, but they can use any reference guide they wish. As a result I get people who can actually program and discuss the decisions they made intelligently, instead of people who are great at "puzzles" but couldn't actually program their way out of a wet paper bag on an actual project.
Let me know if you want a copy of the CD I have prepared.