Amazon
More Experiences
Amazon OA SDE 2
October 31, 2025 • 51 reads
Summary
Attempted Amazon OA SDE 2 with a problem requiring finding the lexicographically smallest sequence meeting specific sum and permutation criteria.
Full Experience
given two integer size and target sum return the lexicography smallest sequence such that
1. the sum of its element equal to target sum
2. the absolute value of its element form permutation of size size
Example:
size=5, target_sum=9
ans=[-3,1,2,4,5]
Interview Questions (1)
Q1
Lexicographically Smallest Sequence with Sum and Permutation Constraints
Data Structures & AlgorithmsHard
Given two integers, size and target sum, return the lexicographically smallest sequence such that:
1. The sum of its elements equals the target sum.
2. The absolute values of its elements form a permutation of size size.