Check if a String Contains all Binary Codes of Size K - Leetcode 1461 - Python

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


0:00 - Read the problem
0:40 - Drawing Explanation
3:57 - Coding Explanation

leetcode 1461

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

Man, thank you so much. I just got my dream Google offer and I would've never ever gotten it without your videos. Thank you so much and I'll be joining you in the Seattle office this fall!

Victor-hghk
Автор

Interesting to think that there is a subset of the183K subscribers who passed an interview and accepted the job because of this channel. Very strong impact

Mutual_Information
Автор

Thought you'd stop after your hard work paid off. Good to see that you're still at it! Keep it up man, it's greatly appreciated :)

AMAZINGGUY
Автор

It indeed has been a while! Glad to see you back! Always great explanation! This reminds me to revisit permutation & backtracking.

ChanChan-pgwu
Автор

Short and to the point as usual! nice pb

numberonep
Автор

I'd suggest allocating a boolean array space of size 2^k and changing each corresponding place of the array with the given substring. This allows us to avoid computing the hash function and saves a lot of space since every bool is only 1 bit. (I implemented my solution in c++ and am unsure how it'd go in python 3.)

fatihorhan
Автор

This was as simple as tricky, loved your explanation

udayptp
Автор

We can add if ((s.length() - k + 1) * k < (1 << k)) return false for pruning the invalid data to make the algorithm faster.

jasonswift
Автор

damn, i just got this challenge today and found ur video was released today too 😂😂

VivekSingh-inrq
Автор

I thought he went up to Google heaven and never returned

halahmilksheikh
Автор

Hi NeetCode, would you consider making a video on more advanced topics like string hashing or segment trees?

trollbaron
Автор

Keep up the good work, really appreciated!

Malmidas
Автор

Hi, hashcode is not too efficient here. Since we have a continuous sequence of integers to search for, why not have an array, 0 to 2^k-1?
This leads to a quite efficient code :)

Runtime: 555 ms, faster than 100.00% of Kotlin online submissions for Check If a String Contains All Binary Codes of Size K.
Memory Usage: 68.4 MB, less than 100.00% of Kotlin online submissions for Check If a String Contains All Binary Codes of Size K.

pekarna
Автор

Is the neetcode 150 list definitive or do you plan on adding more problems to it?

shouryannikam
Автор

hey Neet, your solution is brilliant but what if (s) dont have enough sample to return the number of solution we are seeking. E.g s="0110" k=2

nguyenquangduy
Автор

why O(n*k) can someone explain for me ?: thank u

bh