None of the test cases are getting passed

https://ide.codingblocks.com/s/213248 Still not working after sorting

Hello @tusharnitharwal,

You can refer to the following video:

Also, the output should be in a sorted manner.

Hope, this would help.

my solution is almost similar

Hello @tusharnitharwal,

  1. Missing Case:
    //when there is no node:
    if(v.size()==0)
    cout<<“0”;
    else{
    sort(v.begin(),v.end());
    for(int i=0;i<r;i++)
    {
    cout<<v[i]<<" ";
    }
    }

  2. No, the logic is not similar:
    It failing for many test cases:
    Example:
    9
    1 20 8 4 2 12 10 14 22
    2 4 8 10 12 14 20 22 1
    1
    8 2
    Expected Output:
    1 2 10 14 22
    Your Output:
    1

You must see this code:

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.