Grumpy Bookstore Owner - Leetcode 1052 - Python

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


0:00 - Read the problem
0:30 - Drawing Explanation
4:40 - Coding Explanation

leetcode 1052

#neetcode #leetcode #python
Рекомендации по теме
Комментарии
Автор

sorry about missing the last couple problems. whenever i come back to an easyish question, i feel bad cause people are gonna think im dodging the hard ones

end of the month is when it gets tough so lets 😤😤

NeetCodeIO
Автор

we needed you yesterday and the day before

TheWhiteFlame
Автор

One optimization can be - to do the logic about recalculating max window inside if grumpy[r] - because we only need to recalculate if we find next grumpy == 1. So lines 12-16 - can be in if section. Instead of if we have to use while, but we will do less max comparisons for sure, because we will have amount of max comparisons equals to amount of grumpy days, instead of length of the array.

MykolaPavluchynskyi
Автор

"We are bigger than everybody else" lol

bhuvan
Автор

This leetcode question would be a good plot for an anime

laceycodetime
Автор

This is what I came up with.
class Solution:
def maxSatisfied(self, customers: List[int], grumpy: List[int], minutes: int) -> int:
left = 0
right = minutes - 1
candidate = 0
for i in range(len(customers)):
candidate += customers[i]*abs(grumpy[i] - 1)
for i in range(left, right+1):
candidate += customers[i]*grumpy[i]
ans = candidate
while right < len(customers) - 1:
candidate +=
candidate -= customers[left]*grumpy[left]
if candidate > ans:
ans = candidate
left += 1
right += 1
return ans

patb
Автор

honestly not even reading the description is reasonable they need to hire someone specifically for these problem descriptions

pastori
Автор

You post videos at the time I solve daily leetcode problems :) If I get stuck, it's a lot of help. Thanks and keep posting!

DebopriyoBasu
Автор

can you please upload videos of leetcode weekly and biweekly also

innovativesmartlearning
Автор

we needed you for yesterday and day before yesterday problem sir

harshithd
Автор

what if value 5 from ex 1 was at index 1, then a/c to solution left will removed leaving us with not max customers. Can Someone confirm or correct?

prajyot
Автор

First! Thank you very much Sir for all your help.

benedictaamoah
Автор

Can you share the solution for 1552. Magnetic Force Between Two Balls

xhero
Автор

bro literally missing you few days .... put videos daily

mohammedsuhail.s
Автор

I solved it using Prefix sum + 0/1 Knapsack, but runtime was poor 😐

mohaimenchowdhury
Автор

where were you yester day brother, I needed you 😐😐

M_O-
Автор

Q) 1156. Swap For Longest Repeated Character Substring .

Can this be related to your earlier solution of 424. Longest Repeating Character Replacement ?

anshumansinha
Автор

Neetcode went on vacation when I needed him the most🥲

RajdeepJadeja