Question: CGI OA 2025 | SHL Coding Assessment | Complete Solutions & Tips | Array Sorting & Kth Smallest Element | Mar 7th Campus Assessment | CGI, Recently Asked Online Assessment
0
Entering edit mode

Question: Kth Smallest Stock Price

Problem Statement:

A stock trader trades in N selected stocks. The trader has calculated the relative stock price changes in the N stocks from the previous day's stock prices. The trader's lucky number is K, so the trader wants to invest in the particular stock that has the Kth smallest relative stock value.

Write an algorithm for the trader to find the Kth smallest stock price among the selected N stocks.

Input Format:

  • The first line of the input consists of an integer - stock_size, representing the number of selected stocks (N).
  • The second line consists of N space-separated integers representing the relative stock prices.
  • (Based on the test case, a third line contains the integer K).

Sample Test Case 1:

Input:

7

1 2 3 4 5 7 9

4

Output:

4

 

ADD COMMENTlink 1 day ago Rohit • 30

Login before adding your answer.

Similar Posts
Loading Similar Posts