Last active
September 10, 2024 09:36
-
-
Save AashishNandakumar/1b4c9ed1b5786fffa0c274b05840363d to your computer and use it in GitHub Desktop.
September 10th 2024 Questions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n, k = map(int, input().split()) | |
a = list(map(int, input().split())) | |
a.sort() | |
if k == 0: | |
min_ele = a[0] | |
if min_ele == 1: | |
print(-1) | |
else: | |
print(min_ele - 1) | |
else: | |
res = a[k - 1] | |
if k < n and a[k] <= res: | |
print(-1) | |
else: | |
print(res) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution: | |
#Function to find the maximum number of meetings that can | |
#be performed in a meeting room. | |
def maximumMeetings(self,n,start,end): | |
# code here | |
res = list(zip(start, end)) | |
res.sort(key=lambda x: x[1]) | |
ref = res[0] | |
count = 1 | |
for i in range(1, n): | |
if res[i][0] > ref[0] and res[i][0] > ref[1]: | |
count += 1 | |
ref = res[i] | |
return count |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment