Practice Find the Maximum Number of Elements in Subset
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Select as many occurrences from nums as possible so that they can be arranged as an odd-length sequence whose values start at some x, repeatedly square until the central value, and then retrace the preceding values in reverse order. For example, [2, 4, 16, 4, 2] is valid, but [2, 4, 8, 4, 2] is not. A single selected value is also valid. Each occurrence can be used at most as many times as it appears in nums. Return the maximum number selected.
Source: Find the Maximum Number of Elements in Subset on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
nums = [5,4,1,2,2]
3
# Example 2
nums = [1,3,2,4]
1
Constraints
Related LeetCode Problems
Practice more problems similar to Find the Maximum Number of Elements in Subset.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.