✅  [Java]  Easy Java Solution using Arrays, running prefix & suffix (explained).
This question can be easily solved if you know the basic operations of Arrays in java.\n Although it\'s not the best optimised code but it can be easily underst
## This question can be easily solved if you know the basic operations of Arrays in java.\n Although it\'s not the best optimised code but it can be easily understood by the beginners.\n\nFirst we are calculating the total sum of the elements of array nums and storing it in the variable sum.\n\nand then we are calculating leftsum,rightsum and Average Difference for every Index and we are storing the index of minimum average index in the variable index.\nand finally we are returning the index.\n**Runtime: 17 ms, faster than 95.63%**\n```\nclass Solution {\n    public int minimumAverageDifference(int[] nums) {\n        int l = nums.length;  \n        int index = 0;\n        long min = Integer.MAX_VALUE, sum = 0, leftsum = 0, rightsum = 0;\n        for (int j = 0; j < l; j++) {\n            sum = sum + nums[j];\n        }\n        for (int i = 0; i < l; i++) {\n            leftsum += nums[i];\n            rightsum = sum - leftsum;\n            long diff = Math.abs(leftsum / (i + 1) - (l - i == 1 ? 0 : rightsum / (l - i - 1)));  // if number of rightsum values = 0\n            if (diff < min) {\n                min = diff;\n                index = i;\n            }\n        }\n        return index;\n\n    }\n}\n```\n# **\n# Please upvote if this helps**\n## Thanks
['Array', 'Java']