Week 2 | Day 1
Goal
560. Subarray Sum Equals K (x7)
Variation
Non-negative # using sliding window.
301. Remove Invalid Parentheses (X8)
Return only one solution
621 Task Scheduler (x2)
Variation (English):
- Task's order is fixed, find the last task finished time
- What if Tasks' quantities are way larger than the cooldown time (Scan Task)
- What if the cooldown time is way larger than the tasks' quantities (Queue + Sliding Window)
Variation (Chinese):
给的是task顺利固定,要求最后一个task完成的时间。用hashmap记录一下上一个相同task的完成时间,然后和cool down time比较一下就可以了。follow up是更加优化一下空间,我说的是如果一个task执行完之后,时间过了cool down time就可以把它从map里面remove掉了,没有要写出来。每一题都问了复杂度。
近期高频,两个follow up:
task个数远大与cooldown ===》 scan task
cooldown远大与task个数 ===》 queue with sliding window
Week 2 | Day 1
Goal
560. Subarray Sum Equals K (x7)
301. Remove Invalid Parentheses (X8)
621 Task Scheduler (x2)