Car side and rear-view mirrors are designed to give you a view around your car, but they typically don't show you the two spots directly to the side of your car (the "blind spots"). Luckily, you can increase the field of view of your side mirrors by over 200% and virtually eliminate blindspots by adding aftermarket blind spot mirrors.
As software engineers, we all want to get things done quickly and efficiently. But sometimes, we focus too much on short-term results and end up working harder in the long-term. In this post, we'll explore why you shouldn't just do the bare minimum when implementing code changes and why you should make seemingly unrelated changes while you're there.
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.
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.
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.
Page 1 / 11 »