Hi there 👋

This blog is intended to share my knowledge about software architecture, system design, tools, and techniques for producing high-quality products.

LeetCode - 150 - Subsets

The problem Given an integer array nums of unique elements, return all possible subsets (the power set). A subset of an array is a selection of elements (possibly none) of the array. The solution set must not contain duplicate subsets. Return the solution in any order. Examples Input: nums = [1,2,3] Output: [[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]] Input: nums = [0] Output: [[],[0]] Constraints 1 <= nums.length <= 10 -10 <= nums[i] <= 10 All the numbers of nums are unique. Explanation From the description of the problem we learn that we need to return every single subset that we can create from input nums, without any duplicates. ...

August 27, 2025 · 3 min · Dmytro Chumakov

LeetCode - 150 - Design Twitter

The problem Design a simplified version of Twitter where users can post tweets, follow/unfollow another user, and are able to see the 10 most recent tweets in the user’s news feed. Implement the Twitter class: Twitter() Initializes your Twitter object. void postTweet(int userId, int tweetId) Composes a new tweet with ID tweetId by the user userId. Each call to this function will be made with a unique tweetId. List<Integer> getNewsFeed(int userId) Retrieves the 10 most recent tweet IDs in the user’s news feed. Each item in the news feed must be posted by users who the user followed or by the user themselves. Tweets must be ordered from most recent to least recent. void follow(int followerId, int followeeId) The user with ID followerId starts following the user with ID followeeId. void unfollow(int followerId, int followeeId) The user with ID followerId stops following the user with ID followeeId. Examples Input ["Twitter", "postTweet", "getNewsFeed", "follow", "postTweet", "getNewsFeed", "unfollow", "getNewsFeed"] [[], [1, 5], [1], [1, 2], [2, 6], [1], [1, 2], [1]] Output [null, null, [5], null, null, [6, 5], null, [5]] Explanation Twitter twitter = new Twitter(); twitter.postTweet(1, 5); // User 1 posts a new tweet (id = 5). twitter.getNewsFeed(1); // User 1's news feed should return a list with 1 tweet id -> [5]. return [5] twitter.follow(1, 2); // User 1 follows user 2. twitter.postTweet(2, 6); // User 2 posts a new tweet (id = 6). twitter.getNewsFeed(1); // User 1's news feed should return a list with 2 tweet ids -> [6, 5]. Tweet id 6 should precede tweet id 5 because it is posted after tweet id 5. twitter.unfollow(1, 2); // User 1 unfollows user 2. twitter.getNewsFeed(1); // User 1's news feed should return a list with 1 tweet id -> [5], since user 1 is no longer following user 2. Constraints 1 <= userId, followerId, followeeId <= 500 0 <= tweetId <= 10^4 All the tweets have unique IDs. At most 3 * 10^4 calls will be made to postTweet, getNewsFeed, follow, and unfollow. A user cannot follow himself. Explanation Let’s start with the easy part of this problem that are follow and unfollow operations and move up as we go. ...

August 25, 2025 · 6 min · Dmytro Chumakov

LeetCode - 150 - Task Scheduler

The problem You are given an array of CPU tasks, each labeled with a letter from A to Z, and a number n. Each CPU interval can be idle or allow the completion of one task. Tasks can be completed in any order, but there’s a constraint: there has to be a gap of at least n intervals between two tasks with the same label. Return the minimum number of CPU intervals required to complete all tasks. ...

August 19, 2025 · 5 min · Dmytro Chumakov

LeetCode - 150 - Kth Largest Element in an Array

The problem Given an integer array nums and an integer k, return the kth largest element in the array. Note that it is the kth largest element in the sorted order, not the kth distinct element. Can you solve it without sorting? Examples Input: nums = [3,2,1,5,6,4], k = 2 Output: 5 Input: nums = [3,2,3,1,2,4,5,5,6], k = 4 Output: 4 Constraints 1 <= k <= nums.length <= 10^5 -10^4 <= nums[i] <= 10^4 Explanation From the description of the problem we learn that we need to find the kth largest element from the given array. The kth element means if, for example, we had k = 1 then we would return the first largest element, or if we had k = 3 then we would return the third largest element. ...

August 15, 2025 · 2 min · Dmytro Chumakov

LeetCode - 150 - K Closest Points to Origin

The problem Given an array of points where points[i] = [xi, yi] represents a point on the X-Y plane and an integer k, return the k closest points to the origin (0, 0). The distance between two points on the X-Y plane is the Euclidean distance (i.e., √(x1 - x2)^2 + (y1 - y2)^2). You may return the answer in any order. The answer is guaranteed to be unique (except for the order that it is in). ...

August 13, 2025 · 4 min · Dmytro Chumakov