74 problems across 19 coding patterns. Learn the approach, understand the code, ace the interview.
Showing 74 problems
The problem asks to find two numbers in a sorted array that add up to a specific target value. It's a classic interview question testing your ability to leverage data ordering for efficient searching.
Given an array of integers, find all unique triplets that sum to a specified target value. The order of triplets and elements within triplets does not matter.
This problem tests your ability to identify palindromes within strings, while also requiring you to handle and filter out irrelevant characters. It's a common interview question pattern that combines string manipulation with algorithmic thinking.
Find the largest rectangular area possible within a histogram defined by an array of heights. This problem showcases your ability to optimize a solution from quadratic to linear time, a key skill for efficient algorithm design.
The Budget Buddies problem asks you to find two spending amounts from a list that, when combined, exactly match a given budget. This tests your ability to efficiently search for pairs within a data set, a common task in financial analysis and resource allocation.
Validate a NumPlace puzzle board to ensure it follows the core rules: each row, column, and block contains unique digits. This tests your ability to use data structures for efficient constraint validation, a common pattern in problem-solving.
The Matrix Infection problem requires modifying a matrix such that if any cell contains a specific value, its entire row and column are updated with that value. This tests understanding of in-place modifications and efficient matrix traversal.
Reversing a linked list is a classic interview question that tests your understanding of pointer manipulation and data structure fundamentals. Mastering this problem demonstrates your ability to think algorithmically and handle complex data structures efficiently.
Given a singly linked list, remove the nth node from the end of the list. This problem tests your understanding of linked list manipulation and pointer techniques, crucial for many data structure and algorithm questions.
Determine if two singly linked lists intersect and return the intersecting node. This problem tests your understanding of linked list manipulation and efficient algorithm design.
Design a data structure that acts as a size-limited cache, efficiently storing and retrieving data while prioritizing the most recently accessed entries. This problem tests your understanding of data structures and algorithms, crucial for building performant and scalable systems.
Detecting cycles in linked lists is a classic problem. It showcases your ability to work with pointer manipulation and algorithmic thinking under memory constraints.
The problem is to efficiently find the middle node of a singly linked list. This is a classic interview question that tests your understanding of linked list manipulation and algorithm optimization.
The Digit Dance problem asks whether repeatedly summing the squares of a number's digits will eventually reach 1. This problem tests your ability to detect cycles and apply clever algorithmic thinking.
Determine the number of substrings within a larger string that are anagrams of a given target string. This problem tests your ability to efficiently compare strings and identify patterns, crucial for tasks like data analysis and text processing.
Find the longest substring within a given string that contains no repeating characters. This tests your ability to efficiently manage string data and optimize for performance using sliding window techniques.
Find the longest consecutive segment of a string that can be made up of the same character by changing at most 'k' characters. This tests your ability to use sliding windows and optimize for substring problems.
Given a sorted array of integers, find the correct index to insert a target value so that the array remains sorted. This problem tests your ability to apply efficient search algorithms in common scenarios.
Find the first and last position of a given target value within a sorted array. This problem tests your ability to efficiently search sorted data, a core skill for any software engineer.
This problem involves optimizing resource allocation, a common theme in software engineering. It tests your ability to apply binary search in a non-traditional way to find the optimal solution within a defined range.
The Rotated Array Search problem challenges you to find a target value in a sorted array that has been rotated. Mastering this problem demonstrates your ability to adapt binary search to non-standard scenarios, a key skill for efficient algorithm design.
Determine if a string containing different types of brackets is properly nested. This tests your understanding of data structures and algorithm design, specifically stacks, which are fundamental in many software engineering contexts.
Find, for each element in an array, the closest element to its right that is strictly greater. This problem tests understanding of data structures for efficient lookups and monotonic stacks.
This problem challenges you to parse and evaluate a mathematical expression string, handling parentheses, addition, and subtraction. It's a good test of your stack data structure skills and ability to manage operator precedence.
Identify the N most frequent items in a collection, then return them in descending order of frequency. This is a common pattern for data analysis, search algorithms, and recommendation systems.
Merge k sorted streams into a single sorted stream. This tests your ability to efficiently manage multiple sorted data sources and is a good indicator of your heap data structure skills.
Design a data structure to efficiently calculate the running median of a continuously growing stream of numbers. This tests knowledge of heaps and data structure design under dynamic constraints, a common interview theme.
The 'Meeting Room Merger' problem asks you to consolidate overlapping time intervals, which is a common scenario in scheduling applications. Mastering this problem demonstrates your ability to work with interval data and optimize algorithms for efficiency, crucial for software engineering roles.
Given two lists of time intervals, find all the overlapping time periods between them. This problem tests your ability to work with interval data structures and algorithmic thinking.
The problem asks you to find the maximum number of overlapping time intervals within a given set. This tests your ability to efficiently manage and analyze intervals, a common pattern in scheduling and resource allocation problems.
The Problematic Playlist problem asks you to find how many song combinations in a playlist have a total length equal to a target duration. This is a common interview problem that tests your understanding of prefix sums and efficient counting techniques.
The Target Sum Segments problem asks you to find how many continuous segments of an array add up to a specific target value. Mastering this problem demonstrates your ability to efficiently use prefix sums and hash maps, crucial skills for many coding interview questions.
The 'Modified Product Array' problem challenges you to create a new array where each element is the product of all other numbers in the input array, excluding the number at that index. This tests your ability to manipulate arrays efficiently and think creatively about prefix and suffix products.
The problem asks you to mirror a binary tree, effectively swapping the left and right children of each node. This tests your understanding of tree traversals and recursion, crucial for many tree-based algorithms.
Determine if a binary tree is considered 'well-proportioned' - meaning that for every node, the heights of its left and right subtrees are within a certain tolerance. This is a common tree problem that tests your understanding of recursion and tree traversals.
Finding the visible nodes from the left in a binary tree is a classic tree traversal problem. It tests your ability to navigate tree structures and apply level-order traversal, a crucial skill for many tree-related interview questions.
Determine the maximum width of any level in a binary tree. This tests your understanding of tree traversals and space optimization, crucial for efficient data structure manipulation.
Determine if a given binary tree adheres to the rules of a Binary Search Tree (BST). This problem tests your understanding of tree traversals and BST properties, critical for many tree-based algorithms.
Finding the Lowest Common Ancestor in a binary tree is a classic problem that tests your understanding of tree traversals and recursion. It's important because it demonstrates your ability to efficiently navigate complex data structures.
Reconstruct a binary tree given its preorder and inorder traversals. This tests understanding of tree traversals and recursive algorithms, crucial for many data structure-related interview questions.
Find the maximum sum of any path in a binary tree. This problem tests your understanding of tree traversals and dynamic programming.
Implement a trie (prefix tree) data structure to efficiently store and retrieve words. This problem tests your understanding of tree-based structures and their application to string manipulation, a common theme in coding interviews.
Design a data structure that efficiently stores words and supports searching for words with wildcard characters. This problem tests your understanding of tries and recursive searching, crucial for applications like autocomplete and spellcheck.
Given a grid of letters and a list of words, identify all words from the list that can be constructed by traversing adjacent cells in the grid. This problem tests your ability to combine graph traversal with efficient data structures for searching.
The problem is to create a completely independent copy of a graph given a starting node. This tests your understanding of graph traversal and deep copying techniques, crucial for many real-world applications like data structure manipulation and algorithm design.
Given a grid representing a map with land and water, the task is to determine the number of distinct landmasses. This problem tests graph traversal skills, a fundamental concept in algorithm design and software engineering.
Determine the minimum time for a digital virus to spread across a network represented as a grid. This problem tests graph traversal and optimization skills crucial for real-world network analysis.
Determine if a given network of friends can be divided into two groups where no friends in the same group are directly connected. This problem tests graph traversal and coloring skills, crucial for understanding network structures and resource allocation.
Find the longest path in a matrix where each step increases in value. This tests graph traversal and optimization skills, crucial for system design and algorithm efficiency.
Given a starting word, an ending word, and a dictionary of valid words, find the minimum number of transformations to change the starting word into the ending word by changing one letter at a time, where each intermediate word must exist in the dictionary.
The 'Network Connectivity' problem focuses on modeling a social network where individuals can form connections, merging their friend groups. This tests your ability to efficiently track group memberships and sizes after a series of connection events, a common pattern in graph algorithms and data structure optimization.
Generate all possible orderings of elements in a list. This problem tests your ability to think recursively and use backtracking effectively, common skills in algorithm design.
Given a set of ingredients, find all possible combinations of ingredients that can be made. Each combination must be unique.
The Knight's Harmony problem challenges you to place a given number of knights on a chessboard such that no two knights threaten each other. This tests your ability to use backtracking to explore solution spaces efficiently, a crucial skill for solving combinatorial problems.
This problem explores dynamic programming through counting possible paths. Mastering this pattern is crucial for demonstrating problem-solving and optimization skills in coding interviews.
This problem focuses on finding the minimum number of stamps needed to reach a specific postage value, a classic dynamic programming challenge. Mastering this demonstrates understanding of optimization techniques and problem decomposition, crucial skills for software engineers.
The 'Concert Lineup' problem asks you to find the maximum enjoyment a concert promoter can get from a lineup of bands, with the constraint that no two bands of the same genre can play consecutively. It tests dynamic programming skills and optimization.
Given a row of houses, each with a certain amount of valuables, determine the maximum amount you can collect without hitting two adjacent houses. This tests dynamic programming skills and optimization techniques.
Find the longest sequence of ingredients that appear in the same order in two different recipes. This problem tests dynamic programming skills and the ability to optimize for overlapping subproblems.
Given a string, find the longest substring that is a palindrome. This problem tests your ability to recognize patterns and efficiently search for optimal solutions within strings, a common task in text processing and bioinformatics.
The Maximum Profit Slice problem asks you to find the contiguous subarray within a given array of stock prices that yields the highest profit. This problem is a classic example of dynamic programming and tests your ability to optimize for time complexity.
A museum curator needs to select artifacts to display, maximizing their cultural value while staying within the exhibit's weight limit. This is a variation of the classic knapsack problem.
Determine if you can reach the last index of an array given jump lengths at each position. This tests dynamic programming and greedy approaches common in technical interviews.
Imagine a circular race track where cars need fuel to complete laps. This problem asks you to find a starting point on the track that allows a car with a limited fuel capacity to complete the entire circuit without running out of fuel, testing your ability to apply greedy algorithms.
The 'Treat Distribution' problem focuses on fairly distributing treats to children based on their performance ratings, ensuring those with higher ratings receive more treats than their neighbors. This problem tests your ability to think greedily and optimize resource allocation based on local information, a common scenario in real-world scheduling and optimization tasks.
Sort a singly linked list in ascending order. This tests understanding of linked list manipulation and efficient sorting algorithms applicable to non-array data structures.
Rearrange the elements of an array of integers such that all even numbers come before all odd numbers. This problem tests understanding of array manipulation and sorting concepts.
Finding the Xth largest element in a dataset is a common task with various applications. This problem assesses your ability to efficiently identify specific elements within unsorted data, testing your knowledge of sorting and searching algorithms.
Calculate the 'digital root' of each number from 0 to n, where the digital root is the result of repeatedly summing the digits of a number until a single-digit number is reached. This problem tests bit manipulation and dynamic programming skills, crucial for optimizing performance in numerical computations.
Given an array of integers where each number appears a certain number of times except for one unique number, find the number that appears an odd number of times. You must do this efficiently.
This problem focuses on bit manipulation, a crucial skill for optimizing performance and understanding low-level system architecture. The task is to rearrange the bits of an integer by interleaving two new numbers created by its even and odd bits.
Traverse a 2D matrix in a clockwise, layer-by-layer fashion, returning the elements in the order visited. This problem tests your ability to work with multi-dimensional arrays and think geometrically about data structures.
Given a 32-bit signed integer, cyclically right-shift its digits by a specified amount. If the resulting integer falls outside the 32-bit signed integer range, return 0.
Given a set of coordinates on a 2D plane, find the largest number of points that lie on the same straight line. This tests your ability to apply geometric principles and optimize for precision issues in calculations.