1626. Best Team With No Conflicts

DP with age limit class Solution: def bestTeamScore(self, scores: List[int], ages: List[int]) -> int: """tc O(N^2) sc O(N) main idea: LIS dp[i]: max total scores by sorted ages[i] 1. sort age,score pair by age 2. at any age[i], find age[j] where score[j] <= score[i] and j < i 3. update... [Read More]
Tags: Array DP Sorting

560. Subarray Sum Equals K

class Solution: def subarraySum(self, A: List[int], k: int) -> int: """tc O(N) sc O(N) main idea: two sum + prefix sum (psum[i] - psum[j-1] = k => psum[i] - k = psum[j-1], where j < i => count occurance of psum by far and check number of time that psum[i]... [Read More]