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.
- Zig Zag Sequence
- Discussions
Zig Zag Sequence
Zig Zag Sequence
Sort by
recency
|
1054 Discussions
|
Please Login in order to post a comment
`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
I can't see the option to code in Javascript
C++20 and Java 15 has no starter code, maybe these should be fixed or removed
Make sure you only edit 3 lines, even white space/comments count!
Misisng typescript template for findZigZagSequence.