Search
⌘K
Get Premium
Leetcode 2501. Longest Square Streak in an Array
Find the maximum length (≥2) subsequence of nums whose elements, when sorted, form a chain a, a^2, a^4, ... (each element is the square of the previous); return -1 if no such subsequence exists. The challenge is to match values to their squared successors while respecting original index order efficiently for n up to 1e5.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.