Find second largest number from an array in C# || Interview Program

Поделиться
HTML-код
  • Опубликовано: 10 дек 2024

Комментарии • 25

  • @InterviewPoint
    @InterviewPoint  2 года назад +1

    Code has been updated of this video, Link is available in the description box for the updated code.

    • @jaishreeagrawal5775
      @jaishreeagrawal5775 2 года назад

      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
      @InterviewPoint  2 года назад +1

      @@jaishreeagrawal5775 You are right, have you checked updated code on the blog? link is available in description of this video.

    • @jaishreeagrawal5775
      @jaishreeagrawal5775 2 года назад +1

      @@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];
      }

  • @DrunkenEngineer
    @DrunkenEngineer 4 года назад +1

    Inspired from you even I have started Sharing my Interview Experience with different Mnc's

    • @InterviewPoint
      @InterviewPoint  4 года назад

      Thank you, and wish you all the best for your new journey, keep it up the good work...

  • @nigarbayramli5645
    @nigarbayramli5645 2 года назад

    Thanks for the explanation👍

  • @sanjaykhanna1838
    @sanjaykhanna1838 5 лет назад +2

    Good Job Brother Keep it Up

  • @deepanr7924
    @deepanr7924 3 года назад

    awesome taech way sir!

  • @harshsaxena05
    @harshsaxena05 3 года назад +1

    very good program but please explain well..

  • @yesudoss7127
    @yesudoss7127 4 года назад

    Good

  • @krajasrikar
    @krajasrikar 8 месяцев назад +1

    Please keep a debug point and explain bro

  • @abhiksingh1999
    @abhiksingh1999 10 месяцев назад

    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);

  • @MuhammadAbbas-pd8sf
    @MuhammadAbbas-pd8sf 2 года назад +1

    it not works on 0,5,1,2,1,5..
    first and second both shows 5 output

    • @InterviewPoint
      @InterviewPoint  2 года назад

      Code has been updated, please check code on blog, Link is available in the description box.

  • @AbhilashYadavSanghsevak
    @AbhilashYadavSanghsevak Год назад

    int max1,max2;
    int[] arr = { 12, 30, 32, 85, 80, 90, 98, 78, 74 };
    for(int i=0;i

    • @InterviewPoint
      @InterviewPoint  Год назад

      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.

  • @SandeepPal084991904
    @SandeepPal084991904 Год назад

    Wrong code on blog also

    • @InterviewPoint
      @InterviewPoint  Год назад

      What output are you getting by using the video code?