Wavy Sequence
CodeChefOpen on judge ↗
Problem Statement John defines a wavy sequence "a" as a sequence of N integers such that a[0] a[2] a[4] ... and so on. Also, he defines the value of a sequence as sum of |a[i] - a[i - 1]| for all 0 Now, any sequence that is wavy and has maximum value amongst all its permutations becomes the favourite of John. Given an integer N, can you print the lexicographically minimum permutation of length
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start