Find the second highest number in an array java | Client Escalation | 171 | Second Largest Number

Поділитися
Вставка
  • Опубліковано 2 жов 2024

КОМЕНТАРІ • 8

  • @shankardayal6928
    @shankardayal6928 2 роки тому +3

    Why voice quality of almost all videos are very low?

  • @akashtiwari9039
    @akashtiwari9039 2 роки тому +2

    Hi There is a difference between Arrays.sort and Bubble sort. When you use two for loops that means you are using bubble sort which gives time Complexity as big O( n^2) while when you use Arrays.sort it internally use quick sort for primitives and merge sort for objects which give average time complexity as big O(n) which is very optimized as compared to bubble sort. This is the reason why client was rejecting many candidates as time complexity wasn't good enough.

    • @akashtiwari9039
      @akashtiwari9039 2 роки тому

      So what you can do to solve this problem is simply(either you set or simply write a for loop and iterate all the elements) remove duplicacy from array after that perform sorting.

  • @shubhamkumar-gw4vb
    @shubhamkumar-gw4vb 2 роки тому +1

    bhai want more of these please, i'm about to go through the client interview process

  • @rahulverma4200
    @rahulverma4200 2 роки тому +1

    Use Java 8 stream

  • @MrKranthisingh
    @MrKranthisingh 2 роки тому

    Good.