Skip to content

Instantly share code, notes, and snippets.

@bhavjot
Created March 10, 2017 05:14
Show Gist options
  • Save bhavjot/be5df7adf232c1630893d67ba82f44fa to your computer and use it in GitHub Desktop.
Save bhavjot/be5df7adf232c1630893d67ba82f44fa to your computer and use it in GitHub Desktop.
Reverese Array- Hacker Rank
using System;
namespace HackerRank
{
class Program
{
static void Main(string[] args)
{
int n = Convert.ToInt32(Console.ReadLine());
string[] arr_temp = Console.ReadLine().Split(' ');
int[] arr = Array.ConvertAll(arr_temp, Int32.Parse);
for (int i = 0; i < n / 2; i++)
{
int temp = arr[i];
arr[i] = arr[n - i - 1];
arr[n - i - 1] = temp;
}
string reverseArr = string.Join(" ", arr);
Console.Write(reverseArr);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment