Leetcode Question of Today
70 subscribers
472 links
Send Question of Today from Leetcode everyday at 0:00 (UTC)
Download Telegram
2021-12-11
878. Nth Magical Number

Topic: Math, Binary Search
Difficulty: Hard

Problem:
A positive integer is magical if it is divisible by either a or b.

Given the three integers n, a, and b, return the n^th magical number. Since the answer may be very large, return it modulo 10^9 + 7.

Example 1:

Input: n = 1, a = 2, b = 3
Output: 2


Example 2:

Input: n = 4, a = 2, b = 3
Output: 6


Example 3:

Input: n = 5, a = 2, b = 4
Output: 10


Example 4:

Input: n = 3, a = 6, b = 4
Output: 8



Constraints:

1 <= n <= 10^92 <= a, b <= 4 * 10^4
2021-12-12
416. Partition Equal Subset Sum

Topic: Array, Dynamic Programming
Difficulty: Medium

Problem:
Given a non-empty array nums containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both subsets is equal.

Example 1:

Input: nums = [1,5,11,5]
Output: true
Explanation: The array can be partitioned as [1, 5, 5] and [11].


Example 2:

Input: nums = [1,2,3,5]
Output: false
Explanation: The array cannot be partitioned into equal sum subsets.


Constraints:

1 <= nums.length <= 200
1 <= nums[i] <= 100