Input n integers: a0, a1, a2... an
Output: An array {a1.a2...an , a0.a2...an , a0.a1...an , a1.a2...an-1 } Such the element at ith location would be multiple of all integers except ai
Solutions:
Brute force : O(n2)
Division Method : create a variable: a0.a1...an . Iterate it, for each iteration, divide it with ith element. O(n)
Do not use Division : Start filling the array with with a0.a1...ai-1 for ith element. Then, do the reverse, multiplying with the number in the array. O(n)