This is probably obvious to a lot of people, but I thought it still might be useful since I didn't think of it myself for years. Since sometime in college, I've been the kind of person who wakes up groggily at 10 am and then drags myself out of bed. I've always been a late sleeper so I didn't think much about it, but when I stopped taking allergy pills, I fairly quickly became someone who woke up around 8:30 am without much effort (still not early but not crazy-late).
Write code to interact with 3rd parties using their data model
When writing code to interact with a third party like a SaaS provider, you typically need to write both code to handle the API the third party uses, and translate their data model into your data model. One thing I've found that makes this easier is to do each step separately: First write a library to interact with their API using their own data model, then separately write code to translate between your data model and theirs.
"Additional" space complexity is a bad metric
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.
It's worth it to use more memory
There's a common programming interview question that asks you to find the single non-duplicated value in a list of duplicated integers. This can be done in O(n) time and O(1) space by XOR'ing the values, and doing so is almost always the wrong answer. A better solution when you can afford to do it is to use a hash table to count occurrences.
The problem with wealth taxes
Elizabeth Warren recently proposed a wealth tax as part of her plan to partially pay for single-payer healthcare. I think this is significantly worse than other methods of raising the same amount of revenue from the same group of people, so this article describes the problems with wealth taxes plus …