Zig Zag Sequence

  • + 0 comments

    This one in C# asks to create to whole class but it fails... Am I getting negatives cuz of performance?

    class Solution {
        static void Main(String[] args) {
            /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution */
            int queries = Convert.ToInt32(Console.ReadLine());
            int arrLength = Convert.ToInt32(Console.ReadLine());
            string[] arrStr = Console.ReadLine().Split(' ');
            int[] arr = new int[arrLength];
            int[] res = new int[arrLength];
    
            for (int count = 0; count < arrStr.Length; count++)
            {
                int item = Convert.ToInt32(arrStr[count]);
                arr[count] = item;
            }
    
            arr = arr.OrderBy(x => x).ToArray();
    
            for (int index = 0; index < arrLength; index++)
            {
                res[index] = arr[index < (arrLength - 1) / 2 ? index : (arrLength - index) + 2];
            }
    
            Console.WriteLine(String.Join(" ", res).Trim());
        }
    }