Not getting correct output

please check what is the wrong in my code

hi @shivamgoel150 there are two things wrong with your code.

  1. You already declared size of v as n. If you do a push_back operation, the elements will be placed starting from the index n. You can simply access the elements from 0 -> n-1
    image

  2. Assign the first job after sorting, not before.
    image