**Hint 1:** Think about how you can partition the array into three parts: elements less than the pivot, elements equal to the pivot, and elements greater than the pivot. This will help you satisfy the conditions mentioned in the problem statement.
**Hint 2:** Consider using a two-pointer approach. One pointer can start from the beginning of the array and move towards the end, while the other pointer can start from the end of the array and move towards the beginning. This will allow you to efficiently partition the array into the three parts.
**Hint 3:** When iterating through the array, keep track of the number of elements less than the pivot and the number of elements greater than the pivot. This will help you determine when to stop moving the pointers.
**Hint 4:** Think about how you can use the relative order of the elements less than and greater than the pivot to your advantage. For example, if you find an element that is less than the pivot, you can move the first pointer forward and update the count of elements less than the pivot. Similarly, if you find an element that is greater than the pivot, you can move the second pointer backward and update the count of elements greater than the pivot
**Hint 1:** Start by thinking about how you can separate the array into three parts: elements less than the pivot, elements equal to the pivot, and elements greater than the pivot. How can you efficiently achieve this separation?
**Hint 2:** Consider using a two-pointer approach. Initialize two pointers, one at the beginning of the array and one at the end. How can you move these pointers to separate the array into the three parts?
**Hint 3:** Think about how you can maintain the relative order of elements less than and greater than the pivot. How can you ensure that elements with the same value as the pivot are placed in the correct position?
**Hint 4:** Don't forget to consider the edge cases! What happens when the pivot is the smallest or largest element in the array? How can you handle these special cases?
**Hint 5:** Finally, think about how you can combine the three parts to form the final rearranged array. Can you use a simple loop or a more complex data structure to achieve this?
By breaking down the problem into smaller sub-problems and using a combination of these hints, you should be able to come up with a creative solution to this problem!
**Hint 1:** Start by thinking about how you can separate the elements of the array into three categories: elements less than the pivot, elements equal to the pivot, and elements greater than the pivot. Can you think of a way to iterate through the array and group these elements together?
**Hint 2:** Consider using a two-pointer approach. You can use one pointer to iterate through the array and identify elements that are less than the pivot, and another pointer to iterate through the array and identify elements that are greater than the pivot. How can you use these two pointers to create the desired output?
**Hint 3:** Think about how you can maintain the relative order of the elements less than and greater than the pivot. Can you use a data structure like a stack or a queue to help you keep track of the elements and ensure that they are in the correct order?
**Hint 4:** Don't forget to handle the elements equal to the pivot! You'll need to insert these elements into the correct position in the output array. Can you think of a way to do this efficiently?
**Hint 5:** Take your time and think about the edge cases. For example, what happens if the pivot is the