Hello everyone. It's time for my weekly report.
LeetCode
Last week, I spent 8 hours on LeetCode. I solved six problems:
- 122. Best Time to Buy and Sell Stock II - Medium difficulty.
- 123. Best Time to Buy and Sell Stock III - Challenging. I tried to solve it on my own but failed, so I watched a tutorial video for this problem.
- 124. Binary Tree Maximum Path Sum - Challenging. I solved it without hints, although the previous problem could be considered a hint as they are similar in approach.
- 126. Word Ladder II - Challenging. I solved it without hints.
- 126. Word Ladder - Surprisingly, Word Ladder 2 appears before Word Ladder 1 in the list? I copied the code from the previous problem.
- 128. Longest Consecutive Sequence - This is a strange problem with an artificial constraint: it must be an O(n) algorithm, so sorting isn't allowed. I watched a tutorial video for this problem but it was outdated; LeetCode has updated the tests for this task, and the solution from the video now gets a Time Limit Exceeded.
Linux Optimizations
In a previous post, I discussed Linux optimizations that I use on my laptop but didn't provide specific numbers on how much each optimization helps. Here they are:
- Btrfs - 46% disk space saved
- ZSWAP - 50% disk space saved
- KSM - 2.5% memory savings
It turns out that Btrfs and ZSWAP compression save almost half of the disk space 🤯 While KSM only saves memory a little bit: about 2.5%. It consumes approximately 2.9% CPU, though. I didn't measure the impact of Btrfs and ZSWAP on CPU since I couldn't find an easy way to do that.