Leetcode 1674 Solution
This article provides solution to leetcode question 1674 (minimum-operations-to-make-array-equal)
Access this page by simply typing in "lcs 1674" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/minimum-operations-to-make-array-equal
Solution
class Solution:
def f(self, i):
if i == 0:
return 0
elif i == 1:
return 0
return self.f(i - 2) + i - 1
def minOperations(self, n: int) -> int:
if n <= 1:
return 0
if n % 2 == 1:
return int((n - 1)/2 * ((n - 1)/2 + 1))
else:
return int(n * n / 4)