Zig Zag Sequence

Sort by

recency

|

1054 Discussions

|

  • + 0 comments

    `What is the problem?

    //C++

    void findZigZagSequence(vector < int > a, int n){

        sort(a.begin(), a.end());

        int mid = (n + 1)/2;

        int st = mid - 1;

        int ed = n - 1;

        while(st <= ed){

            swap(a[st], a[ed]);

            st = st + 1;

            ed = ed - 1;

        }

        for(int i = 0; i < n; i++){

            if(i > 0) cout << " ";

            cout << a[i];

        }

        cout << endl;

    } `

    running failed: compiler Message Wrong Answer

    Input (stdin)

    1

    7

    1 2 3 4 5 6 7

    Your Output (stdout)

    1 2 3 7 6 5 4

    Expected Output

    1 2 3 7 6 5 4

  • + 0 comments

    I can't see the option to code in Javascript

  • + 0 comments

    C++20 and Java 15 has no starter code, maybe these should be fixed or removed

  • + 1 comment

    Make sure you only edit 3 lines, even white space/comments count!

  • + 0 comments

    Misisng typescript template for findZigZagSequence.