Can i sort a particular part of array using sort() function

for example i have an array of 7 to 8 elements and i want to sort in pair of 5 means i want to sort element from 1 to 6 ,then 2 to 7 and then 3 to 8. can i do this using sort()

i am thinking of
A[10],i

loop of i
sort(A+i,A+(i+5));
can i do like this ?

why dont you just try it ?

2 Likes

i tried but not getting desired output . so i want to know can we use sort() function to sort some part of array or not

Yes, you can…

Replace i with i-1, it’s 0 based index

1 Like

loop of i starts from 0 so i have taken i .

Show code ! Then only i could debug

I don’t complie English :stuck_out_tongue:

3 Likes

i am getting right answer on putting custom input but on submission it is showing WA

Access Denied! Is this related to some ongoing contest?

yep that’s why i am not posting whole code. i found the answer it is working on other ide but WA on submission

That means your logical approach is not correct. Try to test it with all kinds of inputs like corner cases and big values.

1 Like

i have tested with all the valid values and it is giving correct output

WA means you haven’t tried all values :wink:

can you give some input values of problem S10Eoctober challenege i will test it

This is not allowed.

1 Like

ok just tell me one thing in input can we take values out of range of question contarint

No, all inputs are strictly within the constraints

then my program is giving right ouput .i don’t know what is messing up . is there any limit of WAs?

Just try to find an input for which your programs gives a wrong output, correct it and submit again. You have more than a week. If you can’t, let the contest end and wait for the editorial. Then you’ll get your mistake :wink:

2 Likes

got the mistake thanks to WAs they are love :smiling_face_with_three_hearts:

1 Like