[AtCoder] E - Two CurrenciesRead more
[Codeforces] Round #143 (Div. 2) D. Magic BoxRead more
[Codeforces] Round #145 (Div. 2, ACM-ICPC Rules) D. CinemaRead more
[Codeforces] Round #145 (Div. 2, ACM-ICPC Rules) E. Champions` LeagueRead more
[Codeforces] Round #145 (Div. 2, ACM-ICPC Rules) G. PracticeRead more
[Codeforces] Round #144 (Div. 1) A. CyclesRead more
[LeetCode] Closest Prime Numbers in Range

2523. Closest Prime Numbers in Range

Given two positive integers left and right, find the two integers num1 and num2 such that:

  • left <= nums1 < nums2 <= right .
  • nums1 and nums2 are both prime numbers.
  • nums2 - nums1 is the minimum amongst all other pairs satisfying the above conditions.

Return the positive integer array ans = [nums1, nums2]. If there are multiple pairs satisfying these conditions, return the one with the minimum nums1 value or [-1, -1] if such numbers do not exist.

A number greater than 1 is called prime if it is only divisible by 1 and itself.

Read more
[LeetCode] Partition String Into Substrings With Values at Most K

2522. Partition String Into Substrings With Values at Most K

You are given a string s consisting of digits from 1 to 9 and an integer k.

A partition of a string s is called good if:

  • Each digit of s is part of exactly one substring.
  • The value of each substring is less than or equal to k.

Return the minimum number of substrings in a good partition of s. If no good partition of s exists, return -1.

Note that:

  • The value of a string is its result when interpreted as an integer. For example, the value of “123” is 123 and the value of “1” is 1.
  • A substring is a contiguous sequence of characters within a string.
Read more
[LeetCode] Distinct Prime Factors of Product of Array

2521. Distinct Prime Factors of Product of Array

Given an array of positive integers nums, return the number of distinct prime factors in the product of the elements of nums.

Note that:

  • A number greater than 1 is called prime if it is divisible by only 1 and itself.
  • An integer val1 is a factor of another integer val2 if val2 / val1 is an integer.
Read more
[LeetCode] Count the Digits That Divide a Number

2520. Count the Digits That Divide a Number

Given an integer num, return the number of digits in num that divide num.

An integer val divides nums if nums % val == 0.

Read more