Practice Longest Square Streak in an Array
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Medium#2501
LeetCode ProblemLongest Square Streak in an Array
Problem Statement
Choose at least two entries from nums and sort the chosen values. They form a square streak if every value after the first equals the square of its immediate predecessor. Return the maximum streak length, or -1 if none exists.
Source: Longest Square Streak in an Array on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
nums = [4,3,6,16,8,2]
Output
3
# Example 2
Input
nums = [2,3,5,6,7]
Output
-1
Constraints
2 <= nums.length <= 10^5
2 <= nums[i] <= 10^5
Related LeetCode Problems
Practice more problems similar to Longest Square Streak in an Array.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.