Array Product

Interesting problem, mostly because it gave me some good practise in Python programming:

Given an array, output array whose ith index is product of all but the ith input element (without using division)

Code:

 

Median from a data stream

I recently came across an interesting question : “Find Median from Data Stream”

The problem allows one to think of multiple concepts:

[1] Run-time complexity of adding in number to the data structure v/s finding median from the data structure

[2] can we leverage some form of counting sort algo

[3] what kinds of data structures might be useful useful –  heaps, segment trees, AVL etc etc

[4] I sensed some parallels with the range-minimum query problem as well.

 

Code

 

The run-times are not great, but then I was not using any libraries.I wonder what optimizations other folks are doing to improve runtime.

medianpb.JPG