← All problemsSign in

2501. Longest Square Streak in an Array

LeetCodeArrayHash TableBinary SearchDynamic ProgrammingSortingOpen on judge ↗

You are given an integer array nums. A subsequence of nums is called a square streak if: - The length of the subsequence is at least 2, and - after sorting the subsequence, each element (except the first element) is the square of the previous number. Return the length of the longest square streak in nums, or return -1 if there is no square streak. A subsequence is an array that can be derived

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.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start