C++ Super Simple Intuitive 4-line Explained Solution - 0 ms, Fatser than 100%
We have to sum the difference between the median of the array (which will always be n) and the current number.\nWhy will the median always be n?\nLet\'s see exa
We have to sum the difference between the median of the array (which will always be n) and the current number.\nWhy will the median always be n?\nLet\'s see examples:\n* n = 1: arr = [1], medain = 1\n* n = 2: arr = [1, 3], median = 2\n* n = 3: arr = [1, 3, 5], median = 3\n* n = 4: arr = [1, 3, 5, 7], median = 4\nAnd so on.\n```\nclass Solution {\npublic:\n    int minOperations(int n) {\n        int res = 0;\n        for (int i = 0; i < n/2; i++) {\n            res += n - (2 * i + 1);\n        }\n        return res;\n    }\n};\n```\n**Like it? please upvote!**
['C']