Data Structures & AlgorithmsModerateTCS NQT · Infosys
Problem: Consider the array [3, 7, 4, 9, 2, 8, 5]. Two selection rounds are performed: first pick the largest value and remove it, then pick the largest of the remaining values and remove it. What is the sum of the two removed values?
- A. 10
- B. 24
- C. 11
- D. 17
Correct answer: D. 17
The two largest are 9 and 8, so 17. Summing the first two elements gives 10, three rounds give 24, and 9 + 2 adds the largest and smallest.
More Coding Interview Problems questions
- Problem: Dictionary: a list of words is ["cat", "dog", "bat", "dig"]. Words are grouped by changing exactly one letter (Hamming distance…
- Problem: Starting at (0,0), a robot moves on an infinite grid using the string "UURDDLLUR" (U = up, D = down, L = left, R = right). The…
- Problem: The set S = {1, 2, 3, …, 30} is considered. How many integers in S are NOT divisible by 2, 3 or 5?
- Problem: A binary search over the sorted array [1, 3, 5, 7, 9, 11, 13, 15, 17, 19] looks for the value 12 which is absent. Using the…
- Problem: The 10 numbers 1 to 10 are split into two groups of five. The sum of the group containing 10 is S. How many different values of S…
- Problem: In a directed acyclic graph with arcs 0→1, 0→2, 1→3, 2→3, 3→4, 2→4, how many distinct topological orders exist?