Java|| Easy to Understand || main thing is to handle the last index
You can skip the arr part that is redundant that is used only for i/o purpose else you can ommit it.\n\nclass Solution {\n    public int minimumAverageDifferenc
You can skip the `arr` part that is redundant that is used only for i/o purpose else you can ommit it.\n```\nclass Solution {\n    public int minimumAverageDifference(int[] nums) {\n        if(nums.length == 1){\n            return 0;\n        }\n        int idx = -1;\n        long min = Integer.MAX_VALUE;\n        long suml = nums[0];\n        long sumr = 0;\n        for(int i = 1; i < nums.length; i++){\n            sumr += nums[i];\n        }\n        int i = 1;\n        int calc = 0;\n        int left = 1;\n        int right = nums.length - left;\n        long[] arr = new long[nums.length];\n        while(i < nums.length){\n            long diff = Math.abs((suml/left) - (sumr/right));\n            arr[calc] = diff;\n            if(diff < min){\n                min = diff;\n                idx = calc;\n            }\n            suml += nums[i];\n            sumr -= nums[i];\n            left++;\n            right--;\n            calc++;\n            i++;\n        }\n        arr[calc] = suml/nums.length;\n        if(arr[calc] < min){\n            min = arr[calc];\n            idx = nums.length - 1;\n        }\n        // for(i = 0; i < nums.length; i++){\n        //     System.out.println(arr[i]);\n        // }\n        return (int)idx;\n    }\n}\n```
['Java']