前缀计数
把 0/1 记录直接做前缀和,s[i] 表示前 i 天打卡总数,区间内打卡数为 s[r]-s[l-1]。
时间复杂度 O(n+q)O(n+q)O(n+q),空间复杂度 O(n)O(n)O(n)。
使用您的 星源智一OJ 通用账户