"Write a function in C that returns the largest signed integer supported on the system the code will be running on."
I thought this was something that was defined in a header file somewhere, so I asked if I could look at some header files. The interviewer said not to make any assumptions about the hardware, so I said OK, but I would still need to include some header files anyway so some declarations would be recognized. I didn't find what I was looking for in the header files, but I did think of a way to do this for a 32-bit signed integer. (While out walking, the way to do this for an arbitrary sized signed integer occurred to me. Oh well.)
"Implement a function in production quality code, file_copy(), that takes two pathnames, copying the contents of one to the other."
I asked if it needed to return a particular error code in case of failure, and he said I could define that myself. I also asked if these were regular files (so ordinary calls to open(), read(), etc. would work), and he said yes. He also said it was OK for me to refer to man pages, which was good, because I don't remember the order of arguments to open(), read(), etc. So I proceeded to write a simple version of it, where any failure to do anything would close all open descriptors and return an error. After I was done, I told him that at this point, I would test it to see if I had made any mistakes. He then asked me if there was a way I could make the function more robust (e.g. if there was a partial write()). I understood what he was asking, and made a few changes, but because the actual typing using Google Docs had taken longer than if I'd been allowed to use a text editor or an IDE, a lot of time had passed, so I used a goto to break out of an inner loop instead of doing more of a rewrite.
At this point I was feeling tired, having been up late the night before doing something I would have done earlier if it had not been for some personal issues that had come up earlier in the day. My right shoulder also started bothering me. The interviewer needed to take a break, which was good, because I did also.
"Given the root of binary search tree, and two nodes, find the lowest common ancestor."
This is one of those "standard algorithms" that I don't remember off the top of my head, but I figured it could be solved by traversing the tree recursively. I started to write some code to do that, but I started feeling even more tired. I wasn't really getting anywhere, so I took a piece of scrap paper, drew a sample tree on it, and worked out a few simple cases. I then told the interviewer that I needed more time, but he said time was almost up. (Recall that we weren't able to start on time due to problems installing the WebEx client.) So, he asked me to explain in words what I would do. I gave the best description I could, under the circumstances.
After that, I asked the usual questions I ask of anyone who interviews me, such as what a typical workday is like, and so forth. He thanked me for my time, and that was it. I haven't heard anything since.
I just sort of chalked this one up to being tired and having to use Google Docs. I think I could have done better if I hadn't been tired. This stuff is difficult enough on its own; it's even more so when dealing with personal problems. But I really hated having to use Google Docs to write the code. IMO, it is one of the worst editors for coding. I know there has been a lot said about how interviewers can't tell how good a software engineer a candidate is if the candidate is using his or her favorite editor or IDE. However, IMO, there has to be a better way than Google Docs, especially if production quality code is requested. Apparently, Codeanywhere provides a service that purports to be the Google Docs for collaborative coding in the cloud. If it is, will candidates be allowed to use it during interviews?