LeetCode - 150 - Multiply Strings

The problem Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string. Note: You must not use any built-in BigInteger library or convert the inputs to integers directly. Example 1: Input: num1 = "2", num2 = "3" Output: "6" Example 2: Input: num1 = "123", num2 = "456" Output: "56088" Constraints: 1 <= num1.length, num2.length <= 200 num1 and num2 consist of digits only. Both num1 and num2 do not contain any leading zeros, except the number 0 itself. Multiplication Solution Explanation We can multiply two numbers using the stacked method. We are going to start iterating from right to left in reverse order, multiplying each value in num1 with a value in num2. If the result is greater than or equal to 10, we are going to carry an additional value. For example, with num1 = 123 and num2 = 45: ...

June 17, 2026 · 3 min · Dmytro Chumakov

LeetCode - 150 - Pow(x, n)

The Problem Implement pow(x, n), which calculates x raised to the power n (i.e., xⁿ). Example 1: Input: x = 2.00000, n = 10 Output: 1024.00000 Example 2: Input: x = 2.10000, n = 3 Output: 9.26100 Example 3: Input: x = 2.00000, n = -2 Output: 0.25000 Explanation: 2^-2 = 1/2^2 = 1/4 = 0.25 Constraints: -100.0 < x < 100.0 -2^31 <= n <= 2^31 - 1 n is an integer. Either x is not zero or n > 0. -10^4 <= x^n <= 10^4 Brute Force Solution Explanation The brute force way to solve this problem without using built-in functions is to use a while loop and multiply the x value n times. The problem with this solution is that it will not pass on LeetCode because it takes O(n) time. ...

June 13, 2026 · 3 min · Dmytro Chumakov

LeetCode - 150 - Minimum Interval to Include Each Query

The problem You are given a 2D integer array intervals, where intervals[i] = [lefti, righti] describes the ith interval starting at lefti and ending at righti (inclusive). The size of an interval is defined as the number of integers it contains, or more formally righti - lefti + 1. You are also given an integer array queries. The answer to the jth query is the size of the smallest interval i such that lefti <= queries[j] <= righti. If no such interval exists, the answer is -1. ...

June 4, 2026 · 4 min · Dmytro Chumakov

LeetCode - 150 - Valid Parenthesis String

The problem Given a string s containing only three types of characters: '(', ')', and '*', return true if s is valid. The following rules define a valid string: Any left parenthesis '(' must have a corresponding right parenthesis ')'. Any right parenthesis ')' must have a corresponding left parenthesis '('. A left parenthesis '(' must go before the corresponding right parenthesis ')'. '*' could be treated as a single right parenthesis ')', a single left parenthesis '(', or an empty string "". Example 1: ...

May 26, 2026 · 3 min · Dmytro Chumakov

LeetCode - 150 - Partition Labels

LeetCode - 150 - Partition Labels The problem You are given a string s. We want to partition the string into as many parts as possible so that each letter appears in at most one part. For example, the string "ababcc" can be partitioned into ["abab", "cc"], but partitions such as ["aba", "bcc"] or ["ab", "ab", "cc"] are invalid. Note that the partition is done so that after concatenating all the parts in order, the resultant string should be s. ...

May 18, 2026 · 3 min · Dmytro Chumakov