Recursive + meme | TLE
Intuition\n- At any index we have two option to be part of previous subarray or start a new subarray.\n\n# Code\n\nclass Solution {\n    public static long maxi
# Intuition\n- At any index we have two option to be part of previous subarray or start a new subarray.\n\n# Code\n```\nclass Solution {\n    public static long maximumTotalCost(int[] nums) {\n        HashMap<String, Long> map = new HashMap<>();\n\n        return helper(0, false, nums, 0, map);\n    }\n\n    public static long helper(int idx, boolean isOdd, int[] nums, long sum, HashMap<String, Long> map) {\n        if (idx == nums.length)\n            return sum;\n\n        String key = idx + " " + isOdd + " " + sum;\n        if (map.containsKey(key)) {\n            return map.get(key);\n        }\n\n        long take = helper(idx + 1, !isOdd, nums, sum + (isOdd ? -(nums[idx]) : nums[idx]), map);\n        long skip = sum + helper(idx + 1, isOdd, nums, nums[idx], map);\n\n        map.put(key, Math.max(take, skip));\n        return Math.max(take, skip);\n    }\n}\n```
['Hash Table', 'Recursion', 'Java']