Course Schedule III | Live Coding with Explanation | Leetcode - 630

preview_player
Показать описание


To support us you can donate

Check out our other popular playlists:
Questions you might like:

If you find any difficulty or have any query then do COMMENT below. PLEASE help our channel by SUBSCRIBING and LIKE our video if you found it helpful.

#coding #leetcode #programminglife #programmingisfun #programmer #tech #software #codinglife #leetcode
Рекомендации по теме
Комментарии
Автор

Brilliant I really like your visualizations in every problem which makes it easy to understand. You made the hard problem very easy.

aditgandhi
Автор

Thank you teacher! I really appreaciate that smooth explanation of what is going on with this leetcode problem :)

andresm-pfij
Автор

Very well explained!
Thank you for making such amazing videos.

shivambhardwaj
Автор

great video, thanks for the explanation

shauryatomer
Автор

best explanation, thank you so much ma'am !!

shiwani
Автор

Amazing explanation!! Thank you so much

arushiarora
Автор

Thanks for your approch & solution. I completely understood .

praveenj
Автор

Can anyone tell me what is the mistake that I am making with my code?

class Solution:
def scheduleCourse(self, courses: List[List[int]]) -> int:
courses.sort(key = lambda x:x[1])

maxindex = None
output = []
currtime = 0

for i in range(len(courses)):
if currtime + courses[i][0] <= courses[i][1]: #good condition
currtime += courses[i][0]
output.append(courses[i])
#check maxindex
if maxindex is not None:
if courses[i][0] > courses[maxindex][0]:
maxindex = i
else:
maxindex = i
else:
if maxindex is not None:
if courses[i][0] < courses[maxindex][0]:
#now we are interested in swapping with maxindex
if (currtime + courses[i][0]) - courses[maxindex][0] < courses[i][1]:
#it should also satisfy the above condition
currtime -= courses[maxindex][0]

output.append(courses[i])
currtime += courses[i][0]
maxindex = i


return len(output)

narenmohan
Автор

can't we do it in less time than nlogn? like O(n) or O(n+m). If we can avoid sorting, can we achieve better solution?

venkatkrishna
Автор

Is Time complexity=O(N log N) and space=O(N)? Correct me if I am wrong

gaunikasrivastava
Автор

Could you also add explanation of dp approach for this problem ? Thank you for the explanation!

shubhamlahoti
Автор

I think in the else block we again have to check wether we can add the course or not

none
Автор

Tum hi ho,
Jo,
Exam ko RAATEE laga laga ke pass karti ho...

talwaarkidhaar
Автор

I am having a hard time understanding the Arrays.sort() line.
It would be a kind gesture if someone can elaborate.

rahulrajtripathi
Автор

Could you add time stamps to your video?

ayushthakur
welcome to shbcf.ru