Commit 2dc978c
committed
feat: Add two-pointer method to reverse an array in-place
🧠 Logic:
- Introduced `ReverseTheArray(int[] arr)` method using two pointers (`p1` at start, `p2` at end).
- Swap elements at `p1` and `p2` and move both pointers towards the center.
- This reverses the array efficiently in O(n) time and O(1) space.
Signed-off-by: Somesh diwan <[email protected]>1 parent 6c014d6 commit 2dc978c
File tree
2 files changed
+4
-43
lines changed- Section9ArrayAB/Array 2.0/src
2 files changed
+4
-43
lines changedThis file was deleted.
Lines changed: 4 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | | - | |
| 1 | + | |
| 2 | + | |
5 | 3 | | |
6 | 4 | | |
7 | 5 | | |
8 | | - | |
9 | 6 | | |
10 | 7 | | |
11 | 8 | | |
12 | 9 | | |
13 | 10 | | |
14 | | - | |
| 11 | + | |
| 12 | + | |
15 | 13 | | |
16 | 14 | | |
17 | 15 | | |
18 | | - | |
0 commit comments