Data Structures & AlgorithmsModerateICPC regional · Amazon SDE OA
What is the minimum absolute difference between two distinct elements of [12, 5, 9, 1, 15, 7]?
- A. 3
- B. 1
- C. 2
- D. 14
Correct answer: C. 2
After sorting, the closest values are adjacent: the gaps 5-7 and 7-9 are both 2, and no gap is smaller.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- How many distinct characters occur at least twice in "programming"?
- With 1-based indexing, what is the sum of i times a[i] for a = [2, 0, 3, 1]?
- For [1, 0, 1, 1, 0, 1, 0, 1], consider windows of length 4. In each window you may flip at most one 0 to 1. What is the largest number of…
- Over all windows of size 3 in [4, 8, 2, 7, 5, 9], what is the smallest value of (window max minus window min)?
- How many index pairs i < j of length-2 substrings of "ababa" are equal strings?
- What is the smallest positive integer x such that floor(x/2) + floor(x/3) is at least 10?