I've been subscribed to Interview Cake for years, and today they had a really interesting question: Given a list of n + 1 integers in the range 1...n, find one of the duplicates (there is guaranteed to be at least one) in O(n) time and O(1) additional space. The answer is really interesting, and I recommend trying it, but I don't think it makes sense to care about additional space rather than total space, and I still think using a set is the best solution in practice.

Read more

To make your data faster to lookup, you can either store it in an order that makes it easier to search, or add one or more indexes. For practical work, you can let your file system do this for you, or use a pre-built database (either relational or not). I'll describe from the lowest-level to highest level so you can understand what I'm suggesting, but my real-world answer is that I would store most kinds of data in a relational database like PostgreSQL and put indexes on any column that I want to do lookups by.

Read more

When you're documenting a project so other people can use it, whether it's a library or web service, one important thing to do is to give people good examples to work with. Not only does this save people time trying to cobble together their first working program, but it's also a good way to show how the library is meant to be used, instead of just what's technically possible.

Read more

I recently spent several days improving the OCaml FreeTDS C bindings for work, and I thought it might be useful to share the problems I ran into and how to solve them.

I tried to order things so the most likely issues are listed first, but if you're trying to debug some C binding crashes, I recommend just reading the whole thing.

This post will assume you're already familiar with the official documentation.

Read more

Page 1 / 10 »