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,951–2,975
Find the length of the longest subsequence of s that reads the same forwards and backwards — a classic dynamic programming problem (equivalently LCS between…
Companies: Goldman Sachs
Dynamic Programming · String
Given a string s and a budget k of single-step cyclic letter shifts (each operation moves a character to its next or previous letter, wrapping…
General practice
Given a string, find the length of the longest palindromic subsequence you can form (a subsequence that reads the same forward and backward). This typically…
General practice
Find the longest simple path in a rooted tree where every pair of adjacent nodes have different characters; this is solved with a DFS/tree-DP that…
General practice
Given a string, return the length of the longest substring that appears at least twice in the string (overlaps allowed). This requires efficiently detecting repeated…
General practice
Find the length of the longest contiguous subarray (or substring) that is "semi-repeating" — i.e., contains at most one value/character that appears more than once…
General practice
Given a rooted weighted tree with a value at each node, find a downward ancestor→descendant path whose node values are all unique that maximizes the…
General practice
Given a rooted tree with edge lengths and node values, find a downward ancestor→descendant path that maximizes total edge length under the constraint that node…
General practice
Find the maximum length (≥2) subsequence of nums whose elements, when sorted, form a chain a, a^2, a^4, ... (each element is the square of…
General practice
Given an integer array, return the length of the longest contiguous subarray that is strictly increasing or strictly decreasing. This is equivalent to finding the…
General practice
General practice
Companies: Amazon
Array · Hash Table · Prefix Sum
Given a binary array, delete exactly one element and return the length of the longest contiguous subarray of 1s in the resulting array (0 if…
General practice
Find the maximum bitwise AND achievable by any subarray and return the length of the longest contiguous subarray that attains it. Key observation: the maximum…
General practice
Find the longest string seq such that seq repeated k times (seq*k) is a subsequence of s, returning the lexicographically largest one on ties (or…
General practice
Find the longest subsequence of nums such that the absolute differences between consecutive chosen elements are non-increasing. This is an LIS-like DP problem where you…
General practice
For each query, determine the maximum number of elements you can pick from nums (as a subsequence) whose sum is ≤ query — equivalent to…
General practice
Companies: Bloomberg, Google, Infosys
Array · Bit Manipulation
Find the length of the longest contiguous substring made only of vowels that contains each of 'a','e','i','o','u' at least once and whose characters never decrease…
Companies: Rippling
Sliding Window · String
Find the length of the longest substring of a lowercase string s such that every character in that substring appears at least k times. The…
General practice