Data Structures & AlgorithmsModerateTCS NQT Digital · Accenture
Problem: The array [1, 4, 6, 3, 8, 2] is processed by a single pass that tracks the maximum so far. How many elements are records (strictly greater than all earlier elements)?
- A. 5
- B. 4
- C. 3
- D. 6
Correct answer: B. 4
The records are 1, 4, 6 and 8, the elements that exceed everything before them.
More Coding Interview Problems questions
- Problem: A set of 10 people is divided into 5 pairs. How many distinct ways are there to form these pairs (unordered pairs, unordered…
- Problem: In the array [5, 8, 3, 7, 2], find the second-largest element.
- Problem: A tree with 5 nodes is given by the parent array p = [−1, 0, 0, 1, 1] (node 0 is the root). How many leaves does it have?
- Problem: The bit pattern 10110 is shifted left by 2 positions and then XOR-ed with the original pattern. What is the decimal value of the…
- Problem: Vertices 0–4 have undirected edges 0-1 (3), 1-2 (1), 2-3 (4), 3-4 (2), 0-4 (6), 1-4 (5). A path's cost is the sum of its edge…
- Problem: A directed graph has vertices 0–3 with arcs 0→1, 1→2, 2→1, 2→3. Using DFS from vertex 0 with children visited in increasing…