Maximum Average Subarray I - Leetcode 643 - Fixed Sliding Window (Python)

Поделиться
HTML-код
  • Опубликовано: 28 янв 2025

Комментарии • 11

  • @GregHogg
    @GregHogg  6 месяцев назад +1

    Master Data Structures & Algorithms For FREE at AlgoMap.io!

  • @maralazizi
    @maralazizi 7 месяцев назад

    Thank you so much for a clear explanation!

  • @IsaacMiranda-dd4fi
    @IsaacMiranda-dd4fi 8 месяцев назад +1

    great video! Helped me out a lot.

  • @moeinhasani8718
    @moeinhasani8718 7 месяцев назад

    thanks man that was helpful!

  • @НикитаБуров-ъ6р
    @НикитаБуров-ъ6р 7 месяцев назад +5

    you shouldn't use '/' each step, i'd better return only final res as 'max_sum / k'

    • @hyperboliq
      @hyperboliq 4 месяца назад

      Why would it be bad to use "/" on each step?

    • @lorenzospizzuoco6434
      @lorenzospizzuoco6434 4 месяца назад

      @@hyperboliq It's not "bad", by dividing only when returning the response, you speed up a bit the solution. Performing x (number of iterations) divisions costs more then performing just one

    • @hyperboliq
      @hyperboliq 4 месяца назад

      @@lorenzospizzuoco6434 I see

  • @achyuthvishwamithra
    @achyuthvishwamithra Месяц назад

    You don't have to calculate average at each step, instead compare sums, and only at the end return the average.

  • @josephif
    @josephif 4 месяца назад +2

    I did this question but leet code says 121 testcase paassed out of 127

    • @Pillow-n8w
      @Pillow-n8w 2 месяца назад

      For me it fails on test 116/127. On array [0, 1, 1, 3, 3] with k = 4, i return 2, but site for some unknown to me reason wants 1.25.