2071. Maximum Number of Tasks You Can Assign

UMPIRE - [U]nderstand the problem, ask questions and come up with corner test cases. - [M]atch the leetcode pattern - [P]lan to using pattern template and data structures - [I]mplement the code - [R]eview by running the example and corner test cases - [E]valuate time and space complexity Understand Return max number of tasks that can be completed using the the given wokers and pills. Brute force Brute is searching searching all possiblities Check if k number of tasks can be completed and iterate k from 0 to len(tasks) Check logic would be greedy logic either you get it or not....

April 30, 2025 · 2 min · 279 words · Me

1295.Find Numbers With Even Number of Digits

UMPIRE - [U]nderstand the problem, ask questions and come up with corner test cases. - [M]atch the leetcode pattern - [P]lan to using pattern template and data structures - [I]mplement the code - [R]eview by running the example and corner test cases - [E]valuate time and space complexity Understand Find count of numbers whose digits are divisible by 2 Brute force For each number find number of digits % 2 == 0 and res += 1 Match NA...

April 29, 2025 · 1 min · 126 words · Me

2962. Count Subarrays Where Max Element Appears at Least K Times

UMPIRE - [U]nderstand the problem, ask questions and come up with corner test cases. - [M]atch the leetcode pattern - [P]lan to using pattern template and data structures - [I]mplement the code - [R]eview by running the example and corner test cases - [E]valuate time and space complexity Understand return number of sub arrays that max element atleast k times Brute force Generate all sub arrays, count mx element. O(n^2) Match Sliding window Grow till max_cnt equals k Plan Grow till max_cnt equals k say i Once k then all the sub arrays that end with i+1, i+2 ....

April 28, 2025 · 2 min · 247 words · Me

2302. Count Subarrays With Score Less Than K

UMPIRE - [U]nderstand the problem, ask questions and come up with corner test cases. - [M]atch the leetcode pattern - [P]lan to using pattern template and data structures - [I]mplement the code - [R]eview by running the example and corner test cases - [E]valuate time and space complexity Understand Return number of sub arrays whose sum * len < k Brute force Generate all subarrays. O(n^2) Match Sliding window Shrink while s * l >= k, grow otherwise Plan For every ith idx if sum(nums[:i]) * len(nums[:i]) < k then we increase the result by (right - left + 1)....

April 27, 2025 · 1 min · 189 words · Me

3392. Count Subarrays of Length Three With a Condition

UMPIRE - [U]nderstand the problem, ask questions and come up with corner test cases. - [M]atch the leetcode pattern - [P]lan to using pattern template and data structures - [I]mplement the code - [R]eview by running the example and corner test cases - [E]valuate time and space complexity Understand Return number of length 3 sub arrays whose nums[1]/2 == nums[0] + nums[2] Brute force We can generate all sub arrays of length 3 O(n^2)....

April 26, 2025 · 1 min · 143 words · Me

2444. Count Subarrays With Fixed Bounds

UMPIRE - [U]nderstand the problem, ask questions and come up with corner test cases. - [M]atch the leetcode pattern - [P]lan to using pattern template and data structures - [I]mplement the code - [R]eview by running the example and corner test cases - [E]valuate time and space complexity Understand Need to count subarrays where min = minK and max = maxK Brute force Generate all sub arrays, track min and max Time complexity O(n^2) fails for constraint n = 10^5 Match Sliding window?...

April 25, 2025 · 2 min · 366 words · Me

2845. Count of Interesting Subarrays

UMPIRE - [U]nderstand the problem, ask questions and come up with corner test cases. - [M]atch the leetcode pattern - [P]lan to using pattern template and data structures - [I]mplement the code - [R]eview by running the example and corner test cases - [E]valuate time and space complexity Understand Need to count subarrays where cnt is number of element such that nums[i] % modulo == k and cnt % modulo == k Brute force Generate all sub arrays, calculate cnt and verify cnt % modulo == k....

April 24, 2025 · 3 min · 427 words · Me

2799. Count Complete Subarrays in an Array

UMPIRE - [U]nderstand the problem, ask questions and come up with corner test cases. - [M]atch the leetcode pattern - [P]lan to using pattern template and data structures - [I]mplement the code - [R]eview by running the example and corner test cases - [E]valuate time and space complexity Understand Need to count the sub arrays the have same number of distinct elements as the array For [1,3,1,2,2] Subarrays starting with index 0 and 3 distinct elements [1, 3, 1, 2] ad [1, 3, 1, 2, 2] Subarrays starting with index 1 and 3 distinct elements [3, 1, 2] ad [3, 1, 2, 2] Total 4 Brute force Generate all sub arrays and also maintain distinct count Time complexity O(n^2) it passes for given constraints def countCompleteSubarrays(self, nums: List[int]) -> int: arr_distinct = len(set(nums)) res = 0 for i in range(len(nums)): sub = set() for j in range(i, len(nums)): sub....

April 23, 2025 · 2 min · 286 words · Me