simple code implementation in python from typing import * class Solution: def longestSquareStreak(self, nums: List[int]) -> int: nums = set(nums) already_checked_numbers=set() long_streak_count=1 for each_num in nums: if each_num >= 65536 or each_num in already_checked_numbers: continue present_num=each_num default_count=1 for _ in range(5): if present_num**2 in nums: present_num*=present_num already_checked_numbers.add(present_num) default_count+=1 else: break long_streak_count=max(long_streak_count,default_count) if long_streak_count==5: return 5 if long_streak_count==1: return -1 else: return long_streak_count
Coming to this channel and watching his approach of daily lc qn is like a like a daily religious routine now
religious! :)
Thank you for daily updates :)
Happy to help! :)
sir whats the secret of your success in DSA?
Thankyou sir
welcome :)
simple code implementation in python
from typing import *
class Solution:
def longestSquareStreak(self, nums: List[int]) -> int:
nums = set(nums)
already_checked_numbers=set()
long_streak_count=1
for each_num in nums:
if each_num >= 65536 or each_num in already_checked_numbers:
continue
present_num=each_num
default_count=1
for _ in range(5):
if present_num**2 in nums:
present_num*=present_num
already_checked_numbers.add(present_num)
default_count+=1
else:
break
long_streak_count=max(long_streak_count,default_count)
if long_streak_count==5:
return 5
if long_streak_count==1:
return -1
else:
return long_streak_count
nice
why 2d dp failing?
what are the dimensions you took ?
what about of your program?
which program?