Company: Amazon_12oct
Difficulty: medium
Lexicographically Smallest Sequence Problem Description Data scientists at Amazon are working on a utility to generate data points for their models based on existing data points. A simple prototype takes in two integers, n , and sequence_sum , and generates a sequence of size n whose sum of elements equals sequence_sum , and the absolute values of the elements form a permutation of size n . The utility reports the lexicographically smallest such sequence. Given two integers, n , and sequence_sum , return the lexicographically smallest sequence of integers such that: The sum of its elements equals sequence_sum . The absolute values of its elements form a permutation of size n . Note: A sequence of n integers is a permutation if it contains all integers from 1 to n exactly once. For example, [1, 4, 2, 5, 3] is a permutation but [2, 3, 4, 5] is not. Given two permutations x and y , x is lexicographically smaller than y if there exists an index i where x[i] and for this smallest index j ,