All Posts

Leetcode 2541: Minimum Operations to Make Array Equal II

You are given two integer arrays nums1 and nums2 of equal length n and an integer k. You can perform the following operation on nums1: Choose two indexes i and j and increment nums1[i] by k and decrement nums1[j] by k. The goal is to determine the minimum number of operations required to make nums1 equal to nums2. If it is impossible, return -1.

Leetcode 2544: Alternating Digit Sum

You are given a positive integer n. Each digit of n has a sign according to the following rules: The most significant digit is assigned a positive sign. Each other digit has an opposite sign to its adjacent digits. Return the sum of all digits with their corresponding sign.

Leetcode 2549: Count Distinct Numbers on Board

You are given a positive integer n, initially placed on a board. For each number x on the board, find all integers i such that 1 <= i <= n and x % i == 1. Add these numbers to the board. Your goal is to determine how many distinct integers will be present on the board after a billion days.

Leetcode 2550: Count Collisions of Monkeys on a Polygon

You are given a regular convex polygon with n vertices. Each vertex has one monkey. Every monkey can move either clockwise or anticlockwise to a neighboring vertex. A collision occurs if two monkeys land on the same vertex or cross paths on an edge. Your task is to return the number of ways the monkeys can move such that at least one collision happens, modulo 10^9 + 7.

Leetcode 2566: Maximum Difference by Remapping a Digit

You are given an integer num, and you know that Bob will sneakily remap one of the 10 possible digits (0 to 9) to another digit. Your task is to return the difference between the maximum and minimum values Bob can make by remapping exactly one digit in num. If no change is made, the value of num remains the same.

Leetcode 2572: Count the Number of Square-Free Subsets

You are given a positive integer array nums. A subset of the array nums is square-free if the product of its elements is a square-free integer. A square-free integer is an integer that is not divisible by any perfect square other than 1. Return the number of square-free non-empty subsets of the array nums. Since the answer may be too large, return it modulo 10^9 + 7.