Data Structures & AlgorithmsHardICPC regional · Product Company SDE
Problem: In a directed graph with arcs 0→1, 1→2, 2→0, 2→3, 3→4, 4→3, the strongly connected components are formed. What is the size of the largest strongly connected component?
- A. 4
- B. 3
- C. 2
- D. 5
Correct answer: B. 3
Two vertices share a strongly connected component when each can reach the other. The cycle 0-1-2 forms one component of size three, and 3 and 4 form a separate component.
More Coding Interview Problems questions
- Problem: The tree with edges 1-2, 1-3, 2-4, 2-5, 3-6, 6-7, 6-8 is rooted at node 1. How many nodes have exactly two neighbours (degree 2)…
- Problem: How many occurrences of the substring "ana" are in "bananarama" (overlapping occurrences count)?
- Problem: How many distinct strings formed by permuting the letters of "aab" are palindromes?
- Problem: Find the length of the shortest substring of "bbaac" that contains both letters 'a' and 'b' at least once.
- Problem: What is the length of the longest substring of "aabbcbbcc" in which every character occurs at least twice?
- Problem: In how many ways can 15 be written as a sum of distinct odd positive integers (order does not matter)?