C++O(n)
Intuition\nAll numbers converge at n / 2, and it\'s true for arrays of even and odd lenghts. Just solve a few examples by hand and it\'ll become clear how to so
**Intuition**\nAll numbers converge at `n / 2`, and it\'s true for arrays of even and odd lenghts. Just solve a few examples by hand and it\'ll become clear how to solve it.\n\nNote that we only need to go till `n / 2`, since we increasing/decreasing two \'oposite\' numbers at the same time.\n\n```cpp\nint minOperations(int n) {\n    int res = 0;\n    for (int i = 0; i < n / 2; ++i)\n        res += n - i * 2 - 1;\n    return res;\n}\n```
[]