How can I solve this
Resort the array taking the absolute value of negative numbers. Your complexity should be O(n)
Ex. A = {-8,-5,-3,-1,3,6,9}
Output: {-1,-3,3,-5,6,-8,9}
How can I solve this
Resort the array taking the absolute value of negative numbers. Your complexity should be O(n)
Ex. A = {-8,-5,-3,-1,3,6,9}
Output: {-1,-3,3,-5,6,-8,9}
Hey @ritika_dhamija
Try this out:
1. Split the array in to two halves, one with negative numbers and the other with positive numbers.
2. Reverse the negative numbers array.
3.Then, run merging algorithm considering the absolute value of both the arrays.
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.