Space for hash map can be saved using binary search for every iterative square number. For a streak starting with 2, search for 2, 4, 16.
@Axel.Blazer18 күн бұрын
yes class Solution: def longestSquareStreak(self, nums: List[int]) -> int: nums = set(nums) streak = -1 for num in sorted(nums): cur = 1 nxt = num * num while nxt in nums: cur += 1 nxt = nxt * nxt if cur >= 2: streak = max(streak, cur) return streak if streak!=1 else -1
@algorithmsbyaditi18 күн бұрын
Great work
@harishbehera781218 күн бұрын
thanx for the video. Radhe Radhe
@algorithmsbyaditi18 күн бұрын
Glad it was helpful !
@Sumanth280318 күн бұрын
nice explanation. Radhe Radhe
@algorithmsbyaditi18 күн бұрын
Thank you
@KedarBhawthankar18 күн бұрын
nice explaination
@algorithmsbyaditi18 күн бұрын
Thank you
@rahulsingh-sc1hg18 күн бұрын
Hello Ma'am I am beginner in DSA, Would you create a playlist for beginners? Thank you.
@algorithmsbyaditi18 күн бұрын
Will try soon, Thanks.
@kthamim755218 күн бұрын
post a video in english also mam
@chad._life18 күн бұрын
nice efforts but you could do much better if you invest some more energy and time