Hello Sir, Your videos really helped me a lot, thank you so much... But in this program there is a loophole, it is showing a wrong result for this particular array ---- int[] arr = {140, 139, 140, 100, 100, 100, 140}; result is Max1 = 140 & Max2 = 140 but in this case max2 is 139
@@InterviewPoint yes sir, I have checked but it is still showing the same output for that particular array elements. So I have tried this condition for that ... please check if (arr[i] > Max1) { Max2 = Max1; Max1 = arr[i]; } else if (arr[i] > Max2 && Max1 != arr[i]) { Max2 = arr[i]; } else if (arr[i] < Max2 && Max1 == Max2) { Max2 = arr[i]; }
There is a mistake in code. Updated code is available on my blog, link is available in the description of the video. Also check the pinned comment of this video.
Code has been updated of this video, Link is available in the description box for the updated code.
Hello Sir, Your videos really helped me a lot, thank you so much... But in this program there is a loophole, it is showing a wrong result for this particular array ---- int[] arr = {140, 139, 140, 100, 100, 100, 140}; result is Max1 = 140 & Max2 = 140 but in this case max2 is 139
@@jaishreeagrawal5775 You are right, have you checked updated code on the blog? link is available in description of this video.
@@InterviewPoint yes sir, I have checked but it is still showing the same output for that particular array elements.
So I have tried this condition for that ... please check
if (arr[i] > Max1)
{
Max2 = Max1;
Max1 = arr[i];
}
else if (arr[i] > Max2 && Max1 != arr[i])
{
Max2 = arr[i];
}
else if (arr[i] < Max2 && Max1 == Max2)
{
Max2 = arr[i];
}
Inspired from you even I have started Sharing my Interview Experience with different Mnc's
Thank you, and wish you all the best for your new journey, keep it up the good work...
Thanks for the explanation👍
Thank you
Good Job Brother Keep it Up
Thanks
awesome taech way sir!
Glad you liked it
very good program but please explain well..
sure. thanks for your suggestion
Good
Thanks Yesu
Please keep a debug point and explain bro
Sure
int max1 = int.MinValue, max2 = int.MinValue;
for (int i = 0; i < arr.Length; i++)
{
if (arr[i]>max1)
max1 = arr[i];
else if (arr[i]>max2 && arr[i]!=max1)
max2 = arr[i];
}
Console.WriteLine(max2);
it not works on 0,5,1,2,1,5..
first and second both shows 5 output
Code has been updated, please check code on blog, Link is available in the description box.
int max1,max2;
int[] arr = { 12, 30, 32, 85, 80, 90, 98, 78, 74 };
for(int i=0;i
There is a mistake in code. Updated code is available on my blog, link is available in the description of the video.
Also check the pinned comment of this video.
Wrong code on blog also
What output are you getting by using the video code?