 Welcome guys, welcome to our channel. So today in this video I am going to share you one of the interview questions that I have encountered in my recent interview. So this question was like, basically the question was, the question is very simple, but I was unable to give a solution using Java, it streams. So the question was this, so I was given an array of integers, I was asked to print key value pairs, how many times the number is getting repeated. So two is getting repeated one time, it is only one time three is getting repeated two times four is getting repeated two times. So this question was asked to me, one of the company called Ivy Compete in that interview I was asked this question and I was unable to give the solution using stream. So then later on I thought this is a very, what I can say very, below average question. So I won't be getting this kind of questions in my, any other of it, but believe me after four to five days in Tick-Mindra interview, the same question was asked instead of integers, it was string. And again I was unable to give the answer. So usually whenever I am unable to give any coding answer, I usually go back home and prepare for the coding question, like why I was unable to give the solution. But when came to, but when I was unable to give the answer for the first, whenever I was unable to give the answer for the first question, I still didn't practice because thinking nobody will be asking this kind of questions. But like what I can say, unexpectably, like unexpectably was hard, I have encountered the same question again within few days. The same question again appeared in front of me and in both the interviews I was unable to give the solution because I was not able to find a call. Like I haven't practiced it to be honest, you need to know some internal classes of Java 8 to give a solution for this, for this solution. So let us see how, like later on a practice and let us see. And the reason for sharing this question is, maybe I feel there might be at least one or two, three, one or two guys who might be not aware of this class. So I am sharing this for them. So let us give the solution numberless.stream.collect.groupingby. So to be honest, I know how to use grouping by function, but here the trick was I was not able to, I was not knowing this function.identity. So it would be the key, comma, looking by function.identity, commons, collectors, dot, counting. So this was the solution that we were expecting from here. To be honest, I know every part of this, but I wasn't aware of this function.identity. So I was unable to get the answer at that time. So let us capture this output that equals map of string and integer and long and let us print this output now. So task storage and key value base will be there when lambda, let us print this. So let us print this and see whether we are getting what desired output or not. So yes, we are getting the desired output three quadrupled twice, four quadrupled twice, nine quadrupled twice. And let us see the similar solution was for array list as well. Let's see that solution as well. So basically the intention is don't underestimate any question. Thinking your experience is high, you will not be getting this kind of question. Anyone can get any question. So this was the only two questions in those interviews I was unable to give answers. So don't do this mistake. I will not do this mistake again. To be honest, like once I mistake them, okay, fine, but again and again repeating the same mistake is wrong. So I'll not do that. I'll prepare you no matter how small the question is. We should respect that question. I thought I came to take revenge from me after not preparing even though I was asked to me earlier interview or put to create a local variable. Yep. And let me copy this. Let us run this application now. And see just we got the desired outputs and I was and if you prefer at all, that's how we can give the solution. So basically this was the key function identity that I was not aware of. Like we want what actually does. So later on I learned it and I have started applying it like coding doing some practices. So if at all someone wants the solution in the traditional way, here it is. So here is the solution. I just I was having this already. So I just copy this. So I have created a map to store the output. This is in as per look. I was like everything in the string list. So I was checking the map, whether if it is containing the key, if it is containing the key, then I was getting the value. I was implementing the value. And again, I was keeping putting that back into the map. I was putting the I was inserting it as a new entry and I was. This is how I was. Oh, sorry. This is how I was. This is how I was. Let us see. Let us run this and see. This is how we can fill the legacy. The legacy. Now it has become legacy. In as per look. So, yeah. This is four times. We got the same output, but this was not accepted. At least with the experience that I had, he was expecting to know each and every class in Java 8. Sadly, I was unable. I was not sure of these classes. So that's it in this video. If you guys have not yet subscribed, please do subscribe by hitting the subscribe button. And if at all you want to. Contributors, you can open any one of our interview or any of your videos. And on your next shopping at Amazon, you can use our Amazon official affiliation link. And when you click it, it will take you to Amazon, Amazon app or Amazon website. Here you can search your item, whatever items you want. Like I put all I want to go pro. Okay. So I'll go all. So basically anything you can go and buy before buying that up. Please use our affiliation so that we might get some commission out of it. That's it. That is what I wanted to show you. If you haven't subscribed, please do subscribe. There are many videos that are chewed up. And thanks for watching. Bye-bye.