Problem1(minimum_loss.py) : in a time series array find the minimum possible "loss" that can be incurred. Problem at : https://www.hackerrank.com/challenges/minimum-loss/problem
My solution in N log n time. Uee quicksort type implementation. As we move through the array we pick first element as pivot and move the future elements in order into left and right arrays and make recursive calls to these sub arrays. Here we just check differences between pivot element and left array as we need the loss. Advantage: no fancy library needed just knowledge of data structures. Code available at : https://github.com/arpanojha/My_algorithms/tree/master/hacker%20rank |
Archives
March 2022
Categories |