Skip to content

Latest commit

 

History

History
67 lines (58 loc) · 10.7 KB

prefix-sum.md

File metadata and controls

67 lines (58 loc) · 10.7 KB

Prefix Sum LeetCode Problems

A collection of LeetCode problems solved using Prefix Sum pattern techniques, explanations, and complexity analysis.

Problems

Easy

# Problem Language Time Space Explanation
13 Roman to Integer Python O(n) O(n) Explanation
14 Longest Common Prefix Python O(n) O(n) Explanation
744 Find Smallest Letter Greater Than Target Python O(n) O(n) Explanation
1281 Subtract the Product and Sum of Digits of an Integer Python O(n) O(n) Explanation
1365 How Many Numbers Are Smaller Than the Current Number TypeScript O(n) O(n) Explanation
1455 Check If a Word Occurs As a Prefix of Any Word in a Sentence Python O(n) O(n) Explanation
1961 Check If String Is a Prefix of Array C++ O(n) O(n) Explanation
2574 Left and Right Sum Differences Kotlin O(n) O(n) Explanation
2996 Smallest Missing Integer Greater Than Sequential Prefix Sum Rust O(n) O(n) Explanation
3042 Count Prefix and Suffix Pairs I Python O(n) O(n) Explanation
3471 Find the Largest Almost Missing Integer Kotlin O(n) O(n) Explanation
3550 Smallest Index With Digit Sum Equal to Index JavaScript O(n) O(n) Explanation
3718 Smallest Missing Multiple of K C# O(n) O(n) Explanation
4006 Count Valid Prefixes JavaScript O(n) O(n) Explanation

Medium

# Problem Language Time Space Explanation
1015 Smallest Integer Divisible by K Python O(n) O(n) Explanation
1171 Remove Zero Sum Consecutive Nodes from Linked List JavaScript O(n) O(n) Explanation
1291 Sequential Digits C++ O(n) O(n) Explanation
1621 Number of Sets of K Non-Overlapping Line Segments JavaScript O(n) O(n) Explanation
1744 Can You Eat Your Favorite Candy on Your Favorite Day? JavaScript O(n) O(n) Explanation
1871 Jump Game VII C++ O(n) O(n) Explanation
2424 Longest Uploaded Prefix JavaScript O(n) O(n) Explanation
2433 Find The Original Array of Prefix Xor Python O(n) O(n) Explanation
2453 Destroy Sequential Targets Python O(n) O(n) Explanation
2587 Rearrange Array to Maximize Prefix Score JavaScript O(n) O(n) Explanation
2640 Find the Score of All Prefixes of an Array JavaScript O(n) O(n) Explanation
2657 Find the Prefix Common Array of Two Arrays C++ O(n) O(n) Explanation
3043 Find the Length of the Longest Common Prefix C++ O(n) O(n) Explanation
3652 Best Time to Buy and Sell Stock using Strategy Python O(n) O(n) Explanation
3839 Number of Prefix Connected Groups JavaScript O(n) O(n) Explanation
3933 Largest Local Values in a Matrix II Python O(n) O(n) Explanation
3984 Divisible Game JavaScript O(n) O(n) Explanation

Hard

# Problem Language Time Space Explanation
745 Prefix and Suffix Search Python O(n) O(n) Explanation
1392 Longest Happy Prefix Python O(n) O(n) Explanation
1563 Stone Game V Java O(n) O(n) Explanation
1872 Stone Game VIII Java O(n) O(n) Explanation
2003 Smallest Missing Genetic Value in Each Subtree Python O(n) O(n) Explanation
2132 Stamping the Grid Python O(n) O(n) Explanation
2179 Count Good Triplets in an Array JavaScript O(n) O(n) Explanation
2416 Sum of Prefix Scores of Strings Python O(n) O(n) Explanation
2528 Maximize the Minimum Powered City JavaScript O(n) O(n) Explanation
3045 Count Prefix and Suffix Pairs II Python O(n) O(n) Explanation
3312 Sorted GCD Pair Queries PHP O(n) O(n) Explanation
3485 Longest Common Prefix of K Strings After Removal Python O(n) O(n) Explanation
3699 Number of ZigZag Arrays I PHP O(n) O(n) Explanation
3739 Count Subarrays With Majority Element II PHP O(n) O(n) Explanation
3762 Minimum Operations to Equalize Subarrays Python O(n) O(n) Explanation