307. Range Sum Query - Mutable - Day 31/31 Leetcode July Challenge

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

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

  • @Algorithmist
    @Algorithmist  2 ปีที่แล้ว +2

    How did you deal with the range?

    • @tsogoobayartsogt5653
      @tsogoobayartsogt5653 2 ปีที่แล้ว +1

      I tried the bucketing by value since it is in [-100, 100] and used SortedList but got TLE... I was thinking it is enough since update is O(logn) and sumRange is O(200 * logn)

  • @gouravkumarshaw5467
    @gouravkumarshaw5467 2 ปีที่แล้ว +2

    Thank you!!

  • @UmeshMalik0
    @UmeshMalik0 2 ปีที่แล้ว

    Hi Larry, I tried very basic approch in this question that I am initialing array, sum of whole array and then in update making change in array on that index and also changing sum according to new value and in getSum , just minus sum of array (0, left) + array (right+1, Len array) and it was 98 % faster in python submission and memory was around 80% better, can you explain why??

    • @nhbknhb
      @nhbknhb 2 ปีที่แล้ว

      Submissions score can be random