class Solution { public: int minOperations(int n) { int ans = 0; if(n%2) { // sum of first n/2 terms int terms = n/2; int curr_sum = terms*terms; int reqd_sum = (2*terms + 1)*terms; ans = reqd_sum - curr_sum; } else { // sum of first n/2 terms int terms = n/2; int curr_sum = terms*terms; int value = (2*(terms-1) + 1) + 1; int reqd_sum = value*terms; ans = reqd_sum - curr_sum; } return ans; } };