Cardinality
CodeChefOpen on judge ↗
You have a set of unique numbers. You are trying to find a subset of this set such that no two numbers in the subset have a common digit. There will of course be several such subsets. You are interested in the subset with the maximum sum. The sum of a subset is defined as the sum of the numbers in the subset. In fact, you are most interested in the cardinality - that is, the number of elements -
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start