Data Structures & AlgorithmsHardCodeforces Div2 B-D · ICPC regional
What is the length of the longest run of equal consecutive values in [5, 5, 5, 6, 6, 5, 5, 5, 5]?
- A. 4
- B. 5
- C. 3
- D. 6
Correct answer: A. 4
Scan once, resetting the run count when the value changes. The run of four 5s at the end is longer than the opening run of three.
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 length-2 substrings of "abbaabab" are either "ab" or "ba"?
- From task sizes [4, 5, 6, 3], what is the largest number of tasks you can keep so that their total size is at most 10?
- How many subsets (including the empty set, but counting each subset once) of [1, 2, 3, 4] have element sum equal to 5?
- Convert (a+b)c/(d-e) to postfix with the shunting-yard algorithm (+ and - lowest, then and /, all left-associative). What is the postfix…
- Evaluate the postfix expression 2 3 1 + 9 -. What is the result?
- Three sorted lists [1, 4, 7], [2, 5, 8] and [3, 6, 9] are merged into one sorted list. What is the value at position 5 (1-based)?