Java || Easy Solution || Datatype Manipulation ✨
4 Test cases not passing just for Integer underflow --> \n\n\nclass Solution {\n    public int minimumAverageDifference(int[] nums) {\n        int n = nums.leng
# 4 Test cases not passing just for Integer underflow --> \n\n```\nclass Solution {\n    public int minimumAverageDifference(int[] nums) {\n        int n = nums.length;\n        List<Integer> list = new ArrayList<>();\n        int res[] = new int[n];\n        int pref = 0;\n        int suf = 0;\n        for(int i = 0;i<n;i++){\n            suf += nums[i];\n        }\n        for(int i = 0;i<n-1;i++){\n            pref += nums[i];\n            suf -= nums[i];\n            int lem = pref/(i+1);\n            int sem = suf/(n-i-1);\n            res[i] = Math.abs(lem - sem);\n        }\n        int freshSum = 0;\n        for(int p : nums){\n            freshSum += p;\n        }\n        res[n-1] = Math.abs(freshSum/n);\n        int min = Integer.MAX_VALUE;\n        int result = -1;\n        for(int p : res){\n            if(p < min){\n                min = p;\n            }\n        }\n        for(int i = 0;i<n;i++){\n            if(res[i] == min){\n                list.add(i);\n            }\n        }\n        Collections.sort(list);\n        return list.get(0);\n    }\n}\n```\n\n# Revised code with long datatype-->\n```\nclass Solution {\n    public int minimumAverageDifference(int[] nums) {\n        int n = nums.length;\n        List<Integer> list = new ArrayList<>();\n        long res[] = new long[n];\n        long pref = 0;\n        long suf = 0;\n        for(int i = 0;i<n;i++){\n            suf += nums[i];\n        }\n        for(int i = 0;i<n-1;i++){\n            pref += nums[i];\n            suf -= nums[i];\n            long lem = pref/(i+1);\n            long sem = suf/(n-i-1);\n            res[i] = Math.abs(lem - sem);\n        }\n        long freshSum = 0;\n        for(long p : nums){\n            freshSum += p;\n        }\n        res[n-1] = Math.abs(freshSum/n);\n        long min = Long.MAX_VALUE;\n        int result = -1;\n        for(long p : res){\n            if(p < min){\n                min = p;\n            }\n        }\n        for(int i = 0;i<n;i++){\n            if(res[i] == min){\n               result = i;\n                break;\n            }\n        }\n        return result;\n    }\n}\n```
['Prefix Sum', 'Java']