4: Reverse an array.
⏳⌚ 00:00:00

Explaination:-

for Reverse an array , you can follow these steps:-
1.Initialize Two Pointers:- Start by initializing two pointers, one at the beginning of the array (let's call it left) and the other at the end of the array (let's call it right). left initially points to the first element of the array (index 0). right initially points to the last element of the array (index n-1, where n is the number of elements in the array).
2. Swap Elements:- Swap the elements pointed to by left and right. This effectively reverses the order of these two elements.
3.Move Pointers Inward:- Increment left by one (move it to the right) and decrement right by one (move it to the left). Continue Swapping and Moving: Repeat steps 2 and 3 until left is greater than or equal to right. This means you've reversed the entire array.
4.Array is Reversed:- At this point, the entire array will be reversed, and you're done.

solution->

View Code 1
Time Complexity = O(n)
Space Complexity = O(n)