 back to our channel so today we are going to share one interview patient so the purpose of sharing this video is like recently we have connected a drive so out of 10 we placed them in front of our client so there was a client round so client hub the slow go reject my idea so I was there in the client round as well so the reason why you have to say widget kardiya sabko is the coding question so this was a coding question basically he was that was given like find the second highest number from an array so they say the equation because sub-loan a cat here for sale the head are a dot sort input or print karadha sysout input dot minus 2 so print karane say ideally you have it If 22 is the highest number, then it will work. They were typing this solution, this code and expecting they got the ideal result. So the client changed it. He put 1 comma and 1 and 45. Now he won't work for an hour. Because he didn't do the duplicates handy. Because here the hard coded one will give the last but one. Here 45 and 45 is the last one. He returned it. He was giving a chance. So he says this as an approach 1. So he was giving an opportunity again. Like, can you try? So what people started doing? So I copy and paste it. So what people started doing? Let us say this as approach 2. And how does this code look? They are putting two for loop. And they are swapping the temporary variable. And they are writing input of input dot length minus 2. This may be the same issue. It will just, they are just returning the last but one. Number is there. So the client is asking what is the difference. They are saying this is swapping logic and this is sorting logic. They were candidates who were having more than 8 plus years of experience. Actually this logic here is in this method. This is the swapping and sorting logic. People are saying this is a different logic. But when we write this code, some different logic gets performed. This is not the case. Ideally they are doing the same. Either we are sorting, swapping, swapping. So they are rejecting. I mean 10 to 10 people rejected. So finally our thought of sharing the best way which handles the duplicates as well. So this is the best way. Here is the best way that will handle the duplicates as well. So now within one for loop this gets completed. Here people were giving 2 to 2 for loop. They are still using 2 to 2 for loop. They are not getting the output yet. And here this happens once per loop. Just take 2 variables. First and second. Swap the loop. Swap the loop for the first and second. Put the loop for the first and second. And then put the Lcf. The input of i is greater than second. And the input of i is not equal to first. Then put the second. So if we look at the end. The first 2 are saved. Now see this is 22. And the second 2 are 45. And if I remove the first 45 from here. I remove the duplicate. So they are giving 3 for 22. So they are giving 3 for 22. So the first question was for 10 people. So there were 2 questions. So the next question also I will share. If people were unable to write. So now they will give 3 right. There is no duplicate here. It is right there. So as soon as the duplicate came. The code is gone. So we have escalated. That people are taking the useless people from the market. So whenever you encounter this type of question. Like finding the second highest number. So always just think. What the logic you are writing. So this is it. I hope you guys liked it. That's it. Thank you for watching. I hope this video helps you.