Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS
Items [1, 1, 1, 1, 2, 2, 3] must be placed into stacks of capacity 3 such that each stack holds only identical items. What is the minimum number of stacks?
- A. 5
- B. 3
- C. 2
- D. 4
Correct answer: D. 4
Group identical values; each value with count c needs ceil(c / 3) stacks. Here value 1 needs 2, value 2 needs 1 and value 3 needs 1, totalling 4.
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 index pairs i < j in [0, 1, 2, 3, 4] satisfy a[i] + a[j] = a[i] a[j]?
- Repeatedly remove adjacent equal characters from "abbaca" using a stack. How many characters are removed in total?
- How many integers n from 1 to 99 inclusive have both n and n + 1 squarefree (not divisible by any square greater than 1)?
- Choose the fewest intervals of length 3 (covering integer points s, s+1, s+2 for a start s from 1 to 8) so that every integer point from 1…
- How many integers x with 1 ≤ x ≤ 2024 have NO two equal adjacent digits in their decimal representation?
- How many integers x with 1 ≤ x ≤ 500 have a decimal digit sum divisible by 3?