Company: policy bazaar
Difficulty: easy
Kth Smallest Relative Stock Price A stock trader trades in N selected stocks. The trader has already calculated the relative stock price change of each of the N stocks with respect to the previous day's stock price. A relative price change may be negative (the stock lost value), zero (unchanged) or positive (the stock gained value). The trader's lucky number is K , so the trader wants to invest in the particular stock whose relative stock value is the K -th smallest among the N selected stocks. Write a program that reads the relative stock prices and reports the K -th smallest relative stock price. The ranking is done over the multiset of the given values, so equal values are counted separately : if the sorted list of relative prices is 1 1 3 4 5 , then the 1st smallest is 1 , the 2nd smallest is 1 , and the 3rd smallest is 3 . (inferred — the source statement does not discuss repeated values, but the reference implementation shown on the assessment screen sorts the array and returns t