Sorting in linear time

This is my code, but it does not pass all the test cases.Why?

hello @ayushtiwari12

its time complexity is O(n^2) thats why it is not passing.

try to solve it in O(n)
hint -> in input u will only have 0,1 or 2

will you please make it correct in my code?

bro u need to change ur complete logic.

keep count of 0 , 1 and 2.
and then simply use tht counting to put that many of 0 in start then put 1 s and then 2

https://ide.codingblocks.com/s/374107 I have change my code, but again it is showing runtime error.

@ayushtiwari12
pls check ur updated code here->

Thankyou, Now I got it.