Data Structures & AlgorithmsVery hardCodeforces Div2 B-D · ICPC regional
With 1-based indexing, what is the sum of i times a[i] for a = [2, 0, 3, 1]?
- A. 15
- B. 9
- C. 12
- D. 17
Correct answer: A. 15
With 1-based indices the weights are 1, 2, 3, 4, giving 2 + 0 + 9 + 4 = 15. Using 0-based indices (the first option) changes every weight.
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
- For [1, 0, 1, 1, 0, 1, 0, 1], consider windows of length 4. In each window you may flip at most one 0 to 1. What is the largest number of…
- Over all windows of size 3 in [4, 8, 2, 7, 5, 9], what is the smallest value of (window max minus window min)?
- How many index pairs i < j of length-2 substrings of "ababa" are equal strings?
- What is the smallest positive integer x such that floor(x/2) + floor(x/3) is at least 10?
- In [3, 8, 1, 8, 5], you move the rightmost occurrence of the maximum to the last position using adjacent swaps. How many adjacent swaps…
- How many unordered pairs of distinct words in ["abc", "aba", "cdc", "xyz", "axa", "cd"] share both the same first letter and the same last…