☕ Operating Systems Explained
An awesome series of lectures on Operating Systems. Plus, a solution to our last coding interview question using the sliding window technique!
Hey Guys,
Interviewing.io is a fantastic resource I wanted to share with you all.
You can book realistic mock interviews with senior FAANG engineers who will give you detailed and actionable feedback on exactly what you need to work on.
Mastering algorithms on LeetCode and system design on SystemsExpert is great, but they don’t prepare you for the pressure and stress that comes from an actual interview setting.
The best part?
You don’t pay anything until you’re hired.
Check them out here.
Special thanks to Interviewing.io for sponsoring Quastor Daily. I’m a user of the service!
Tech Snippets
An awesome series of lectures on Operating Systems!
The lectures are from 2014 so some of the numbers (clock speed, RAM, # of cores etc.) might be a bit outdated, but the concepts are all the same!
Developer Onboarding on the M1 Macbook Pros.
The new M1 Macbook Pros have been getting a lot of buzz for their speed and battery life.
One question is how Apple’s new chips will affect software development work.
This post goes through developer onboarding on M1 Macbook Pros with a Python/Go/Kubernetes backend stack and TypeScript/React on the frontend.
Interview Question
You are given an array with all the numbers from 1 to N appearing exactly once, except for one number that is missing.
How can you find the missing number in O(n) time and O(1) space?
What if there are two numbers missing?
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
You are given two arrays.
One array is a shorter array and has all distinct elements
The other array is longer and can have repeat elements.
Find the shortest subarray in the longer array that contains all the elements in the shortest array.
The items can appear in any order.
Input - [1, 5, 9], [7, 5, 9, 0, 2, 1, 3, 5, 7, 9, 1, 1, 5, 8, 8, 9, 7]
Output - [7, 10]
Explanation - This is the index for the subarray [5, 7, 9, 1] in the larger array.
Solution
This question can be solved by the Sliding Window technique.
The Sliding Window technique is useful for when we’re looking for a subarray that satisfies certain conditions.
Here’s a great video on the Sliding Window Technique.
For this question, we’ll maintain a sliding window that will represent our subarray.
We’ll then iterate through the longer array.
Our sliding window will start at index 0, and we’ll expand the sliding window until it contains all the elements in the shorter array.
When this is the case, we’ll check the length of the sliding window and see if it’s shorter than the shortest subarray we’ve seen that contains all the elements of the shorter array.
If so, then we’ll set our shortest subarray to the current sliding window.
Then, we’ll contract (shorten) our sliding window (by eliminating elements from the left) until our sliding window no longer contains all the elements in the shorter array.
While we contract our sliding window, we’ll continue checking if our sliding window is shorter than the shortest subarray (and contains all the elements in the shorter array). If both conditions are met, then that sliding window becomes our new shortest subarray.
Once our sliding window no longer contains all the elements in the shorter array, then we’ll go back to expanding it by adding in elements from the right.
We’ll terminate when the sliding window reaches the end of the longer array and it’s no longer possible to create a subarray with all the elements of the shorter array.
Here’s the Python 3 code.
Want more practice with real FAANG software engineers?
Check out Interviewing.io!
You don’t have to pay anything until you get that job at FAANG!