[AtCoder] D - Kth ExcludedRead more
[AtCoder] D - CollisionRead more
[Codeforces] Round #535 (Div. 3) D. Diverse GarlandRead more
[Codeforces] Global Round 1 B. TapeRead more
[Codeforces] Round #542 [Alex Lopashev Thanks-Round] (Div. 2) C. ConnectRead more
[Codeforces] Round #541 (Div. 2) B. Draw!Read more
[Codeforces] Round #549 (Div. 2) C. QueenRead more
[LeetCode] Minimize Rounding Error to Meet Target

1058. Minimize Rounding Error to Meet Target

Given an array of prices [p1,p2…,pn] and a target, round each price pi to Roundi(pi) so that the rounded array [Round1(p1),Round2(p2)…,Roundn(pn)] sums to the given target. Each operation Roundi(pi) could be either Floor(pi) or Ceil(pi).

Return the string “-1” if the rounded array is impossible to sum to target. Otherwise, return the smallest rounding error, which is defined as Σ |Roundi(pi) - (pi)| for i from 1 to n, as a string with three places after the decimal.

Read more
[LeetCode] Matchsticks to Square

473. Matchsticks to Square

You are given an integer array matchsticks where matchsticks[i] is the length of the ith matchstick. You want to use all the matchsticks to make one square. You should not break any stick, but you can link them up, and each matchstick must be used exactly one time.

Return true if you can make this square and false otherwise.

Read more
[LeetCode] Minimum Operations to Make Array Equal

1551. Minimum Operations to Make Array Equal

You have an array arr of length n where arr[i] = (2 * i) + 1 for all valid values of i (i.e., 0 <= i < n).

In one operation, you can select two indices x and y where 0 <= x, y < n and subtract 1 from arr[x] and add 1 to arr[y] (i.e., perform arr[x] -=1 and arr[y] += 1). The goal is to make all the elements of the array equal. It is guaranteed that all the elements of the array can be made equal using some operations.

Given an integer n, the length of the array, return the minimum number of operations needed to make all the elements of arr equal.

Read more