In this challenge, the task is to debug the existing code to successfully execute all provided test files.
Given an array of n distinct integers, transform the array into a zig zag sequence by permuting the array elements. A sequence will be called a zig zag sequence if the first k elements in the sequence are in increasing order and the last k elements are in decreasing order, where k = (n+1)/2. You need to find the lexicographically smallest zig zag sequence of the given array.
Example.
a = [1,3,2,5,4]
Now if we permute the array as [1,4,5,3,2], the result is a zig zag sequence.
Debug the given function findZigZagSequence to return the appropriate zig zag sequence for the given input array.
Note: You can modify at most three lines in the given code. You cannot add or remove lines of code.
Watch video HackerRank | 1 Week Preparation Kit | Zig Zag Sequence hackerrank solution in python | Day 3 online without registration, duration hours minute second in high quality. This video was added by user Engineers Revolution 08 January 2023, don't forget to share it with your friends and acquaintances, it has been viewed on our site 1,984 once and liked it 10 people.