You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Primary idea: Dynamic Programming, track Left and Right product lists at the same time and just use one additional array.The problem statement mentions that using theanswer array doesn't add to the space complexity.
* Time Complexity: O(n), Space Complexity: O(1)
*/
class ProductExceptSelfNotUseDivide{
func productExceptSelf(_ nums: [Int]) -> [Int] {
var arr = Array.init(repeating: 1, count: nums.count)