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 76–96
Given two strings, return the starting index of the first occurrence of needle in haystack, or -1 if absent. This is a classic substring search…
Companies: Bloomberg, Google, Meta, Microsoft
Boyer–Moore String-Search Algorithm · Knuth–Morris–Pratt Algorithm · String · String Matching
Determine whether there exists a consistent one-to-one character mapping from s to t that transforms s into t (i.e., each character in s always maps…
Companies: Meta
Hash Table · String
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 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
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
Given a valid parentheses string, assign each character to one of two disjoint valid-parentheses subsequences A and B (output 0/1 per index) so that the…
Companies: Microsoft
Bracket Sequences · Stack · String
Partition the string into the fewest contiguous substrings such that each substring is "balanced" (every distinct character in the substring appears the same number of…
Companies: Grammarly
Counting · Dynamic Programming · Hash Table · String
Count the number of ways to form target left-to-right by picking each target character from some word’s character at column k, with the constraint that…
Companies: Uber
Array · Dynamic Programming · String
Count the number of non-empty substrings (in a string of letters 'a'–'j') whose character counts have at most one odd frequency. Core idea: track a…
Companies: Uber
Bit Manipulation · Hash Table · Prefix Sum · String
Partition the input string s into substrings so that every substring is a palindrome, and return all possible such partitions. This is typically solved by…
Companies: Salesforce
Backtracking · Dynamic Programming · String
Given a line of dominoes where some are initially pushed left (L), right (R), or upright (.), compute the final positions after simultaneous propagation of…
Companies: Anduril
Dynamic Programming · String · Two Pointers
Sort teams by aggregating position-wise vote counts: compare teams by their counts for first place, then second place, and so on, using alphabetical order as…
Companies: Atlassian
Array · Counting · Hash Table · Sorting
Reconstruct a binary tree from a preorder string where each node is represented by its value prefixed with D dashes indicating its depth (root depth…
Companies: Grammarly
Binary Tree · Depth-First Search · String · Tree
Remove duplicate letters from s so each character appears exactly once and the resulting string is the smallest possible in lexicographic order. This is solved…
Companies: TikTok
Greedy · Monotonic Stack · Stack · String
Reverse the input array of characters in-place (O(1) extra space) so the characters appear in reverse order; array length can be up to 10^5.
Companies: Meta
String · Two Pointers
Given lists of positive and negative words and one feedback report per student, compute each student's score (+3 per positive word, -1 per negative word)…
Companies: Booking.com
Array · Hash Table · Heap (Priority Queue) · Sorting
Convert a valid Roman numeral string into its integer value by applying the additive and subtractive rules (e.g., IV = 4, IX = 9, CM…
Companies: Google, Microsoft
Hash Table · Math · String
Check whether one string is a rotation of another: return true iff s and goal have the same length and goal can be obtained by…
Companies: Roblox
String · String Matching
Given a binary tree with unique node values, produce the shortest path from start node s to destination t as a string of 'L', 'R'…
Companies: Snowflake
Binary Lifting · Binary Tree · Depth-First Search · Lowest Common Ancestor
Given a string s and an empty buffer t that acts like a stack (you can push s's first char onto t or pop t's…
Companies: Bloomberg, Expedia, Rippling
Greedy · Hash Table · Stack · String
Determine whether two strings are anagrams — i.e., contain the same multiset of characters — by comparing their character frequency distributions (or sorted forms). Inputs…
Companies: Amazon, Google, Meta, Microsoft +1
Hash Table · Sorting · String