JAVA || O(1) || 100% || Logic
\tLOGIC: there are 2 cases even length array and odd length array\n\tcase1: Even length array ex 1,3,5,7,9,11\n\tso we will change every element into (5+7)/2 or
\tLOGIC: there are 2 cases even length array and odd length array\n\tcase1: Even length array ex 1,3,5,7,9,11\n\tso we will change every element into (5+7)/2 or simply \'6\'\n\tso forget right half and convert left operations will be 1 (5 to 6), 3 (3 to 6), 5(1 to 6) and so on \n\thencee answer =(sum f n odd numbers ) i.e (n^2)\n\t\n\tcase2: Odd Length Array ex 1,3,5,7,9\n\tso we will change every element into 5 i.e. middle element\n\tso forget right half and convert left operations will be 2 (3 to 5), 6 (1 to 5) and so on\n\thence answer = (n^2 - n)\n\nclass Solution {\n\t\tpublic int minOperations(int n) {\n\t\t\treturn n*n/4;\n\t\t}\n\t}
[]