Data Structures & AlgorithmsModerateCodeforces Div2 B-D · ICPC regional
What is the lexicographically largest substring of length 2 in "zebraqzyx"?
- A. zy
- B. zb
- C. ze
- D. zr
Correct answer: A. zy
Compare all length-2 substrings lexicographically; the largest is the one with the greatest first character, then the greatest second. Comparing character codes of single letters only is a different question.
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
- Numbers 1 to 5 are pushed in order onto a stack, and pops are interleaved so that the output is 4, 3, 5, 2, 1. How many pops are performed…
- How many pairs (i, j) with 1 <= i < j <= 12 have a product i j that is a perfect square?
- Nodes 0 to 10 form a linked structure where each node i points to node (2i + 1) mod 11. Starting at node 0, how many distinct nodes lie on…
- Tasks are (duration, deadline): (4, 2), (2, 1), (3, 2), (1, 1), (5, 3), and a single machine runs them one at a time from time 0. What is…
- What is the sum of gcd(a, b) over all unordered pairs of distinct elements of [6, 10, 15]?
- How many contiguous subarrays of [2, 4, 2, 1, 3] have a sum exactly equal to twice their maximum?