Maximum Number of Balloons - Leetcode 1189 - Python

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


0:00 - Read the problem
1:05 - Drawing Explanation
4:08 - Coding Explanation

leetcode 1189

#tesla #interview #python
Disclosure: Some of the links above may be affiliate links, from which I may earn a small commission.
Рекомендации по теме
Комментарии
Автор

Thank you so much for these videos man, I passed my FANG interview watching these.

joechen
Автор

Even the "easy" ones take a little while for me to do on my own, but at least theyre solvable for me 😂

catharsis
Автор

The space complexity is o(1) since we would at most have 26 + 26 keys in our map representing the alphabet aZ. It will not grow linearly

subhanc
Автор

Thanks for keeping it up along with a full time job dude. Really appreciate it!

harigovind
Автор

For someone Who wanna do it in a hardcode way:
hashmap = {}
balloon = {}
example = "balloon"

for n in text:
hashmap[n] = 1 + hashmap.get(n, 0)

for x in example:
balloon[x] = 1 + balloon.get(x, 0)

res = len(text)
for c in balloon:
res = min(res, hashmap[c] // balloon[c] if c in hashmap else 0)
return res

weiyaoli
Автор

I feel like my solution is a bit dumb but here ... :

def MNOB(n:str):
Balloons =['b', 'a', 'l', 'o', 'n']
counter = 0
for c in n :
if c in Balloons:
counter+=1
return counter // 7

itsJustJayMusic
Автор

Thank you so much . Excellent explanation. Before I watched the solution, I tried to figure that out on my own. My idea is to divide the values the two dictionaries and then take the min value from the resulting dictionary, so I guess I end up with a poorer time complexity ( O(n) for dividing the values and O(n) (at most) when I am searching the minimum value ) .

gianniprocida
Автор

i see improvements every day from watching your videos

johnsoto
Автор

Why memory has to be O(n) ? Can't it be O(1), as you are just storing counts for {b, a, l, o, n} i.e. a 5 size array ?

mahim_mahbub
Автор

Please make a playlist on DSA first concept, algorithm then question so beginners can also get familiar.
And also there isn't any good DSA playlist in python on YouTube.

Nick-uobi
Автор

I was literally looking for this problem in your channel a week ago. Glad you made it :D

dmytrokavetskyy
Автор

If the input was the max ratio is 3, min ratio is 2, so the answer would be 2. Our default should be greater than the min ratio, so 20 works here. The most max value of min ratio can never be greater than the length of the string, hence it is a good default

dheepthaaanand
Автор

These videos really helps me, thanks.

jayeshkaushik
Автор

is it just for the thumbnail or is this really a tesla interview question?

Ibrahim-K-Issa
Автор

This was what I came up with:
def bla(text):
word = "balloon"
hash_map = {}
for i in text:
if i in word and i not in hash_map:
if i == "l" or i == "o":
hash_map[i] = text.count(i) // 2
else:
hash_map[i] = text.count(i)
if len(hash_map.keys()) == len(set(word)):
return min(hash_map.values())
else:
return 0

chamikaonyt
Автор

what do you use for drawing on the screen like that?

davyzou
Автор

Thanks for video.
Do you know a solution without using hash?

vladimireliseev
Автор

Tesla uses leetCode for interview?? 😍 Man I'm in!!!

cutiex
Автор

In chemistry, the letter that would be the bottleneck we would call the limiting reagent.

joef
Автор

muchas gracias por el video neetcode! aunque hable espanol se entiende perfectamente!

leetcodeespanol
visit shbcf.ru