Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS
What is the maximum nesting depth of parentheses in "(()(()))()"?
- A. 4
- B. 2
- C. 5
- D. 3
Correct answer: D. 3
Track the running balance and record its maximum; the deepest point comes inside the inner pair of the middle group. Counting all open brackets (last option) gives the total, not the depth.
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
- How many distinct values does floor(n / 3) take as n ranges over 1 to 20 inclusive?
- What is the sum of an = n mod 7 for n from 1 to 20 inclusive?
- From [1, 2, 2, 3, 5, 6, 6], what is the maximum number of disjoint pairs where the two values differ by at most 1?
- How many integers from 1 to 64 inclusive have a binary representation (without leading zeros) that reads the same forwards and backwards?
- What is the minimum number of characters that must be inserted anywhere in "abcb" to make it a palindrome?
- How many windows of size 4 in [1, 2, 1, 3, 4, 2, 5, 6] contain four pairwise distinct values?