remove dups from a sorted list

From http://www.programcreek.com/2013/01/leetcode-remove-duplicates-from-sorted-list/: remove duplicate items from a sorted list. My initial version had a bug that I didn't catch till running. You can't increment the current pointer until all dups have been eliminated - nested inside the first while must be another while (not…

Read full post

reservoir sampling

I learned a nice algorithm for choosing a random, evenly distributed sample along a stream of unknown size, or one that you don't have random access to. It originally showed up as a question from Amazon on careercup.com. The näive algorithm (and the only solution i could come up…

Read full post