Data Structures & AlgorithmsVery hardCodeforces Div2 D · ICPC regional
Consider all non-empty contiguous subarrays of [2, 7, 3, 8, 6]. For each, take its sum modulo 10. What is the largest of these residues?
- A. 26
- B. 9
- C. 8
- D. 6
Correct answer: B. 9
For each prefix P[j], look for the smallest earlier prefix residue just above P[j] mod 10; here [2, 7] gives 9, the maximum possible. Reducing the largest sum (the whole array, 26) gives only 6, and 8 is just the largest element.
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
- A robot walks from the top-left corner of a 3 × 4 grid of cells to the bottom-right corner, moving only right or down. How many such paths…
- Two lists a = [4, 9, 1, 7] and b = [3, 8, 2, 10] are paired one-to-one (any bijection). What is the minimum possible value of the sum of…
- In the sequence [1, 3, 5, 2, 4, 6], how many strictly increasing subsequences have the maximum possible length (count by index positions)?
- Consider the routine that computes the length of the longest STRICTLY increasing subsequence of [2, 2, 3, 3, 4, 4, 5] using the tails…
- How many unordered pairs of positions of the same letter are there in "abracadabra" (i < j with s[i] = s[j])?
- A Java program computes d[0] = d[1] = 1 and d[i] = d[i−1] + d[i−2] using int (32-bit two's complement, wrapping on overflow) with no…