Hi there 馃憢

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

LeetCode - Blind 75 - Sum of Two Integers

The problem Given two integers聽a聽and聽b, return聽the sum of the two integers without using the operators聽+聽and聽-. Examples Input: a = 1, b = 2 Output: 3 Input: a = 2, b = 3 Output: 5 Constraints -1000 <= a, b <= 1000 Explanation From the description of the problem, we learn that we need to figure out the way of adding two numbers without using + or - operators. Let鈥檚 visualize this problem and find the way we can do it. ...

May 14, 2025 路 3 min 路 Dmytro Chumakov

LeetCode - Blind 75 - Missing Number

The problem Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array. Examples Input: nums = [3,0,1] Output: 2 Explanation: n = 3 since there are 3 numbers, so all numbers are in the range [0,3]. 2 is the missing number in the range since it does not appear in nums. Input: nums = [0,1] Output: 2 Explanation: n = 2 since there are 2 numbers, so all numbers are in the range [0,2]. 2 is the missing number in the range since it does not appear in nums. Input: nums = [9,6,4,2,3,5,7,0,1] Output: 8 Explanation: n = 9 since there are 9 numbers, so all numbers are in the range [0,9]. 8 is the missing number in the range since it does not appear in nums. Constraints n == nums.length 1 <= n <= 10^4 0 <= nums[i] <= n All the numbers of nums are unique. Follow up: Could you implement a solution using only O(1) extra space complexity and O(n) runtime complexity? ...

May 12, 2025 路 4 min 路 Dmytro Chumakov

LeetCode - Blind 75 - Reverse Bits

The problem Reverse bits of a given 32-bit unsigned integer. Note: Note that in some languages, such as Java, there is no unsigned integer type. In this case, both input and output will be given as a signed integer type. They should not affect your implementation, as the integer鈥檚 internal binary representation is the same, whether it is signed or unsigned. In Java, the compiler represents the signed integers using 2鈥檚 complement notation. Therefore, in Example 2 above, the input represents the signed integer -3 and the output represents the signed integer -1073741825. Examples Input: n = 00000010100101000001111010011100 Output: 964176192 (00111001011110000010100101000000) Explanation: The input binary string 00000010100101000001111010011100 represents the unsigned integer 43261596, so return 964176192, whose binary representation is 00111001011110000010100101000000. Input: n = 11111111111111111111111111111101 Output: 3221225471 (10111111111111111111111111111111) Explanation: The input binary string 11111111111111111111111111111101 represents the unsigned integer 4294967293, so return 3221225471, whose binary representation is 10111111111111111111111111111111. Constraints The input must be a binary string of length 32 Follow up: If this function is called many times, how would you optimize it? ...

May 10, 2025 路 4 min 路 Dmytro Chumakov

LeetCode - Blind 75 - Counting Bits

The problem Given an integer聽n, return聽an array聽ans聽of length聽n + 1聽such that for each聽i聽(0 <= i <= n),聽ans[i]聽is the聽number of聽1s聽in the binary representation of聽i. Examples Input: n = 2 Output: [0,1,1] Explanation: 0 --> 0 1 --> 1 2 --> 10 Input: n = 5 Output: [0,1,1,2,1,2] Explanation: 0 --> 0 1 --> 1 2 --> 10 3 --> 11 4 --> 100 5 --> 101 Constraints 0 <= n <= 10^5 Follow up: ...

May 8, 2025 路 5 min 路 Dmytro Chumakov

LeetCode - Blind 75 - Number of 1 Bits

The problem Given a positive integer聽n, write a function that returns the number of聽set bits聽in its binary representation (also known as the聽Hamming weight). A set bit refers to a bit in the binary representation of a number that has a value of聽1. Examples Input:聽n = 11 Output:聽3 Explanation: The input binary string聽1011聽has a total of three set bits. Input:聽n = 128 Output:聽1 Explanation: The input binary string聽10000000聽has a total of one set bit. Input:聽n = 2147483645 Output:聽30 Explanation: The input binary string聽1111111111111111111111111111101聽has a total of thirty set bits. Constraints 1 <= n <= 2^31 - 1 Follow up:聽If this function is called many times, how would you optimize it? ...

May 5, 2025 路 3 min 路 Dmytro Chumakov