You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: DSA Crack Sheet/README.md
+1
Original file line number
Diff line number
Diff line change
@@ -113,6 +113,7 @@
113
113
-[Sort by Set Bit Count](https://practice.geeksforgeeks.org/problems/sort-by-set-bit-count1153/1#"view question") - [Cpp Solution](./solutions/Sort%20by%20Set%20Bit%20Count.cpp)
114
114
-[Minimum Swaps to Sort](https://practice.geeksforgeeks.org/problems/minimum-swaps/1#"view question") - [Cpp Solution](./solutions/Minimum%20Swaps%20to%20Sort.cpp)
115
115
-[Bishu and Soldiers](https://www.hackerearth.com/practice/algorithms/searching/binary-search/practice-problems/algorithm/bishu-and-soldiers/"view question") - [Cpp Solution](./solutions/Bishu%20and%20Soldiers.cpp)
116
+
-[Kth smallest number again](https://www.hackerearth.com/practice/algorithms/searching/binary-search/practice-problems/algorithm/kth-smallest-number-again-2/"view question") - [Cpp Solution](./solutions/Kth%20smallest%20number%20again.cpp)
Dexter was good in finding the K th smallest number from a set of numbers. He thought he could solve any problem related to K th smallest number. His friend Pipi challenged him with a problem.
6
+
He gave him various ranges of number, These numbers were arranged in increasing order(only distinct numbers to be taken into account). Now he asked him to find the K th smallest number in the sequence, again and again.
7
+
8
+
Input Format
9
+
The first line contains T, the number of test cases.
10
+
For each test case, there will be two integers N and Q.
11
+
Then N lines follow each line containing two integers A and B (denoting the range A-B)
12
+
Then Q lines follow each line containing a non-negative integer K .
13
+
14
+
Output Format
15
+
For each query output the K th smallest number.
16
+
17
+
Constraints
18
+
1 <= T <= 100
19
+
1 <= N <= 100
20
+
1 <= Q <= 1000
21
+
-10^18 <= A <= B <= 10^18
22
+
K >= 1
23
+
24
+
N.B. If Kth smallest number is not present in the series, print -1
25
+
26
+
Sample Input
27
+
1
28
+
1 3
29
+
1 5
30
+
1
31
+
3
32
+
6
33
+
Sample Output
34
+
1
35
+
3
36
+
-1
37
+
38
+
Time Limit: 5
39
+
Memory Limit: 256
40
+
41
+
Explanation
42
+
The numbers are "1 2 3 4 5". The 1st smallest number is 1
43
+
The 3rd smallest number is 3 The 6th smallest number is not present. Hence answer is -1
0 commit comments