Longest Square Streak in an Array | Leetcode 2501

แชร์
ฝัง
  • เผยแพร่เมื่อ 27 ต.ค. 2024

ความคิดเห็น • 13

  • @neelakshigupta7587
    @neelakshigupta7587 7 ชั่วโมงที่ผ่านมา +5

    Coming to this channel and watching his approach of daily lc qn is like a like a daily religious routine now

    • @techdose4u
      @techdose4u  3 ชั่วโมงที่ผ่านมา +1

      religious! :)

  • @sailendrachettri8521
    @sailendrachettri8521 5 ชั่วโมงที่ผ่านมา +1

    Thank you for daily updates :)

    • @techdose4u
      @techdose4u  3 ชั่วโมงที่ผ่านมา

      Happy to help! :)

  • @kheersagarpatel3195
    @kheersagarpatel3195 16 นาทีที่ผ่านมา +1

    sir whats the secret of your success in DSA?

  • @taskeen_fatimaa
    @taskeen_fatimaa 4 ชั่วโมงที่ผ่านมา

    Thankyou sir

    • @techdose4u
      @techdose4u  3 ชั่วโมงที่ผ่านมา

      welcome :)

  • @madhuyagadasu
    @madhuyagadasu ชั่วโมงที่ผ่านมา

    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

    • @techdose4u
      @techdose4u  ชั่วโมงที่ผ่านมา

      nice

  • @4nuragKr
    @4nuragKr ชั่วโมงที่ผ่านมา

    why 2d dp failing?

    • @techdose4u
      @techdose4u  34 นาทีที่ผ่านมา

      what are the dimensions you took ?

  • @aakashyadav8142
    @aakashyadav8142 6 ชั่วโมงที่ผ่านมา +2

    what about of your program?

    • @techdose4u
      @techdose4u  3 ชั่วโมงที่ผ่านมา

      which program?