12Solve 'longest substring without repeating characters' and explain the sliding-window / two-pointer pattern.▼medium★ EssentialMetaAmazonGoogle1 replies○ sign inSliding window is one of the highest-yield coding patterns, and this is its canonical problem. The real signal is recognizing when a window collapses an O(n squared) scan into one linear pass, and maintaining the invariant cleanly.Open full answer →
25Validate balanced parentheses/brackets, and explain the stack pattern.▼easy★ EssentialGoogleMetaAmazon2 replies◆ premiumA warm-up that screens for the stack instinct. The signal is recognizing last-opened-first-closed maps to a stack, and handling the edge cases (leftover opens, early close). Here is the pattern.Open full answer →
33Edit distance (Levenshtein): the 2D dynamic programming pattern.▼hardGoogleMetaAmazon1 replies◆ premiumEdit distance is the canonical 2D string DP, behind spell-check, diff, and fuzzy matching. The signal is defining the subproblem and the insert/delete/replace recurrence. Here is the answer.Open full answer →
39Word Break: can a string be segmented into dictionary words?▼mediumGoogleMetaAmazon1 replies◆ premiumWord Break is the classic 1D string DP that trips people who reach for greedy or naive recursion. The signal is the dp[i] = 'is the prefix of length i segmentable' recurrence, plus why a locally valid split can doom the rest. Here is the answer.Open full answer →
45Longest Common Subsequence (LCS) and the 2D DP family.▼mediumGoogleMetaAmazon1 replies◆ premiumLCS is the template 2D-sequence DP behind diff tools and bioinformatics. The signal is reconstructing the match/mismatch recurrence cold and not confusing subsequence (gaps allowed) with substring (contiguous). Here is the answer.Open full answer →
49Minimum Window Substring: the variable-size sliding window.▼hardGoogleMetaAmazon1 replies◆ premiumMinimum Window Substring is the hard sliding-window problem that tests expand-and-contract with a character-count map. The signal is the grow-to-valid then shrink-to-minimal pattern, checked in O(1) per step.Open full answer →
51Group Anagrams: the canonical-key hash-map pattern.▼mediumGoogleMetaAmazon2 replies◆ premiumGroup Anagrams tests the 'compute a canonical key and bucket by it' pattern. The signal is choosing a key that anagrams share without comparing every pair. Here is the answer.Open full answer →
58Decode Ways: count the decodings of a digit string (1D DP).▼mediumGoogleMetaAmazon1 replies◆ premiumDecode Ways is a 1D DP whose difficulty lives entirely in the edge cases: zeros and the valid 1-26 range. The signal is the take-one-digit-or-two recurrence plus disciplined validity checks. Here is the answer.Open full answer →
59Longest Palindromic Substring (expand around center).▼mediumGoogleMetaAmazon2 replies◆ premiumThis classic has a clean O(n^2) expand-around-center solution that beats the naive O(n^3). The signal is expanding from every center and handling odd and even lengths separately. Here is the answer.Open full answer →
90Generate all valid combinations of n pairs of parentheses.▼mediumGoogleMetaAmazon1 replies◆ premiumGenerating then filtering is O(2^(2n)) and wasteful. Backtracking with two counters builds only valid strings by enforcing the balance rule at every step. Here is the template and why the pruning conditions are exactly right.Open full answer →
94Implement a basic calculator that evaluates a string with +, -, *, /, and parentheses.▼hardGoogleMetaAmazon2 replies◆ premiumEvaluating arithmetic with precedence and nested parentheses is a parsing problem, and a stack handles both cleanly. The traps are operator precedence, multi-digit numbers, and the sign of truncated division. Here is a single-pass solution.Open full answer →