retagged by
501 views

1 Answer

2 votes
2 votes
Apply one pass to count number of 1, 0, -1 hen in second pass do fillling -1 first then 0 then 1.

SO O(n) time.

Related questions

0 votes
0 votes
1 answer
1
1 votes
1 votes
1 answer
2
A_i_$_h asked Jul 24, 2017
287 views
array has n elements and we need to sort them in non decreasing order as follows. first find minimum, remove this element from the array and find minimum of remaining ele...
1 votes
1 votes
1 answer
4
admin asked Jan 6
142 views
Which of the following is true for a sorted list with ' $n$ ' elements?Insertion in a sorted array takes constant time.Insertion in a sorted linear linked list takes cons...