☕ Big change at Microsoft
Microsoft reverses on their position around remote work. A google interview question.
Hope you’re having an awesome day!
On to the Interview Problem and Industry News!
Design a data structure for an LRU (Least Recently Used) Cache.
Implement the following functions:
- Constructor that takes in the size of the LRU Cache as a parameter.
- get(key) Return the value of the key if the key exists, otherwise return -1. This key is now the most recently used item in the cache.
- put(key,value) Add the key and value to the LRU cache. If the cache is already at capacity, then delete the least recently used item.
If you’re unfamiliar with what an LRU Cache is, check this out.
If you have any follow up questions, reply to this email and I’ll answer them!
We’ll send out the solution (with working code and test cases) 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 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”
Microsoft announces permanent work from home - As lots of companies jumped aboard the remote work train, Microsoft was hesitant. In May, during an interview with the NYT, Satya Nadella talked about how he was no big fan of remote work. Here’s the full quote.
Mr. Nadella said that raw productivity stats for many of Microsoft’s workers have gone up, but that isn’t something to “overcelebrate.” More meetings start and end on time, but “what I miss is when you walk into a physical meeting, you are talking to the person that is next to you, you’re able to connect with them for the two minutes before and after.” That’s tough to replicate virtually, as are other soft skills crucial to managing and mentoring.
Switching from offices before the pandemic to an all-remote setup would be “replacing one dogma with another dogma,” he said. “What does burnout look like? What does mental health look like? What does that connectivity and the community building look like? One of the things I feel is, hey, maybe we are burning some of the social capital we built up in this phase where we are all working remote. What’s the measure for that?”
Microsoft has now reversed their position on this, with two policy changes.
- Employees can work from home freely as long as it’s less than 50% of the working week
- Managers can approve permanent remote work
This is still a bit less drastic than Twitter, which has announced that all employees can permanently work remotely. But it’s still a massive change in policy compared to their position in May.
Employees will also be allowed to relocate domestically or internationally, but they’ll need approval from the company.
As a refresher, here’s the previous question
Given a collection of numbers that may contain duplicates, return all possible unique permutations.
Input - [1, 1, 2, 3]
Output - [[1,1,2,3],[1,1,3,2],[1,2,1,3],[1,2,3,1],[1,3,1,2],[1,3,2,1],[2,1,1,3],[2,1,3,1],[2,3,1,1],[3,1,1,2],[3,1,2,1],[3,2,1,1]]
This is a classic backtracking problem.
This is one of those questions where it’s a lot easier to watch it being solved as opposed to reading a solution, so you should check this video out. It’s the best explanation to this problem that I’ve seen.
The only difference is that with this question, we can have duplicates.
Therefore, the first thing we do in our function is sort the list (sorting is a “free” operation, since the time complexity of finding all permutations is higher than O(n log n)). By doing that, all duplicate items in the input list are right next to each other. That allows us to quickly check (in O(1) time) , if this item is a duplicate (which tell us if we’re already generated this permutation).
We do this on line 10 in our code.
Feel free to reply to this email with any questions!