Created
August 29, 2021 19:18
-
-
Save goish135/66eb795ef1821cc8824c0404f6ea656b to your computer and use it in GitHub Desktop.
This file contains 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: | |
def solve(self, times): | |
times.sort(key=lambda x: x[1]) | |
print(times) | |
counter = 0 | |
end = -1 | |
for i in range(len(times)): | |
print("start:",times[i][0]) | |
print("dy. end:",end) | |
if times[i][0] >= end: | |
counter += 1 | |
end = times[i][1] | |
return counter | |
ob = Solution() | |
''' | |
times = [ | |
[3, 6], | |
[6, 9], | |
[7, 8], | |
[9, 11] | |
] | |
''' | |
#times =[[1, 2], [1, 3], [2, 3], [3, 4]] # test case | |
times =[[3, 4],[1, 2], [1, 3], [2, 3]] | |
print(ob.solve(times)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment