Data Structures & AlgorithmsHardCodeforces Div2 D · bitset DP
Problem: What is the time complexity of subset-sum over n items with a bitset of width W (up to 10^5)?
- A. O(2^n)
- B. O(W^2)
- C. O(n * W / 64)
- D. O(n^2 log W)
Correct answer: C. O(n * W / 64)
Each item shifts and ORs a W-bit bitset in W/64 word operations.
More Coding Interview Problems questions
- Problem: What is the purpose of the low-link value in Tarjan's strongly connected components algorithm?
- Problem: What is the worst-case complexity of the SPFA (queue-based Bellman-Ford) shortest path algorithm?
- Problem: Which property must hold for Huffman coding to produce an optimal prefix code?
- Problem: What is the complexity of Kruskal's algorithm when edges are already sorted and union-find uses path compression and union by rank?
- Problem: What does the Kuhn-Munkres (Hungarian) algorithm compute on a bipartite graph with weights?
- Problem: Which approach computes the number of distinct substrings of a string of length n in O(n log n) with a suffix array?