Amazon OA SDE 2

amazon logo
amazon
SDE 2nullOngoing
October 31, 202551 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.

Discussion (0)

Share your thoughts and ask questions

Join the Discussion

Sign in with Google to share your thoughts and ask questions

No comments yet

Be the first to share your thoughts and start the discussion!