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

  Рет қаралды 7,634

NeetCodeIO

NeetCodeIO

Күн бұрын

🚀 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

Пікірлер: 44
@yelnil
@yelnil Ай бұрын
The way this question was worded made it hard to understand.
@asagiai4965
@asagiai4965 Ай бұрын
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 Ай бұрын
sounds like a skill issue to me
@whyredvince
@whyredvince Ай бұрын
@@RTZemun Yeah on part of the person who wrote this question
@GPT-X938
@GPT-X938 Ай бұрын
@@RTZemun shoo fly
@RTZemun
@RTZemun Ай бұрын
@@GPT-X938 zap zap can win
@adama7752
@adama7752 Ай бұрын
Man finds counting sort hammer. Processed to see counting sort nails.
@AnordinaryMan007
@AnordinaryMan007 Ай бұрын
Thanks for the different approaches.
@jessicakoch2331
@jessicakoch2331 Ай бұрын
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
@sandro-of9fq
@sandro-of9fq Ай бұрын
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!
@kraav4ikk6
@kraav4ikk6 Ай бұрын
thank you for different solutions!
@kavyanshpandey3823
@kavyanshpandey3823 Ай бұрын
1. Sort both array. 2. Add abs different of same index value.
@kavyanshpandey3823
@kavyanshpandey3823 Ай бұрын
Following you since last 4 month with 95 percent consistency
@asagiai4965
@asagiai4965 Ай бұрын
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?
@jotrades26
@jotrades26 Ай бұрын
This week , Leetcode has made us to count numbers 👏👏
@hemanthhvv4296
@hemanthhvv4296 Ай бұрын
I really liked the way, you explained about the need of those sort methods A.K.A Rant 😂
@freecourseplatformenglish2829
@freecourseplatformenglish2829 Ай бұрын
considering array is small sorting is sweet and simple approach. Counting sort can be discussed if interviewer ask for more optimised approach.
@John-ht4xv
@John-ht4xv Ай бұрын
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
@junaidmahmud2894
@junaidmahmud2894 Ай бұрын
If you consider space complexity, nlogn solution would be preferable
@sophiophile
@sophiophile Ай бұрын
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 Ай бұрын
Space is not free for sort in python. It's omega(nlogn).
@junaidmahmud2894
@junaidmahmud2894 Ай бұрын
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.
@chien-yuyeh9386
@chien-yuyeh9386 Ай бұрын
Nice 🎉
@pastori2672
@pastori2672 Ай бұрын
yeah i came up with both solutions and was confused why the regular sorting was consistently faster then couting sort
@shraveenb.s3983
@shraveenb.s3983 4 күн бұрын
if logn is of base 10 then any n below 10 or below 100 would have a significantly lower value than n + 100. After 100 nlogn will start doubling. So for O(n + 300) < (300 log 300)
@JamesBond-mq7pd
@JamesBond-mq7pd Ай бұрын
My solution seats = sorted(seats) students = sorted(students) res = 0 for i in range(len(students)): res += abs(seats[i] - students[i]) return res
@Pegasus02Kr
@Pegasus02Kr Ай бұрын
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
@E1an9640
@E1an9640 Ай бұрын
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.
@karanmehta2890
@karanmehta2890 Ай бұрын
When the n is small, nlogn and n tend to be the quite the same. That is why sorting is better in this case.
@black_grey3226
@black_grey3226 Ай бұрын
I just cam r to understand this question.
@jparmar1
@jparmar1 Ай бұрын
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 😅😂😂😂😂
@vickyorg
@vickyorg Ай бұрын
Sort both array SUM += diff from i to n indices did the trick AM I WRONG FROM DOING LIKE THIS
@vickyorg
@vickyorg Ай бұрын
Commented by looking at the first half sorry !
@SantoshKumar2
@SantoshKumar2 Ай бұрын
Seems like internship season started in leetcode. 😅
@olanrewajubakare3790
@olanrewajubakare3790 Ай бұрын
Log100 is supposed to be 2 right?
@mohd.tabishkhan4868
@mohd.tabishkhan4868 Ай бұрын
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 Ай бұрын
@@mohd.tabishkhan4868 You are absolutely right. Don't know why I thought this was actual math.
@sarathikumark
@sarathikumark Ай бұрын
Bro leetcode problem no 481 try
@mohammedansil2302
@mohammedansil2302 Ай бұрын
never try to relate real-world problems with dsa
@fancypants6062
@fancypants6062 Ай бұрын
2:22 lmao erase that one real quick
@sarathikumark
@sarathikumark Ай бұрын
Bro
@paulfunigga
@paulfunigga Ай бұрын
The solution is not clear or convincing
Water Bottles - Leetcode 1518 - Python
8:13
NeetCodeIO
Рет қаралды 9 М.
Creators of Devin AI are genius competitive programmers?
20:23
NeetCodeIO
Рет қаралды 163 М.
Inside Out Babies (Inside Out Animation)
00:21
FASH
Рет қаралды 22 МЛН
How Many Balloons Does It Take To Fly?
00:18
MrBeast
Рет қаралды 202 МЛН
Reveal Cards In Increasing Order - Leetcode 950 - Python
11:14
NeetCodeIO
Рет қаралды 15 М.
The Number of Beautiful Subsets - Leetcode 2597 - Python
32:34
NeetCodeIO
Рет қаралды 10 М.
How I Approach a New Leetcode Problem (live problem solving)
25:31
Understanding B-Trees: The Data Structure Behind Modern Databases
12:39
8 patterns to solve 80% Leetcode problems
7:30
Sahil & Sarra
Рет қаралды 284 М.
How I would learn Leetcode if I could start over
18:03
NeetCodeIO
Рет қаралды 394 М.
Xiaomi SU-7 Max 2024 - Самый быстрый мобильник
32:11
Клубный сервис
Рет қаралды 540 М.
Сколько реально стоит ПК Величайшего?
0:37
КРУТОЙ ТЕЛЕФОН
0:16
KINO KAIF
Рет қаралды 6 МЛН
Todos os modelos de smartphone
0:20
Spider Slack
Рет қаралды 64 МЛН