We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
My code has the same result but is showing that is wrong.
Someone could help me?! ` int n = Convert.ToInt32(Console.ReadLine());
for(int i = 0; i < n ; i++){
int k = Convert.ToInt32(Console.ReadLine());
string[] arr_temp = Console.ReadLine().Split(' ');
int [] arr = Array.ConvertAll(arr_temp, Int32.Parse);
int midIndex = arr.Length / 2;
int lastIndex = arr.Length - 1;
Array.Sort(arr);
int max = arr[lastIndex];
arr[lastIndex] = arr[midIndex];
arr[midIndex] = max;
int leftIndex = midIndex + 1;
int rightIndex = lastIndex - 1;
while(leftIndex < rightIndex)
{
int tempAux = arr[leftIndex];
arr[leftIndex] = arr[rightIndex];
arr[rightIndex] = tempAux;
leftIndex ++;
rightIndex --;
}
Console.WriteLine(string.Join(" ",arr));
}`
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Zig Zag Sequence
You are viewing a single comment's thread. Return to all comments →
My code has the same result but is showing that is wrong. Someone could help me?! ` int n = Convert.ToInt32(Console.ReadLine()); for(int i = 0; i < n ; i++){ int k = Convert.ToInt32(Console.ReadLine()); string[] arr_temp = Console.ReadLine().Split(' '); int [] arr = Array.ConvertAll(arr_temp, Int32.Parse);