Random commentary about Machine Learning, BigData, Spark, Deep Learning, C++, STL, Boost, Perl, Python, Algorithms, Problem Solving and Web Search
1) Sort the array using something like QuickSort or Divide and Conquer [ O(nlgn) running time ]2) Walk thru' the array computing difference between two consecutive integers holding the minimum and the index [ O(n) running time].So effective running time is O(n lg n)
1) Sort the array using something like QuickSort or Divide and Conquer [ O(nlgn) running time ]
ReplyDelete2) Walk thru' the array computing difference between two consecutive integers holding the minimum and the index [ O(n) running time].
So effective running time is O(n lg n)