Reverse [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36] in-place.
Ready — edit the code above and click Run.
using System;
class Program
{
static void Main()
{
int[] arr = { 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36 };
int l = 0, r = arr.Length - 1;
while (l < r) { (arr[l], arr[r]) = (arr[r], arr[l]); l++; r--; }
Console.WriteLine(string.Join(", ", arr));
}
}
Try solving on your own first, then reveal the official answer.
Two-pointer reverse.