Given an array of numbers, return array of products of all other numbers (no division)

I was asked this question in a job interview, and I’d like to know how others would solve it. I’m most comfortable with Java, but solutions in other languages are welcome. Given an array of numbers, nums, return an array of numbers products, where products[i] is the product of all nums[j], j != i. Input … Read more

Array.Add vs +=

I’ve found some interesting behaviour in PowerShell Arrays, namely, if I declare an array as: $array = @() And then try to add items to it using the $array.Add(“item”) method, I receive the following error: Exception calling “Add” with “1” argument(s): “Collection was of a fixed size.” However, if I append items using $array += … Read more