Zig Zag Sequence

  • + 2 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);

            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));
    }`