Minimum Amount of time to Brew Potion
Problem /* Let start[j] denote the time at which potion j starts at wizard 0. Because each potion...
Tag archive
Problem /* Let start[j] denote the time at which potion j starts at wizard 0. Because each potion...
Prefix sum: involves storing sum/product upto each index for quick access/lookup for range...
You memorized the formula but indices, initialization, and negatives still trip you up. Here are the top traps and fixes.
Learn how prefix sums simplify subarray questions, when to pair them with hash maps, and the exact steps to avoid off-by-one mistakes during interv...
Discovering prefix sums is one of those moments where you go aha! It’s staggering how...
Prefix sums turn many O(n²) subarray problems into clean O(n) solutions. Learn the intuition, common patterns, and mistakes LeetCode beginners make...
Problem TC: O(n) SC: O(n) class Solution { public long gridGame(int[][] grid) { long...
Problem TC: O(n) SC:O(n) class Solution { public int subarraySum(int[] nums) { int...
Problem Statement: Count Stars Between Pipes Problem Description You are given...
Problem TC: O(n) for calculating prefix sum, and O(n) for iterating over the prefix sum for...
Problem TC: O(n) for calculating the prefix sum and O(1) for getting the sum of the subarray in the...
Problem TC: O(n) for calculating the prefix[] and O(k) for getting all the counts of the vowels in...