Absolute Permutation (from HackerRank)
This was a fun, moderate problem: https://www.hackerrank.com/challenges/absolute-permutation It is asking you to find an absolute permutation for the given arrays. All you have to do is check whether you can find a suitable candidate for each position in the array. There are only two candidates: index+k and index-k. Keep track of the candidates already used, make sure to prioritize the ones in ascending order, and you should be good. It is in linear time, and given the upper bound of 10^5, this would have been a hint that you need to do it in linear time otherwise the TCs will timeout. Apparently it worked: Code is below, cheers, Marcelo. using System; using System.Collections.Generic; using System.IO; using System.Text; using System.Collections; class Solution { public static void Main(String[] args) { int t = Int32.Parse(Console.ReadLine()); int[][] s...