[Hacker Earth] Fibonacci with GCDRead more
[Codeforces] Round 117 (Div. 2) C. Optimal SumRead more
[LeetCode] Find Missing and Repeated Values

2965. Find Missing and Repeated Values

You are given a 0-indexed 2D integer matrix grid of size n * n with values in the range [1, n2]. Each integer appears exactly once except a which appears twice and b which is missing. The task is to find the repeating and missing numbers a and b.

Return a 0-indexed integer array ans of size 2 where ans[0] equals to a and ans[1] equals to b.

Read more
[LeetCode] Divide Array Into Arrays With Max Difference

2966. Divide Array Into Arrays With Max Difference

You are given an integer array nums of size n and a positive integer k.

Divide the array into one or more arrays of size 3 satisfying the following conditions:

  • Each element of nums should be in exactly one array.
  • The difference between any two elements in one array is less than or equal to k.

Return a 2D array containing all the arrays. If it is impossible to satisfy the conditions, return an empty array. And if there are multiple answers, return any of them.

Read more
[LeetCode] Minimum Cost to Make Array Equalindromic

2967. Minimum Cost to Make Array Equalindromic

You are given a 0-indexed integer array nums having length n.

You are allowed to perform a special move any number of times (including zero) on nums. In one special move you perform the following steps in order:

  • Choose an index i in the range [0, n - 1], and a positive integer x.
  • Add |nums[i] - x| to the total cost.
  • Change the value of nums[i] to x.

A palindromic number is a positive integer that remains the same when its digits are reversed. For example, 121, 2552 and 65756 are palindromic numbers whereas 24, 46, 235 are not palindromic numbers.

An array is considered equalindromic if all the elements in the array are equal to an integer y, where y is a palindromic number less than 109.

Return an integer denoting the minimum possible total cost to make nums *equalindromic by performing any number of special moves.*

Read more
[LeetCode] Apply Operations to Maximize Frequency Score

2968. Apply Operations to Maximize Frequency Score

You are given a 0-indexed integer array nums and an integer k.

You can perform the following operation on the array at most k times:

  • Choose any index i from the array and increase or decrease nums[i] by 1.

The score of the final array is the frequency of the most frequent element in the array.

Return the maximum score you can achieve.

The frequency of an element is the number of occurences of that element in the array.

Read more
[Codeforces] Round 119 (Div. 1) C. Weak MemoryRead more
[Codeforces] Round 123 (Div. 2) E. Building ForestRead more
[Codeforces] Round 122 (Div. 1) B. XorRead more
[Codeforces] Round 124 (Div. 1) B. Infinite MazeRead more