Hello guys, I am currently transitioning from java to swift, I cant turn the java code below to swift using the prefix sum and hash map. Can someone pls assist me ?
Given an array of integers, both -ve and +ve, find a contiguous subarray that sums to 0.For example: [2,4,-2,1,-3,5,-3] --> [4,-2,1,-3]
sumMap[sum] = i is the Swift equivalent to sumMap.put(sum, i). You can use the subscript notation to both get and set values. You can find more in the Collection Types section of the Swift Programming Language Guide.