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

  Рет қаралды 17,145

NeetCode

NeetCode

Күн бұрын

Пікірлер: 32
@Victor-hg6hk
@Victor-hg6hk 2 жыл бұрын
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!
@ChanChan-pg4wu
@ChanChan-pg4wu 2 жыл бұрын
It indeed has been a while! Glad to see you back! Always great explanation! This reminds me to revisit permutation & backtracking.
@AMAZINGGUY1113
@AMAZINGGUY1113 2 жыл бұрын
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 :)
@Mutual_Information
@Mutual_Information 2 жыл бұрын
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
@fatihorhan9355
@fatihorhan9355 2 жыл бұрын
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.)
@fatihorhan9355
@fatihorhan9355 2 жыл бұрын
Beats 85% of runtime and 94% of space in c++.
@allandogreat
@allandogreat 2 жыл бұрын
Yes, good one.
@pallav7041
@pallav7041 2 жыл бұрын
nice approach
@damirshakenov2198
@damirshakenov2198 2 жыл бұрын
Actually, bool is 1 byte (not bit), because the CPU can't address anything smaller than a byte.
@fatihorhan9355
@fatihorhan9355 2 жыл бұрын
@@damirshakenov2198 You're totally right. I forgot that almost all instruction architectures are designed so that smaller size CPUs can interact with is 1 byte. However, STL's boolean vector is designed to optimize for space.
@trollbaron1329
@trollbaron1329 2 жыл бұрын
Hi NeetCode, would you consider making a video on more advanced topics like string hashing or segment trees?
@numberonep5404
@numberonep5404 2 жыл бұрын
Short and to the point as usual! nice pb
@udayptp
@udayptp 2 жыл бұрын
This was as simple as tricky, loved your explanation
@VivekSingh-in6rq
@VivekSingh-in6rq 2 жыл бұрын
damn, i just got this challenge today and found ur video was released today too 😂😂
@jasonswift7468
@jasonswift7468 Жыл бұрын
We can add if ((s.length() - k + 1) * k < (1
@shantanukumar4081
@shantanukumar4081 2 жыл бұрын
Great Explanation !!!
@halahmilksheikh
@halahmilksheikh 2 жыл бұрын
I thought he went up to Google heaven and never returned
@NeetCode
@NeetCode 2 жыл бұрын
Lol good one
@halahmilksheikh
@halahmilksheikh 2 жыл бұрын
@@NeetCode For real though, I thought you retired this channel. I hope you continue it even if it's at a slower cadence (like 1 per week?)
@aishwaryaranghar3385
@aishwaryaranghar3385 2 жыл бұрын
great approach
@Malmidas
@Malmidas 2 жыл бұрын
Keep up the good work, really appreciated!
@shouryannikam3949
@shouryannikam3949 2 жыл бұрын
Is the neetcode 150 list definitive or do you plan on adding more problems to it?
@hilsCYBER
@hilsCYBER 2 жыл бұрын
Thanks man, great content as usual.
@nguyenquangduy910
@nguyenquangduy910 2 жыл бұрын
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
@minarefaat1573
@minarefaat1573 2 жыл бұрын
Hey man We miss you
@farzinhaddadpour7192
@farzinhaddadpour7192 Жыл бұрын
This is clever!
@pekarna
@pekarna 2 жыл бұрын
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.
@mohithadiyal6083
@mohithadiyal6083 2 жыл бұрын
Awesome 😁😁
@bh4541
@bh4541 2 жыл бұрын
why O(n*k) can someone explain for me ?: thank u
@osamaayman3765
@osamaayman3765 2 жыл бұрын
Because the for-loop loops over all the input string of length n and in each iteration we are creating a substring of length k (which takes linear time because it copies all chars to a new string). So, the overall time complexity is O(n*k).
@beebread._.m8
@beebread._.m8 2 жыл бұрын
saos
How I would learn Leetcode if I could start over
18:03
NeetCodeIO
Рет қаралды 579 М.
Making an Algorithm Faster
30:08
NeetCodeIO
Рет қаралды 112 М.
The selfish The Joker was taught a lesson by Officer Rabbit. #funny #supersiblings
00:12
Funny superhero siblings
Рет қаралды 10 МЛН
Which One Is The Best - From Small To Giant #katebrush #shorts
00:17
Big-O Notation - For Coding Interviews
20:38
NeetCode
Рет қаралды 486 М.
How to Solve ANY LeetCode Problem (Step-by-Step)
12:37
Codebagel
Рет қаралды 249 М.
I gave 127 interviews. Top 5 Algorithms they asked me.
8:36
Sahil & Sarra
Рет қаралды 659 М.
Maximum Performance of a Team - Leetcode 1383 - Python
14:53
NeetCode
Рет қаралды 30 М.
Remove K Digits - Leetcode 402 - Python
14:36
NeetCode
Рет қаралды 62 М.
Medium Google Coding Interview With Ben Awad
51:27
Clément Mihailescu
Рет қаралды 1,3 МЛН