Zig Zag Sequence

Sort by

recency

|

73 Discussions

|

  • + 0 comments

    " Now if we permute the array as [1,4,5,3,2] , the result is a zig zag sequence. " This will NOT be the resutl given the input in the example. So it was a very confusing exmaple to give. If you first sort the array clearly this isn't a good output.

  • + 0 comments

    this worked(C++11) void findZigZagSequence(vector < int > a, int n){ sort(a.begin(), a.end()); int mid = (n)/2; swap(a[mid], a[n-1]);

    int st = mid + 1;
    int ed = n - 2;
    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;
    

    }

  • + 1 comment

    Hi, I'm having an issue with the test cases for ts even the result and expected output is the same. someone nows how to fix this?

    Traceback (most recent call last): File "Solution.py", line 174, in run_custom_checker(t_obj, r_obj) File "Solution.py", line 75, in run_custom_checker system_code = code_data[t_obj.submission_language].strip() KeyError: u'typescript'

  • + 0 comments

    C++20 Has no code to debug

  • + 1 comment

    Hi,

    somehow the answer is not accepted even if the output looks same to me.

    I copied this Solution in Python: https://github.com/JayantGoel001/HackerRank/blob/master/Zig%20Zag%20Sequence.py

    Someone made the same experience?