Home > Reflections | ⏮️ ⏭️
2024-06-12
Behavioral Questions
Tell me about your favorite project
This question is difficult to answer because it poses a one dimensional optimization problem in a space that is multidimensional.
There are a variety of aspects of any given project that I might enjoy. Some examples:
- Impact. It’s nice when a project improves people’s lives.
- Scale. It’s fun to work on systems that span thousands of servers across multiple continents or cater to millions of users.
- Learning. Some projects require learning interesting new skills or ideas.
- Technical excellence. I love the opportunity to apply advanced engineering tools and techniques.
- Product enjoyment. Typically, I make side projects for myself first. Making a game that I enjoy playing with friends, for example, is fun and satisfying.
- Teamwork. It can be a lot of fun to work with people.
- Leadership. And there’s a special kind of satisfaction in effectively leading a project that teammates and stakeholders enjoy.
- Challenge. Some projects seem nearly impossible at the outset. Meeting a challenge feels great.
I should come back later and write out some stories about projects I’ve worked on in the past, highlighting these various points.
🏋 Practice
The Problem
1863. Sum of All Subset XOR Totals
The XOR total of an array is defined as the bitwise
XOR
of all its elements, or0
if the array is empty.
- For example, the XOR total of the array
[2,5,6]
is2 XOR 5 XOR 6 = 1
.
Given an arraynums
, return the sum of all XOR totals for every subset ofnums
.
Note: Subsets with the same elements should be counted multiple times.
An arraya
is a subset of an arrayb
ifa
can be obtained fromb
by deleting some (possibly zero) elements ofb
.
🪞 Reflections
- This problem is labeled
Easy
, but I disagree. - Observing that brute force is sufficient based on the size constraints on the input was key.
- Generating every subset is not easy to do. I had to look up techniques before implementing it. Maybe I should practice them. The bitmask technique at least seems memorable.
- The O(N) solution is kind of ridiculous. I imagine this problem was reverse-engineered into existence based on someone’s knowledge of this trick. That said, it would still be cool to be able to come up with it on my own. At least I knew where to look for a trick, even if I didn’t have the patience to thoroughly search and find it (nor would I have had the time to do so in an interview).
- My first solution was completely wrong, but at least I caught that during manual testing. Generating every subset is not trivial (see point 2 above).
- Was this a valuable use of time? I’m not sure. I did observe a couple of gaps in my knowledge. If I’m asked to generate every subset of a thing, I think I’ll be able to do it now.
- Oh yeah, bit-wise XOR on numbers isn’t very intuitive. I referenced the examples provided to determine the value of any given XOR operation (during manual testing) to avoid having to write out the bits and XOR them myself.
My Solutions
Some Universal Design Principles
- Understand the context
- Identify key stakeholders, participants, and users
- Identify constraints: timelines, budgets, performance targets, outcomes
- Minimize complexity within the constraint parameters
- Resiliency
- Our primary path to resiliency is through redundancy
- Redundant data (typically distributed across independent data centers) reduces likelihood of data loss
- Redundant services reduces likelihood of downtime
- Our primary path to resiliency is through redundancy
- Scaling
- Prefer horizontal scaling for growth.
- Handle more users by adding more servers.
- When data grows too large, try splitting it into independent sets.
… to be continued
- Prefer horizontal scaling for growth.
A Framework for System Design Interviews
A friend shared this framework with me. It should help organize responses to design interview questions and ensure that I hit all the major points. I should practice writing out designs for a few systems using this framework before real interviews.
Also, this is mostly copy/paste, which isn’t great for retention. I should review the framework, rationalize it with principles and experiences I’m familiar with, come up with analogies, see if I can derive this or something similar myself.
I think it’s a nice framework. It’s probably a good sign that nothing here is particularly new or surprising, but it does a great job of organizing a lot of concepts I’m already familiar with.
I also appreciate the guidelines on how much time to spend in each section. If I can practice and learn to use this effectively, I can see it keeping me on track during a real interview.
1. Problem Exploration, Scope, and Functional Requirements (5 min)
- Identify & prioritize customers (internal vs external & size)
- Define business goals & metrics (revenue, user adoption)
- Identify use cases & functional requirements
- Identify cost factors (minimize cost of development vs cost of maintenance)
2. Non Functional Requirements (5 min)
- Performance (QPS - read vs write heavy, latency, data staleness)
- Availability (CAP, availability vs strong consistency, how many 9s?, fault tolerance: replication, conflict resolution, timeouts)
- Reliability (durable data, correct responses: verify with batch offline jobs)
- Security (pass tokens with requests)
- Maintainability (Monitoring, Profiling, Debuggability)
- Extensibility (Frameworks & reusable abstractions, plugin models)
3. API Design & Data Model (10 min)
- Handling bad actors
- API Safeguards (rate limiting, large response sizes, pagination)
4. Capacity Estimations (5 min)
- QPS (Read & Write; Peak & Average; Ratios)
- Storage size (1, 3, 5 years)
- Memory size (caching?)
- Network Bandwidth
- Disk IO?
- System bottlenecks (CPU/Memory/Disk/Network Bandwidth bound)
5. Draw Components & Deep Dive (15 min)
- Draw boxes and lines.
- Annotate major request flows.