Frequency Queries

  • + 1 comment

    Why do you do

    cnt[freq[value]] -= 1
    

    and

    cnt[freq[value]] +=1
    

    before and after actions 1 and 2? Why do they not cancel out?