Given an array of positive and negative numbers, arrange them in an alternate fashion such that every positive number is followed by negative and vice-versa. Order of elements in output doesn’t matter. Extra positive or negative elements should be moved to end.ExamplesInput : arr[] = {-2, 3, 4, -1} Output : arr[] = {-2, 3, -1, 4} OR {-1, 3, -2, 4} OR .. Input : arr[] = {-2, 3, 1} Output : arr[] = {-2, 3, 1} OR {-2, 1, 3} Input : arr[] = {-5, 3, 4, 5, -6, -2, 8, 9, -1, -4} Output : arr[] = {-5, 3, -2, 5, -6, 4, -4, 9, -1, 8} OR ..We strongly recommend you to minimize your browser a
...
继续阅读
(18)