Пікірлер
@europana7
@europana7 Ай бұрын
Resiliency can already be done by AWS identical Lamda in multi regions and Elasticache. … and Azure prob has an equivalent.
@sudhakardhayalan8874
@sudhakardhayalan8874 Ай бұрын
This solution is failing for the edge case that I've created - [3, 2, 3, 1, 1, 1] For this, provided solution returns undefined. Need slight improvement in condition to fix this. Below one is working fine. let majorityElement = function (nums) { const ht = {}; for (const num of nums) { ht[num] = ht[num] + 1 || 1; } const isNumsOfEvenLength = nums.length % 2 === 0; const median = Math.floor(nums.length / 2); for (const key in ht) { if (isNumsOfEvenLength && ht[key] >= median) { return key; } else if (!isNumsOfEvenLength && ht[key] > median) { return key; } } };
@sudhakardhayalan8874
@sudhakardhayalan8874 Ай бұрын
Or you can simply use the below solution let majorityElement = function (nums) { const ht = {}; for (const num of nums) { ht[num] = ht[num] + 1 || 1; } const median = Math.ceil(nums.length / 2); for (const key in ht) { if (ht[key] >= median) { return key; } } }; console.log(majorityElement([3, 2, 3])); // 3 console.log(majorityElement([3, 2, 3, 1, 1, 1])); // 1
@Nimzo003
@Nimzo003 Ай бұрын
Best system design video I've ever seen. I'd hire you on the spot.
@chronoel
@chronoel 3 ай бұрын
is there a way to replace zookeeper? why not just store a record of ranges used in a db or redis cache. since the operation of generating a new range happens once in a while. specifically, when a new server is being initialized and another when the range of a server rans out and need to fetch a new one
@vandal144
@vandal144 3 ай бұрын
GOAT tinyURL vid
@FlashFreelancers
@FlashFreelancers 4 ай бұрын
How do we identify the same long url which got converted to tiny url already ? Since we are using counter each time it will get a new tiny url no ?
@deep8843
@deep8843 5 ай бұрын
Really helpful!
@Mr.Zeus11
@Mr.Zeus11 6 ай бұрын
var plusOne = (digits) => (BigInt(digits.join('')) + BigInt(1)).toString().split('');
@JeanNascimentosuissa
@JeanNascimentosuissa 6 ай бұрын
thanks man!
@nishantscollectibles
@nishantscollectibles 7 ай бұрын
By far the simplest and easiest solution that I've seen. Thanks!
@tenaciousbali
@tenaciousbali 7 ай бұрын
Comprehensive explanation and good pointers. Loved this!!!
@umeshhbhat
@umeshhbhat 7 ай бұрын
maine be yahi bataya tha
@brownbearnishant
@brownbearnishant 7 ай бұрын
do more videos brother
@michelmdf
@michelmdf 7 ай бұрын
Why not just rely on a database cluster to generate a sequencial numeric id , and just persist the id and the long url ? So when a request comes in, we convert from base62 to decimal and find the record in the db. What is wrong of this idea ?
@suvajitchakrabarty
@suvajitchakrabarty 7 ай бұрын
If in case anyone is interested, the O(1) space complexity requires some bit manipulation. Essentially if you XOR a number with itself, it returns zero, and if you XOR a number with zero, it returns the number itself. So if you had the following numbers in the list - 3, 3, 2, the XOR between 3 and 3 would return 0, and then XORing 0 with 2 would return 2. Hence if you did a XOR for all numbers in a list which contains 2 of each numbers except for the one number, then you'd get back the number which occurs once. The code is pretty straightforward since you only need to do a XOR for every number, and return the result. Code in Javascript - var singleNumber = function(nums) { let res = nums[0]; for (let i = 1; i<nums.length; i++) { res = res ^ nums[i]; } return res; };
@fannyzheng1077
@fannyzheng1077 8 ай бұрын
Thank you
@seeboonsoo
@seeboonsoo 8 ай бұрын
No one explain better than this guy!!
@DocOmally101
@DocOmally101 10 ай бұрын
Could you do more system design videos? This was super insightful and really well explained. Any of these would be so helpful to understand in your delivery and explanatory sttyle: Google Docs Twitter LeetCode API Rate Limiter BookMyShow Chat Application E-Commerce Portal Splitwise Vending Machine Google Autosuggest Uber Parking Lot Stock Exchange Logging System Authentication Service Either way, thanks for the video man!
@MayankMakwana-n4d
@MayankMakwana-n4d 10 ай бұрын
not even working
@9939364566
@9939364566 10 ай бұрын
Amazing way of explanation.... I watched many YT videos and they all confused me. You nailed it ✌️ Tysm
@vaibhav_cs
@vaibhav_cs 11 ай бұрын
Excellent approach and proper delivery of content !
@AnangPhatak
@AnangPhatak 11 ай бұрын
Please make more videos on systems design. The content here is presented succinctly with non-complex simple diagrams and licid explanation.
@chirut4327
@chirut4327 11 ай бұрын
base62 encoding can result in a string of any length. And we are not supposed to take first 7 chars to avoid collision. So that means we take what ever output we get from base64. This is what I want to hear from these videos, but believe me none of them emphasize on this. They just say blabla and use base62.
@boyangzheng269
@boyangzheng269 7 ай бұрын
We are not encoding the original URL because as u said it would result in a string of any length. Instead we are encoding the numbers (0 - 3.5 trillion) which would not exceed 7 chars because 62^7 > 3.5 trillion.
@ayushgupta7731
@ayushgupta7731 Жыл бұрын
great explaination.
@chetankagyan
@chetankagyan Жыл бұрын
We can improve it using Boyer-Moore Majority Voting Algorithm in constant space.
@rohitdeepati7742
@rohitdeepati7742 Жыл бұрын
Thanks bro
@BestURLShortenerBioPageQRCode
@BestURLShortenerBioPageQRCode Жыл бұрын
Thank you for sharing this much of information.👍👍
@agyemangchristopher5248
@agyemangchristopher5248 Жыл бұрын
please give further explanation
@rohinirenduchintala
@rohinirenduchintala Жыл бұрын
The best comprehensive tinyURL video for system design i've seen so far. Please make more!
@mohammedunais2494
@mohammedunais2494 Жыл бұрын
how will handle [1,9,0] this input??
@DK-ox7ze
@DK-ox7ze Жыл бұрын
If we add 10-15 bits at the end of counter number then it will increase the base62 output size and exceed the 7 character limit. So can you clarify how that addition of random string works?
@jinushaun
@jinushaun Жыл бұрын
TLDR: md5(“123”) vs md5(“123,xyz”) The original solution hashed the returned counter value, which is a simple increasing number. The resulting hash is then base62 encoded. The new solution takes the counter number and appends some extra characters at the end. This new string is then hashed and base62 encoded. In this way, the string sent into hash is not guessable. This works because the numeric portion is still guaranteed not to collide.
@DK-ox7ze
@DK-ox7ze Жыл бұрын
But in this new solution also, there is a chance of collision because we are hashing the counter+random_chars and limiting the hash to a short length.
@chirut4327
@chirut4327 11 ай бұрын
Even without appending extra digits, base62 does not guarantees 7 chars. That simply means, we are not confining ourselves to 7 chars. We probably need to tell the interviewer that we would get as small as possible hash but no guarantees. This is a possible tradeoff to avoid collision.
@caiocutrim3596
@caiocutrim3596 Жыл бұрын
space complexity is O(N)
@abhishekkeshri3974
@abhishekkeshri3974 Жыл бұрын
bool isPowerOfThree(int n) { if(n<=0)return false; if(n==1)return true; return (floor(log10(n)/log10(3))==log10(n)/log10(3)); } O(1)
@jsfortechies-zh3br
@jsfortechies-zh3br Жыл бұрын
Good work
@somebody-17546
@somebody-17546 Жыл бұрын
You must implement a solution with a linear runtime complexity and use only constant extra space.
@hamzasanwar
@hamzasanwar Жыл бұрын
Why base 62 not base 64
@abjbreal
@abjbreal 5 ай бұрын
52 alphabets and 10 digits = 62 total characters
@mohamedelidrissi810
@mohamedelidrissi810 Жыл бұрын
For caching, will it be better to have some kind of background job that populates the cache with the most popular URLs from the database? Else if you're always adding a URL to the cache, then it's no longer just the popular URLs but all of them (or at least the capacity of the cache).
@RandomShowerThoughts
@RandomShowerThoughts Жыл бұрын
this was very good, clean and concise. Really like this video, especially the logic as to not pick sql
@BabeCrs
@BabeCrs Жыл бұрын
it asks it to be in O(1) space complexity. How would you adapt this for that
@garrettsapps2526
@garrettsapps2526 Жыл бұрын
Great video! But perhaps a simpler solution might look like this: var moveZeroes = function(nums) { for(let i = 0; i < nums.length; i++){ if(nums[i] === 0){ nums[nums.length - 1] = nums.splice(i,1) } } }; This will only require one loop. If anyone can see any issues with this solution at scale please let me know.
@wingdphoto
@wingdphoto Жыл бұрын
Follow up: Could you solve it without loops/recursion?
@vonderklaas
@vonderklaas Жыл бұрын
Hello, please continue your videos!
@Prod3t
@Prod3t Жыл бұрын
W coder 🤷🏼‍♂️
@talktovideos4349
@talktovideos4349 Жыл бұрын
Thanks a lot for making this video
@parkerhemming9388
@parkerhemming9388 Жыл бұрын
Couldn’t you just join the array together, wrapped in Number function, add 1, then return split
@lunaretic3
@lunaretic3 Жыл бұрын
I did that and it passed most cases, but when it came to a really long array of length >14 or 15, for some reason it changed the last 4 numbers in the array to zero instead of what they actually were.
@ryuaan
@ryuaan Жыл бұрын
Good explanation. Was 75% there w/ this one but needed some help
@yehsunkang5150
@yehsunkang5150 Жыл бұрын
Really easy to understand the recursive nature and also binary data structure!
@samankayhanian3888
@samankayhanian3888 2 жыл бұрын
Good Job
@pineappleapplepens
@pineappleapplepens 2 жыл бұрын
damn this tutorial was optimal af
@kanyshaiosmonova2008
@kanyshaiosmonova2008 2 жыл бұрын
thank you!
@zarbioromulood8854
@zarbioromulood8854 2 жыл бұрын
Please get back!