Skip to content
We areTOP 1%

Special Permutation

MediumRating 1600CodeforcesConstructive Algorithms
Solve on Codeforces(opens in a new tab)
Track your progress
First attempt
Re-solve after a few days
Final pass before interviews
Approach hintTry it first, then reveal

Very small n has no answer. Otherwise consider placing all odd numbers in decreasing order followed by the even numbers, and choose the first two even numbers so the junction difference stays within [2, 4].

More in Constructive Algorithms

Constructive Algorithms questions
#ProblemPlatformDifficultyOpen1st1st Visit2nd2nd VisitRevRevise
1Beautiful Arrangement IILeetCodeMedium Solve Beautiful Arrangement II on LeetCode (opens in a new tab)
2Special PermutationCodeforcesMedium 1600Solve Special Permutation on Codeforces (opens in a new tab)
3Ehab and Prefix MEXsCodeforcesMedium 1600Solve Ehab and Prefix MEXs on Codeforces (opens in a new tab)
4Prefix Flip (Hard Version)CodeforcesMedium 1700Solve Prefix Flip (Hard Version) on Codeforces (opens in a new tab)
5Construct Target Array With Multiple SumsLeetCodeHard Solve Construct Target Array With Multiple Sums on LeetCode (opens in a new tab)
6Find the Closest PalindromeLeetCodeHard Solve Find the Closest Palindrome on LeetCode (opens in a new tab)
7A/B MatrixCodeforcesHard 1900Solve A/B Matrix on Codeforces (opens in a new tab)
8Phoenix and ScienceCodeforcesHard 1900Solve Phoenix and Science on Codeforces (opens in a new tab)
9Replace by MEXCodeforcesHard 1900Solve Replace by MEX on Codeforces (opens in a new tab)
10Engineer ArtemCodeforcesHard 2000Solve Engineer Artem on Codeforces (opens in a new tab)
11Orac and MediansCodeforcesHard 2000Solve Orac and Medians on Codeforces (opens in a new tab)
12Make Them EqualCodeforcesHard 2000Solve Make Them Equal on Codeforces (opens in a new tab)
13Transform to ChessboardLeetCodeHard Solve Transform to Chessboard on LeetCode (opens in a new tab)
14Errich-Tac-Toe (Easy Version)CodeforcesHard 2100Solve Errich-Tac-Toe (Easy Version) on Codeforces (opens in a new tab)
15Multiples and Power DifferencesCodeforcesHard 2200Solve Multiples and Power Differences on Codeforces (opens in a new tab)

Sign in to track your progress

Your checkboxes, streak and activity heatmap are saved to your account and sync across devices. It is free.
Sign in with email

New here? Create an account