Тёмный

Minimum Number of Moves to Seat Everyone - Leetcode 2037 - Python 

NeetCodeIO
Подписаться 146 тыс.
Просмотров 7 тыс.
50% 1

🚀 neetcode.io/ - A better way to prepare for Coding Interviews
🧑‍💼 LinkedIn: / navdeep-singh-3aaa14161
🐦 Twitter: / neetcode1
⭐ BLIND-75 PLAYLIST: • Two Sum - Leetcode 1 -...
Problem Link: leetcode.com/problems/minimum...
0:00 - Read the problem
0:30 - Drawing Explanation
8:42 - Coding Explanation
leetcode 2037
#neetcode #leetcode #python

Наука

Опубликовано:

 

10 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 43   
@yelnil
@yelnil 28 дней назад
The way this question was worded made it hard to understand.
@asagiai4965
@asagiai4965 28 дней назад
This. It is an easy question, some people would think hard or be confused about. This is the problem with programmers or engineers sometimes making something easy confusingly hard.
@RTZemun
@RTZemun 28 дней назад
sounds like a skill issue to me
@whyredvince
@whyredvince 28 дней назад
@@RTZemun Yeah on part of the person who wrote this question
@GPT-X938
@GPT-X938 27 дней назад
@@RTZemun shoo fly
@RTZemun
@RTZemun 27 дней назад
@@GPT-X938 zap zap can win
@adama7752
@adama7752 28 дней назад
Man finds counting sort hammer. Processed to see counting sort nails.
@AnordinaryMan007
@AnordinaryMan007 28 дней назад
Thanks for the different approaches.
@kraav4ikk6
@kraav4ikk6 27 дней назад
thank you for different solutions!
@kavyanshpandey3823
@kavyanshpandey3823 26 дней назад
1. Sort both array. 2. Add abs different of same index value.
@jessicakoch2331
@jessicakoch2331 28 дней назад
i literally had no idea what they were asking in this question….once nice thing in interviews is that at least you can ask clarifying questions
@freecourseplatformenglish2829
@freecourseplatformenglish2829 27 дней назад
considering array is small sorting is sweet and simple approach. Counting sort can be discussed if interviewer ask for more optimised approach.
@kavyanshpandey3823
@kavyanshpandey3823 26 дней назад
Following you since last 4 month with 95 percent consistency
@jotrades26
@jotrades26 28 дней назад
This week , Leetcode has made us to count numbers 👏👏
@John-ht4xv
@John-ht4xv 27 дней назад
thanks man i've been doing the daily Q for the last few weeks and it's always good to double check against your solutions
@asagiai4965
@asagiai4965 28 дней назад
This is an example of how to make an easy question confusing. Neet's explanation is good. But how is this question presented? It makes it confusing. Also, about the constraints. How I look at it is; students and seats are less than or equal 100 but not less than 1. Does that mean the. Max # you can iterate is 100? The number of items in each array doesn't matter? But both must not be greater than 100 or less than 1. Example if seats [1~100] and students [1~100] then the moves will be 0? Because every students have every seat?
@pastori2672
@pastori2672 27 дней назад
yeah i came up with both solutions and was confused why the regular sorting was consistently faster then couting sort
@sandro-of9fq
@sandro-of9fq 28 дней назад
You are doing god's work. I can't describe to you how much your videos have helped me in learning algorithms. I will forever be grateful!
@junaidmahmud2894
@junaidmahmud2894 28 дней назад
If you consider space complexity, nlogn solution would be preferable
@sophiophile
@sophiophile 28 дней назад
Space complexity of python's built in sort (timsort variant) is theta n. So all the solutions are basically equivalent for time/space.
@sophiophile
@sophiophile 28 дней назад
Space is not free for sort in python. It's omega(nlogn).
@junaidmahmud2894
@junaidmahmud2894 28 дней назад
Exactly. Based on that, if I consider the algorithm takes less space and less time, I would go for sorting. It will work well even after removing the constraints.
@hemanthhvv4296
@hemanthhvv4296 28 дней назад
I really liked the way, you explained about the need of those sort methods A.K.A Rant 😂
@karanmehta2890
@karanmehta2890 28 дней назад
When the n is small, nlogn and n tend to be the quite the same. That is why sorting is better in this case.
@chien-yuyeh9386
@chien-yuyeh9386 28 дней назад
Nice 🎉
@Pegasus02Kr
@Pegasus02Kr 28 дней назад
honestly can't say trying counting sort is meaningful in this problem. but it was a great example to show big-O is not always correct measure
@JamesBond-mq7pd
@JamesBond-mq7pd 28 дней назад
My solution seats = sorted(seats) students = sorted(students) res = 0 for i in range(len(students)): res += abs(seats[i] - students[i]) return res
@jparmar1
@jparmar1 28 дней назад
This question was so weirdly worded. Meanwhile a trivial solution is to find the difference between the sums of the arrays. It did solve 53 testcases for me 😅😂😂😂😂
@E1an9640
@E1an9640 28 дней назад
Big Fan of your work here but I have one suggestion if you could give a formal proof for how the solutions works for questions like these it wud be excellent I dont think most people dont cover it nonetheless it is quite important too.
@black_grey3226
@black_grey3226 28 дней назад
I just cam r to understand this question.
@vickyorg
@vickyorg 27 дней назад
Sort both array SUM += diff from i to n indices did the trick AM I WRONG FROM DOING LIKE THIS
@vickyorg
@vickyorg 27 дней назад
Commented by looking at the first half sorry !
@SantoshKumar2
@SantoshKumar2 27 дней назад
Seems like internship season started in leetcode. 😅
@olanrewajubakare3790
@olanrewajubakare3790 28 дней назад
Log100 is supposed to be 2 right?
@mohd.tabishkhan4868
@mohd.tabishkhan4868 28 дней назад
that is when the base is 10 but in computer science generally the base is taken as 2 because of binary, so log 100 base 2 will be 6.64385618…
@olanrewajubakare3790
@olanrewajubakare3790 28 дней назад
@@mohd.tabishkhan4868 You are absolutely right. Don't know why I thought this was actual math.
@sarathikumark
@sarathikumark 28 дней назад
Bro leetcode problem no 481 try
@mohammedansil2302
@mohammedansil2302 27 дней назад
never try to relate real-world problems with dsa
@sarathikumark
@sarathikumark 28 дней назад
Bro
@fancypants6062
@fancypants6062 28 дней назад
2:22 lmao erase that one real quick
@paulfunigga
@paulfunigga 27 дней назад
The solution is not clear or convincing
Далее
8 patterns to solve 80% Leetcode problems
7:30
Просмотров 233 тыс.
How I would learn Leetcode if I could start over
18:03
Просмотров 317 тыс.
Kevin Malone's Best Moments - The Office
11:22
Просмотров 2,4 млн
25 nooby Python habits you need to ditch
9:12
Просмотров 1,7 млн
Winning Google Kickstart Round A 2020 + Facecam
17:10
ПОКУПКА ТЕЛЕФОНА С АВИТО?🤭
1:00