☕ Computer Memory for Programmers

Hi Everyone,

Hope you’re all having a fantastic day!

Here’s your Tech Snippets and Interview Problem for the day!

Tech Snippets

What Every Programmer Should Know about Memory - This amazing paper goes over…

  • RAM - Static RAM (SRAM) vs. Dynamic RAM (DRAM), and how RAM works.

  • CPU Caches - Cache Operation, Implementation, Measurement of Cache Effects

  • NUMA (Non Uniform Memory Access) systems - NUMA hardware and why it’s useful

  • How to write code with performs well in various situations

  • Tools that help you do a better job on memory management

Drunk Post: Things I’ve learned as a senior Engineer - This is a pretty hilarious post by a Senior Dev on things he’s learned throughout his career. Here are a couple of my favorite takeaways from the post…

  1. The best way I've advanced my career is by changing companies.

  2. Technology stacks don't really matter. All fields have about 10-20 core principles and the tech stack is just trying to make those things easier, so don't fret over it.

  3. If I'm awake at 2am from being on-call for more than once per quarter, then something is seriously wrong and I will either fix it or quit

  4. Good code is code that can be understood by a junior engineer. Great code can be understood by a first year CS freshman. The best code is no code at all.

  5. The most underrated skill to learn as an engineer is how to document.

  6. On Data Engineering... SQL is king. Databases like MySQL, Postgres, Oracle, SQL Server, SQLite are still supreme. Even if you work with new tech, most of it transfers anyway.

Interview Question

You are given the root node of a Binary Search Tree and a L and R value.

Return the sum of values of all the nodes with a value between L and R inclusive.

The Binary Search Tree will have unique values.

Here’s the question in LeetCode.

We’ll send a detailed solution tomorrow, so make sure you move our emails to primary, so you don’t miss them!

Gmail users—move us to your primary inbox

  • On your phone? Hit the 3 dots at the top right corner, click "Move to" then "Primary"

  • On desktop? Back out of this email then drag and drop this email into the "Primary" tab near the top left of your screen

Apple mail users—tap on our email address at the top of this email (next to "From:" on mobile) and click “Add to VIPs”

Previous Solution

As a refresher, here’s the last question

Given an integer, write a function to determine if the integer is a power of two.

Try to do this in O(1) time.

Solution

This is one of those questions where you either know it, or you don’t.

If you know how Bit Manipulation works, then this question is pretty trivial.

If you don’t, then you should learn how Bit Manipulation works!

Here’s the best video I’ve seen that explains the core of Bit Manipulation.

The video also goes over this question!

The question can be solved with this expression

n & (n - 1) == 0 # if this is true, then n is a power of 2

However, this expression fails in one case.

Can you identify it?

Once you figure it out, check out our solution.