Interview questions
Find a company or topic. Read the sources, then practice.
Loading the question library…
Find a company or topic. Read the sources, then practice.
Loading the question library…
Showing 2,926–2,950
Find the longest subsequence of a binary string s whose interpreted integer value is ≤ k. The core challenge is maximizing length by exploiting free…
General practice
Partition a string into the maximum number of non-empty contiguous chunks such that the sequence of chunks is symmetric (chunk i equals chunk k−i+1 for…
General practice
Given an array of strings, you may remove at most one string — choose the removal (or none) that yields the longest common prefix among…
General practice
For each index i, remove words[i] and return the length of the longest common prefix among all adjacent pairs in the remaining array (0 if…
General practice
For each index i, compute the maximum length L such that some prefix of length L appears in at least k strings (counting duplicates) among…
General practice
Given m integer paths over cities 0..n-1, find the maximum length L such that every path contains some contiguous subarray of length L; this is…
General practice
Find the length of the longest sequence of characters that appears in both input strings in the same relative order (not necessarily contiguous). This is…
Companies: Apple
Dynamic Programming · Longest Common Subsequence · String
Find the longest sequence of values that appears in both sorted arrays in order (respecting duplicates), i.e., the longest common subsequence between two sorted sequences…
General practice
Find the length of the longest contiguous (continuous) strictly increasing subarray in a given integer array. This is typically solved by a single-pass/sweeping-window scan…
General practice
Find the longest contiguous subarray that starts with an even number, has all elements <= threshold, and whose adjacent elements strictly alternate parity; return its…
General practice
Given a string s (|s| ≤ 10^5), return the longest non-empty proper prefix that is also a suffix (i.e., the longest "border") of s. This…
General practice
Construct the longest possible string using up to a, b, and c occurrences of letters 'a', 'b', and 'c' such that it never contains "aaa"…
General practice
Find the length of the longest subsequence whose elements differ by exactly 1 (i.e., all elements are either x or x+1 for some x). This…
General practice
Given an array of integers, return the length of the longest strictly increasing subsequence; the core challenge is to compute this efficiently—naive DP is O(n^2)…
Companies: PayPal
Array · Binary Search · Dynamic Programming · Longest Increasing Subsequence
Given a binary matrix, return the length of the longest consecutive line of 1s appearing horizontally, vertically, diagonally, or anti-diagonally. Typical solutions scan the…
General practice
Find the maximum length of a contiguous subarray in which the bitwise AND of every pair of distinct elements is 0 — equivalently, no two…
General practice
Find the longest substring of s such that for every letter appearing in that substring, both its lowercase and uppercase forms also appear; if multiple…
General practice
Companies: Google
Array · Dynamic Programming
Given two length-n arrays, choose for each index either nums1[i] or nums2[i] to form nums3 so as to maximize the length of a contiguous non-decreasing…
General practice
Given a case-sensitive string, return the length of the longest palindrome you can build by reordering its letters — computed by summing pairs from character…
General practice
Given two short strings s and t, pick any substring from s and any substring from t, concatenate them in order, and return the maximum…
General practice
Given strings s and t, pick any substring of s and any substring of t, concatenate them in order, and return the length of the…
General practice
Given a list of two-letter words, build the longest palindrome by selecting words so that reverse pairs (e.g., "ab" and "ba") contribute 4 characters each…
General practice
Find the maximum length of a simple path in an undirected graph (visit each node at most once) such that the sequence of node labels…
General practice