[LeetCode] Special Permutations

2741. Special Permutations

You are given a 0-indexed integer array nums containing n distinct positive integers. A permutation of nums is called special if:

  • For all indexes 0 <= i < n - 1, either nums[i] % nums[i+1] == 0 or nums[i+1] % nums[i] == 0.

Return the total number of special permutations. As the answer could be large, return it modulo 109 + 7.

Read more
[LeetCode] Find the Value of the Partition

2740. Find the Value of the Partition

You are given a positive integer array nums.

Partition nums into two arrays, nums1 and nums2, such that:

  • Each element of the array nums belongs to either the array nums1 or the array nums2.
  • Both arrays are non-empty.
  • The value of the partition is minimized.

The value of the partition is |max(nums1) - min(nums2)|.

Here, max(nums1) denotes the maximum element of the array nums1, and min(nums2) denotes the minimum element of the array nums2.

Return the integer denoting the value of such partition.

Read more
[LeetCode] Total Distance Traveled

2739. Total Distance Traveled

A truck has two fuel tanks. You are given two integers, mainTank representing the fuel present in the main tank in liters and additionalTank representing the fuel present in the additional tank in liters.

The truck has a mileage of 10 km per liter. Whenever 5 liters of fuel get used up in the main tank, if the additional tank has at least 1 liters of fuel, 1 liters of fuel will be transferred from the additional tank to the main tank.

Return the maximum distance which can be traveled.

Note: Injection from the additional tank is not continuous. It happens suddenly and immediately for every 5 liters consumed.

Read more
[Codeforces] Beta Round 96 (Div. 1) C. Logo TurtleRead more
[Codeforces] Round 100 B. New Year CardsRead more
[Codeforces] Round 100 C. New Year SnowmenRead more
[Codeforces] Round 100 D. New Year ContestRead more
[Codeforces] Round 101 (Div. 2) C. QueueRead more
[Codeforces] Round 102 (Div. 1) B. Help GeneralRead more
[Codeforces] Round 104 (Div. 1) B. Lucky Number 2Read more