Python Programming Interview Questions

Given an array A[N] containing N numbers. Crate an array Output[N] where Output[i] is equal to the product of all the elements of A[N] except A[i].

For example Output[0] is the product of A[1] to A[N-1] and Output[1] is the product of A[0] and from A[2] to A[N-1].

Do this without using the division operator. Do it in O(n).

Write a function that takes as input a sorted array and modifies the array to compact it, removing duplicates. Also return the new length of the array.

Notes: The input array might be very large.

For example:

  • input array = [1, 3, 7, 7, 8, 9, 9, 9, 10]
  • transformed array = [1, 3, 7, 8, 9, 10]
  • size = 6