@@jesse2667 Okay, then it should probably be: public static byte getMedian(InputStream stream) { int length = stream.available(); byte[] array = new byte[length]; stream.read(array); stream.close(); Arrays.sort(array); return array[length / 2]; }
@@SourthernerPilgrim i thought it was, a doctor with specialisation "specifically neurosurgeon", a lawyer at a big firm or an engineer in a big company "specifically microsoft or tesla"
have experience in .Net C#, ASP MVC, WebForm, Xamarin Maui is a must. Java and Phyton is a must. Having deep knowledge in PHP, Javascript, Jquery, Typescript and Angular is a must. C/C++ and Assembly atleast intermediete to advance level (proved with international certificate) Having good knowledge di ABAP and SAP 4/Hana Framework. Having good knowledge in DevOps Azure, Jenkins and Github CICD.
Store the stream elements in an AVL-Tree. The median is at all times - root if balance = 0 - (root+right)/2 at balance +1 - (root+left)/2 at balance -1 Edit: this allows you to find other percentiles as well btw. (25th, 12.5th, 6.25th, ... and any combination of the lot: 75th, 81.25th, ...)
Okay your solution boils down to: 1. Store data in an tree 2. Always keep the sorting up 3. Calculate the median. Why is that not optimal? A good balanced tree implementation can rely on an array with arr[0] as the root, arr[1] is the left tree and arr[2] is the right tree. If not perfectly balanced arr[n] can be null, infinity, undefined. Using a node based approach is slower because of cache misses. Now that representation is completely equal to just storing the numbers in a sorted order, with extra steps. Keeping the array always sorted is in general slower than sorting it once at the end. And for this problem we are not asked to find any other quantile but the 0.5 so my proposal. Store the data in an array. Use a random pivot and sort everything less or greater like in quicksort. Repeat until you found the median element(s). This way you can find your value without even sorting all the numbers. For example if you have an array of size n and by chance pick the pivot that 60% of values land on the left side, you could in theory forget about 40% of your numbers. Because they can not be part of the median. The benefit you could store this somewhat sorted data and come back to it in the same way, to find your 0.25 quantil and so on. TLDR: You dont need to do a full balanced tree, when it is enough to only sort it partially. Only do what is asked not more. Only if possible keep the option for more utility.
@@Schnorzel1337 I don't understand what you do before you have all the data. I understand you want to sort the data only at the end. While you are still receiving the data, you are only doing one operation which is sorting the data into one of two lists depending on if it is greater or less than the pivot? Am I correct?
I swear i had an interview like this. That whole thing lasted for about 10 mins. The interviewer asked me my name and wasn't even looking at me, hell he was on Instagram for the entire time. At the end he just said ok, you can leave now. God i wanted to punch him but i just can't. Crazy ass dude, and he wasn't a random dude he was from a MNC.
It is very sad feeling when you meet someone who pretend to be above of your level and treat you shit especially in our specialization. I feel you bro .. Hope you got better work than working for that idiot.
Don't worry. If you know your shit, and you know you aren't shit, then you will be fine. Don't accept this kind of behaviour from companies, that's the golden rule. You're interviewing them as they are interviewing you. Sure the first job can be a mess to get, but once you have even a modicum of experience, you're good. Ultimately the world needs more developers than the other way around.
Don't worry, a guy tells him your code is slow, ask him to specify compiler and kernel version. If he does, tell him you're not familar with those and you'll focus on process - you'd seek platform specific efficencies once those elements are specified. Then ignore any offers - your health isn't worth it.
I went to an interview were the interviewer was like this. Apparently it was an act to put the applicants under pressure, but they legit didn't know what they where talking about and wanted the database to be in the cloud, but also hosted on site for the example question. I ignored the call back for the second interview.
These companies acting like your boyfriend/girlfriend toying with your feeling to test. Jesus fuck, they're running a business, not a toxic relationship xD
Holy shit I got flashbacks from when I was applying for an internship to this startup. And damn I applied so I could learn to webdev, never realized I gotta study everything on my own in three days in order to deliver on a requirement to be accepted.
A good general purpose method is to use two ordered containers (e,g. heaps), min and max, and bin incoming data into one or the other depending on whether it's greater or less than the head or tail elements. This has memory limitations, though.
why do you need 2 if you need them ordered anyway? you seem to mean 2 priority heaps (only partially ordered and thus faster than fully ordered grandma) of equal sizes (+-1) - you need to not only place the element into the right heap, but also rebalance them as needed.
It is like a standard stuff for swe. There are a lot of fields in computer science and it is really hard to find someone who worked in the field you are going to fill in your company. But it is very easy for an engineer to adapt a new tech to work in the position which he has never worked before. How can you ask questions that he have never worked before, right? Why don't we ask questions on what he have done? Yes we do but it is not enough to conclude a swe if he good/bad for the position (he can lie). So algorithms/system design/data structure are the standard stuff for every swe to should know.
the first idea was pretty good. I'd make an array of all Inputs, divide the number of items by 2, subtract 0.5 if it's not natural and then output the item on that place in the array (you'd have to subtract 1 again if the language starts counting array items with spot 0) pretty sure that future me will want to slap me cuz there's an easier solution when he reads this :P
The median... if creating an array solution.. you would need to pop then sort functions in the class for every data point right... or half as the other dude mentioned...
@@PavloPravdiukovit is not sorted, so you have to sort it fitst to find the median and if you receive a stream of 2 100 2 100 2 100, then your "half" will be either 2 2 2 or 100 100 100 and the median is not guaranteed to be true. You need to use a set with binary search insert to read + sort or a heap with median on the top with log N insert
Anyone who wants answer. Use 2 heaps 1st max heap and second min. Insert values from the data stream keeping in mind the sizes of heaps. Case1. If odd no of elemenrs exist within both heaps get the root from the heap with more elements. Case2. If even no. of elements exist, take both the roots and compute average of them as result. Another better way : median of medians..
The truth of Asian interview. I had seen many difficult while meeting. They asked me to fill in 25 Mc and 1 lq within 20 minutes. Actually, my university gives me 40 minutes to complete same task. It burns my brain. I can't see any respect from Asian employers
Full video on Joma Tech channel
Bit late innit?
Bro, I got you, it's:
public static byte getMedian(InputStream stream) {
int length = stream.available();
byte[] array = new byte[length];
stream.read(array);
stream.close();
return array[length / 2];
}
@@shadowofheaven3279 looks like middle, but not median.
@@jesse2667 Okay, then it should probably be:
public static byte getMedian(InputStream stream) {
int length = stream.available();
byte[] array = new byte[length];
stream.read(array);
stream.close();
Arrays.sort(array);
return array[length / 2];
}
@@shadowofheaven3279 Okay then. 🤔Can you make it O(log(n)) for reading a new value and recalculating, instead of O(N log(N))
"My grandmother run faster than your code" 🤣
Ha Ha Aha
Congratulations! You quoted the funny part of the video! You are so original and funny!
@@classicalsheetmusic1986 just like how nice you are
I, a Python developer, can relate
EMOTIONAL DAMAGE!!
"It was ok meeting you"
Gotta try that sometime
Hahaha loved that one too
That one got me!
This line is the definition of a paradox: it's stone cold, but it burns like hell.
Hurtful 😂
@@B3RyL Exactly, It's spelled and sounds like a compliment, but it hurts.
"It was okay meeting you." has got to be one of the coldest lines ever uttered
The disrespect is crazy
I'll start using this phrase in my interviews!
My Singaporean interviewer really said this and said bye and cut me off didn't even smile. At Cisco. That was cold. Forgot her name though.
“It was ok meeting you” is such a calm, passive aggressive yet semi-personal thing to say that it’s more emotionally damaging than an outright insult
Right
emotional damage
Plot twist: He is his son.
Yeah I was waiting for a “cya…dad” moment
Thieeeef
The secretary, now we are full circle
@@JoeyGirardin same 🤣🤣
I was waiting for that reveal
"disappointment just like my son"
🤣🤣🤣
Really asian parent 🤣
me 😔
well in asian here u can pick ur class,,
a doctor, or a disappointment son
@@SourthernerPilgrim i thought it was, a doctor with specialisation "specifically neurosurgeon", a lawyer at a big firm or an engineer in a big company "specifically microsoft or tesla"
@@TheRash_rv thats for moderon family, for the traiditional one are a doctor or a disappointment
@@SourthernerPilgrim not a high ranking official Or ruin family honor with high amount of disapointment and compared to sibling?
Startups are like:"
-10+ years of coding as a full stack dev necessary
-young and dynamic
-wants to work for a penny an hour"
And here I was reading it like minus 10 plus year, minus young, minus wants 😂😂😂
have experience in .Net C#, ASP MVC, WebForm, Xamarin Maui is a must. Java and Phyton is a must. Having deep knowledge in PHP, Javascript, Jquery, Typescript and Angular is a must.
C/C++ and Assembly atleast intermediete to advance level (proved with international certificate)
Having good knowledge di ABAP and SAP 4/Hana Framework.
Having good knowledge in DevOps Azure, Jenkins and Github CICD.
"It was okay meeting you" would shred my self-esteem like nothing else.
I’m saying
Emotional damage.
Why your text can make sound?
@@keikeiso2217 it would be better like this.. emoootional daamage
Haiyaaaa! 🤣
Disappointment
damage Emotional
" it was okey meeting you" 😂
Imma use this phrase from now on
Right in the feels 😭👌
Emotional daamage!
@@minhaj_Ratul was about to comment that 😂
Yeah dude we all watched the video
"You eat too much hash brown, your brain turning to potato" 🤣🤣🤣🤣🤣🤣🤣🤣🤣🤣🤣🤣
🤣🤣🤣🤣
How the heck did I have to scroll so far down to find this comment!! What a legendary insult! I get that the rest of it is gold too but damn! 🤣
Store the stream elements in an AVL-Tree. The median is at all times
- root if balance = 0
- (root+right)/2 at balance +1
- (root+left)/2 at balance -1
Edit: this allows you to find other percentiles as well btw. (25th, 12.5th, 6.25th, ... and any combination of the lot: 75th, 81.25th, ...)
Was looking for a comment like this
Better yet, we can use two heaps, easier to balance
Okay your solution boils down to:
1. Store data in an tree
2. Always keep the sorting up
3. Calculate the median.
Why is that not optimal?
A good balanced tree implementation can rely on an array with arr[0] as the root, arr[1] is the left tree and arr[2] is the right tree. If not perfectly balanced arr[n] can be null, infinity, undefined. Using a node based approach is slower because of cache misses.
Now that representation is completely equal to just storing the numbers in a sorted order, with extra steps.
Keeping the array always sorted is in general slower than sorting it once at the end.
And for this problem we are not asked to find any other quantile but the 0.5 so my proposal.
Store the data in an array. Use a random pivot and sort everything less or greater like in quicksort. Repeat until you found the median element(s). This way you can find your value without even sorting all the numbers.
For example if you have an array of size n and by chance pick the pivot that 60% of values land on the left side, you could in theory forget about 40% of your numbers. Because they can not be part of the median.
The benefit you could store this somewhat sorted data and come back to it in the same way, to find your 0.25 quantil and so on.
TLDR: You dont need to do a full balanced tree, when it is enough to only sort it partially. Only do what is asked not more. Only if possible keep the option for more utility.
@@Schnorzel1337 I don't understand what you do before you have all the data. I understand you want to sort the data only at the end. While you are still receiving the data, you are only doing one operation which is sorting the data into one of two lists depending on if it is greater or less than the pivot? Am I correct?
@@Schnorzel1337 ahh so unfortunate. I really thought you might be saying something interesting, now I see it was just words
“It was *OKAY* meeting you” 😂
😭😭😭😭
😂😂😂😂🤣🤣🤣
God bless you bro 🤣😂
"my grandmother run faster than your code"
*EmOtiOnaL DaMaGe*
"My grandma run faster than your code."EMOTIONAL DAMAGE 😭🤣🤣
I swear i had an interview like this. That whole thing lasted for about 10 mins. The interviewer asked me my name and wasn't even looking at me, hell he was on Instagram for the entire time. At the end he just said ok, you can leave now. God i wanted to punch him but i just can't. Crazy ass dude, and he wasn't a random dude he was from a MNC.
corporate dev are assholes always,
should just walk out or end call, and say you have better interviews to attend
It is very sad feeling when you meet someone who pretend to be above of your level and treat you shit especially in our specialization.
I feel you bro .. Hope you got better work than working for that idiot.
Dodged a bullet. If they treat you like that in an interview, it'll be worse once they think they own you. Consider yourself lucky
What's MNC?
"The perfect cross over doesn't exist"
*uploads this video
I am learning programming. This gave me anxiety.
Then get up and "do" more coding.
Don't worry.
If you know your shit, and you know you aren't shit, then you will be fine.
Don't accept this kind of behaviour from companies, that's the golden rule. You're interviewing them as they are interviewing you.
Sure the first job can be a mess to get, but once you have even a modicum of experience, you're good.
Ultimately the world needs more developers than the other way around.
Don't worry, a guy tells him your code is slow, ask him to specify compiler and kernel version. If he does, tell him you're not familar with those and you'll focus on process - you'd seek platform specific efficencies once those elements are specified.
Then ignore any offers - your health isn't worth it.
"Good luck with your other interviews" now that some positive comment
Why im unemployed
"my grandmother codes father than you"
"Hire her then?"
Ahem. Who's gonna explain it to him?
@@educlarity nope, let's just enjoy the awkwardness
@@educlarity PFFFT I DIDNT UNDERSTAND THEN I HAD TO COME BACK
@@educlarity LOL it took me a minute there to see
My grandmother RUNS faster than your CODE
I went to an interview were the interviewer was like this. Apparently it was an act to put the applicants under pressure, but they legit didn't know what they where talking about and wanted the database to be in the cloud, but also hosted on site for the example question.
I ignored the call back for the second interview.
These companies acting like your boyfriend/girlfriend toying with your feeling to test. Jesus fuck, they're running a business, not a toxic relationship xD
@@cloudynguyen6527 These bots are getting out of hand....
They were probably referring to a private cloud.
???@@revelmonger
Holy shit I got flashbacks from when I was applying for an internship to this startup. And damn I applied so I could learn to webdev, never realized I gotta study everything on my own in three days in order to deliver on a requirement to be accepted.
At this point it's better to create your own startup. Startup culture sucks balls.
at the end
Joma: EMOTIONAL DAMAGE
"What if we create a Beijing Corn?"
- Steven: "You're hired, I send you to Jesus now"
Sounds like Uncle Roger
Fuuuyyoooo this guy and uncle Roger should be in a video together 😂
If you mean the interviewer, you're in luck! They made a video with Twoset violin, called "Asians got parents" czcams.com/video/n_f-1JSJ2fM/video.html
Uncle Roger is a hack.
Watch the video : if shark tank was asian
Guys, do not even talk to such companies. And ignore them. They will make you a slave with a minimum wage and a lot of work.
Yeeey, two of my favourites in one video :D Good job guys
😂 me too
Omg it’s the emotional damage dude! I love him ❤️
“It was okay meeting you” might be the most disrespectful thing I’ve ever heard😂
not him wearing watch on left hand and looking time from right hand 💀
He says “look at the time” and points to the hand that doesn’t have a watch with the hand that does.
it's almost like it was done on purpose!
“Disappointment just like my son”.
As an Asian living with my parents, I felt that
The collab we never thought we needed
The collab I didn’t know I needed 😂
More vids with steve pls!!!!
A good general purpose method is to use two ordered containers (e,g. heaps), min and max, and bin incoming data into one or the other depending on whether it's greater or less than the head or tail elements. This has memory limitations, though.
why do you need 2 if you need them ordered anyway? you seem to mean 2 priority heaps (only partially ordered and thus faster than fully ordered grandma) of equal sizes (+-1) - you need to not only place the element into the right heap, but also rebalance them as needed.
The collaboration I never knew I needed!
Plot twist: the guy that walked out was the one getting interviewed
Bro you made the Day 🤣🤣🤣
Underrated
💀
"It was okay meeting you"
Now thats a lot of emotional damage
Is the interviewer the guy of "emotional damage"?
He is
StevenHe
When Steven says “look at the time” he’s looking on the hand without a watch lmao
The emotional damage is everywhere 😂
The best collab EVER 😂😂😂
collab we all wanted
100% accurate description of all the 100% interviews in India 😂
The last statement got me 😂😂
Now I'm genuinely scared on going to interviews 💀
😅😅 You eat too much hash, your brain turn into Potato. 😂😂😂
What a great collaboration🤣
BEST COLAB EVER!
"Disappointment just like my son"
-Every asian parents
“Hash, hash you eat too much hash brown your brain turn to potato” 😂😂😂😂
Lol the accuracy! Startups be asking which year you were the CEO of Apple
not even good “ it was ok meeting you” lmao
“it was okay meeting you” is a brutal line
"Disappointment , just like my son" got me rollin 😭😭😭🤣🤣🤣
Okay, that "It was okay meeting you" line did NOT need to go that hard. LMFAOOO 😂😂😂
This is literally my financial markets teacher...
These types of interviews don’t make sense, because the “day-to-day” of a software developer is not resolving these types of problems. Muy bueno.
It is like a standard stuff for swe. There are a lot of fields in computer science and it is really hard to find someone who worked in the field you are going to fill in your company. But it is very easy for an engineer to adapt a new tech to work in the position which he has never worked before. How can you ask questions that he have never worked before, right? Why don't we ask questions on what he have done? Yes we do but it is not enough to conclude a swe if he good/bad for the position (he can lie). So algorithms/system design/data structure are the standard stuff for every swe to should know.
He pointed to his hand to indicate the time with the hand that had his watch on it
Lmao the ending line brings me back to the interviewers old videos
"It was okay meeting you" was a lot more brutal than it should lol
Emotional Damage,
As someone that just went through a technical interview yesterday, that gave me emotional damage.
The collab we didn’t expect but happy we all got 😂😂
Finally the colab we want the most 🤣🤣🤣🤣
Eeemotional daaamage
Great collab..
"It was okay meeting you" 😂 That's gold I gonna use that
Emosanal daammage 😜
As a computer science student, god damn this is so real
"it was okay meeting you".. destruction 😂
This was emotionally damaging
"It was OK meeting you"
😂😂
love the collab
Best Combo Ever
It was okay meeting you😂😂
Uncle Roger's Interview. Haiyaa!!
I like how he looks at the time on his right wrist but watch was on the left
Emotional damage 🤣🤣🤣🤣
“Just like my son” 💀💀
the first idea was pretty good.
I'd make an array of all Inputs, divide the number of items by 2, subtract 0.5 if it's not natural and then output the item on that place in the array (you'd have to subtract 1 again if the language starts counting array items with spot 0)
pretty sure that future me will want to slap me cuz there's an easier solution when he reads this :P
Storing the whole stream is not ideal. You need no more than half of the stream. Just make a queue and pop an item every time 2 new items added to it.
@@PavloPravdiukov oh ok, thx
med = med/(count+1)*(count);
med += current/++count;
The median... if creating an array solution.. you would need to pop then sort functions in the class for every data point right... or half as the other dude mentioned...
@@PavloPravdiukovit is not sorted, so you have to sort it fitst to find the median and if you receive a stream of 2 100 2 100 2 100, then your "half" will be either 2 2 2 or 100 100 100 and the median is not guaranteed to be true. You need to use a set with binary search insert to read + sort or a heap with median on the top with log N insert
That "fck" is very relatable in some of my interviews.
"You r even better than my son at failing tests"
Would you look at the time, he said pointing to the other wrist...🤣
I know uncle Roger but this Chinese guy also speak like this and "emotional demage" is his iconic line. (I don't know so much about him tho)
Immmmotional daaaaaamaaage
Use two heaps min heap and max heap. This is like the OG interview question !
Moreeee
The dude: *Emotional damage*
"Haaayaaa.."
I love joma and Steven he! This is GOLD!
Anyone who wants answer. Use 2 heaps 1st max heap and second min. Insert values from the data stream keeping in mind the sizes of heaps.
Case1. If odd no of elemenrs exist within both heaps get the root from the heap with more elements.
Case2. If even no. of elements exist, take both the roots and compute average of them as result.
Another better way : median of medians..
The truth of Asian interview. I had seen many difficult while meeting. They asked me to fill in 25 Mc and 1 lq within 20 minutes. Actually, my university gives me 40 minutes to complete same task. It burns my brain. I can't see any respect from Asian employers
Need more videos like this
I sense the inevitable emotional damage coming his way.
This gave me SEVERE anxiety damnit 😭
you have to import MSG... hayaaaaa
MSG?
Which module is that?