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
|
139 Discussions
|
Please Login in order to post a comment
I found the correct code for java. I was struggling as everyone here, and understood that we should not right the code to solve the problem, we only need to change the given code to get the correct output.
I am using pyhon. I believe my solution is right. I only change 3 lines of code. Still I can't get this to work.
Mine was broken like some of the other comments here, and it was due to changing too many lines. Even though I changed and undid my change it wasn't until after I hit the "reset code" button in the top right and then applied my 3 lines of changes that my solution was accepted.
The return void problems like this are always broken
There is no code to debug in Javascript but I try to get the result in 3 lines but it did not pass the test.
function processData(input) { //Enter your code here const arr = input.split('\n')[2].split(' ').map(str => parseInt(str)).sort((a,b) => a - b); const mid = Math.floor(arr.length/2); console.log([...arr.slice(0,mid),...arr.slice(mid).reverse()].map(String).join(" "));
}