Browse 16 notes tagged algorithms.
My two-pointer solution, with a brute-force comparison, a proof for discarding the shorter side, and executable checks for O(n) time and O(1) extra space.
Keep the submitted cleaned-string solution, then explain an in-place charCodeAt-based two-pointer alternative.
Keep the submitted frequency-counting sliding-window solution and explain why maxFreq can retain its historical maximum.
Keep an initial reset-and-rescan attempt, explain its O(n²) limit, then use a one-pass Map sliding window.
Work through a sorting-based Group Anagrams solution, its repeated-array-copy cost, and a count signature for the fixed lowercase alphabet.
Start with Map frequency counting and sorting, then remove the O(n log n) sort with frequency buckets.
Compare sorting, Map-based frequency differences, and a fixed-size count array for Valid Anagram, including correctness, invariants, and complexity.
Replace nested pair checks with a Map of earlier values and indices, then explain complement lookup, the loop invariant, and expected O(n) time.
Compare a Set's size with the array length, or stop early during one scan, while explaining the Set solution's correctness and expected O(n) complexity.
Replace nested transaction checks with one scan that tracks the lowest purchase price, including the correctness argument for a two-pointer solution and its O(n) cost.
Compare stored left and right sums with a single scan, including output space, auxiliary space, and the loop invariant.
Find the leftmost pivot index with a total sum and one running left sum, then make the loop invariant and O(n) analysis explicit.
Track current altitude and the highest altitude so far in one scan with O(n) time and O(1) auxiliary space.
Use each completed array position as state for one linear scan, with an honest discussion of in-place mutation, the loop invariant, and O(n) time.
Move from sorting to a Set, expand only sequence starts, and give a rigorous expected O(n) analysis for the longest consecutive sequence problem.
Derive a TypeScript merge-intervals solution through sorting, one linear scan, input immutability, and an honest O(n log n) complexity analysis.
Google services settings
Analytics and advertising stay off until you choose.