Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS
How many subsets (including the empty set, but counting each subset once) of [1, 2, 3, 4] have element sum equal to 5?
- A. 3
- B. 1
- C. 4
- D. 2
Correct answer: D. 2
Only {1, 4} and {2, 3} sum to 5; no other subset of [1, 2, 3, 4] does.
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
- 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)?
- A list holds 1, 2, 3, 4, 5. It is rotated right by 2 positions (the last two nodes move to the front). What is the value of the new head…
- How many pairs x < y with 1 <= x, y <= 12 have (x + y) dividing x y exactly?
- How many distinct values does floor(30 / k) take as k ranges over 1 to 30?