Top Company Arrays, Strings, and Sliding Windows Python practice problems
Company-screen array and string patterns: two pointers, matrices, prefix sums, and sliding windows.
Core concepts
Problem-solving patterns
- Move boundaries while preserving a window or two-pointer invariant
Reported company tags
All 20 problems in this topic
Work from top to bottom to build the concept gradually.
- #261Maximize one stock transaction: Profitable price historyCompany MediumPremium
Find the best profit from exactly one buy followed by one later sale.
- #262Maximize one stock transaction: Falling marketCompany MediumPremium
Return zero when no later selling price exceeds an earlier buying price.
- #263Find unique three-sum triplets: Two valid tripletsCompany MediumPremium
List all unique triples whose sum is zero.
- #264Find unique three-sum triplets: No zero-sum tripleCompany MediumPremium
Report None when no three values can make zero.
- #265Maximize water between lines: Mixed container heightsCompany MediumPremium
Find the largest container area formed by two vertical lines.
- #266Maximize water between lines: Two-line minimumCompany MediumPremium
Handle the smallest valid input containing exactly two lines.
- #267Calculate trapped rain water: Classic elevation mapCompany HardPremium
Calculate total water trapped after rain across varied bars.
- #268Calculate trapped rain water: No basinCompany HardPremium
A steadily rising elevation map cannot trap water.
- #269Find the longest consecutive run: Unsorted runCompany MediumPremium
Find the length of the longest consecutive sequence without sorting.
- #270Find the longest consecutive run: Duplicates inside a runCompany MediumPremium
Ignore duplicate values while measuring a consecutive sequence.
- #271Rotate a square matrix clockwise: Three-by-three imageCompany MediumPremium
Rotate a small image matrix 90 degrees clockwise.
- #272Rotate a square matrix clockwise: Two-by-two matrixCompany MediumPremium
Verify the same in-place transformation on the smallest nontrivial square.
- #273Read a matrix in spiral order: Rectangular spiralCompany MediumPremium
Return a rectangular matrix in clockwise spiral order.
- #274Read a matrix in spiral order: Single columnCompany MediumPremium
Avoid duplicate visits when the matrix has only one column.
- #275Set matrix rows and columns to zero: One internal zeroCompany MediumPremium
Zero the complete row and column containing an original zero.
- #276Set matrix rows and columns to zero: Several original zerosCompany MediumPremium
Apply all row and column effects from multiple original zeros.
- #277Count subarrays with target sum: Repeated target sumsCompany MediumPremium
Count every contiguous subarray whose sum equals the target.
- #278Count subarrays with target sum: Include negative valuesCompany MediumPremium
Use prefix counts where a sliding window would fail because values may be negative.
- #279Find the minimum covering window: Smallest covering substringCompany HardPremium
Find the shortest source substring containing every required character with multiplicity.
- #280Find the minimum covering window: Impossible coverageCompany HardPremium
Report None when the source cannot cover the required characters.