Kotlin - Typical Sliding Window Approach with a HashSet
Solution - github\n\nProblem List\n#SlidingWindow - github\n#Subarray - github\n\n\n/**\n * @author: Leon\n * https://leetcode.com/problems/maximum-erasure-valu
Solution - [github](https://github.com/An7One/leetcode-solutions-kotlin-an7one/tree/main/src/main/kotlin/com/an7one/leetcode/lvl3/lc1695)\n\n<b>Problem List</b>\n#SlidingWindow - [github](https://github.com/An7One/leetcode-problems-by-tag-an7one/tree/main/txt/by_technique/n_pointers/by_pointer_amount/2_pointers/sliding_window)\n#Subarray - [github](https://github.com/An7One/leetcode-problems-by-tag-an7one/blob/main/txt/by_data_structure/array/by_data_structure/subarray.txt)\n\n```\n/**\n * @author: Leon\n * https://leetcode.com/problems/maximum-erasure-value/\n *\n * Time Complexity:     O(`nNums`)\n * Space Complexity:    O(`nNums`)\n */\nclass Solution {\n    fun maximumUniqueSubarray(nums: IntArray): Int {\n        val nNums = nums.size\n        \n        var lo = 0\n        var hi = 0\n        var largest = 0\n        var sum = 0\n        \n        val seen = HashSet<Int>()\n        \n        while(hi < nNums){\n\t\t    // to accumulate the running sum\n            sum += nums[hi]\n\t\t\t\n            // to narrow the sliding window,\n\t\t\t// once any previously visited element has been found,\n\t\t\t// till it has been removed in the current (sliding) window.\n            while(seen.contains(nums[hi])){\n                sum -= nums[lo]\n                seen.remove(nums[lo])\n                ++lo\n            }\n            \n\t\t\t// to mark the element as visited\n            seen.add(nums[hi])\n            \n\t\t\t// to keep track of the largest running sum ever showing up\n            largest = maxOf(largest, sum)\n\t\t\t\n\t\t\t// to enlarge the window\n            ++hi\n        }\n        \n        return largest\n    }\n}\n```
['Two Pointers', 'Sliding Window', 'Kotlin']