Data Structures & AlgorithmsVery hardCodeforces Div2 D · ICPC regional
The binary matrix [[1, 0, 1, 1, 0], [1, 1, 1, 1, 0], [1, 1, 1, 1, 1], [1, 0, 0, 1, 0]] is given. What is the area of the largest rectangle consisting only of 1s?
- A. 4
- B. 6
- C. 8
- D. 14
Correct answer: C. 8
Turn each row into a histogram of consecutive 1s above it, then apply the histogram-rectangle stack to each row. The largest square of ones is a different (usually smaller) quantity.
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
- Using the same kind of binary matrix, [[1, 0, 1, 0, 0], [1, 0, 1, 1, 1], [1, 1, 1, 1, 1], [1, 0, 0, 1, 0]], what is the area of the…
- How many permutations of {1, 2, 3, 4, 5} can be sorted into increasing order by a single stack, when the input is read left to right and…
- Repeatedly delete any two adjacent equal letters in "abbacddcaeeaf" until no such pair remains. What is the length of the final string?
- What is the length of the longest well-formed (valid) parentheses substring of "()(()())))(()"?
- What is the minimum number of parentheses that must be ADDED (at any positions) to make "())(()))((" a valid parentheses string?
- For daily temperatures [73, 74, 75, 71, 69, 72, 76, 73], the wait for day i is the number of days until a strictly warmer day (0 if none)…