Data Structures & AlgorithmsVery hardICPC regional · Amazon SDE OA
Remove exactly two elements from [4, 1, 5, 2, 3] to maximise the sum of what remains. What is the maximum remaining sum?
- A. 13
- B. 11
- C. 12
- D. 15
Correct answer: C. 12
The best choice removes the two smallest values, 1 and 2, leaving 4 + 5 + 3 = 12. Removing the largest values is the opposite choice.
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 two-character substrings occur in "mississippi"?
- Perform two operations on [8, 5, 3, 9]: each operation takes the current largest value x and replaces it with floor(x / 2). What is the…
- How many integers n with 1 <= n <= 1000 have n^2 divisible by 36?
- How many palindromic substrings of length at least 2 occur in "aaa" (counted by position)?
- Weights [2, 3, 3, 4, 1, 2] are packed into boxes of capacity 5 by first-fit decreasing. How many boxes are used?
- For an array of length 5 indexed 0 to 4, how many contiguous subarrays contain index 2?