-
Linked List Operations Implement basic operations for a singly linked list, such as insertion, deletion, and reversing the list.
-
Stack Implementation Implement a stack data structure with push, pop, and peek operations.
-
Queue Implementation Implement a queue data structure with enqueue, dequeue, and peek operations.
-
Find the Missing Number Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array.
-
Longest Common Prefix Write a function to find the longest common prefix string amongst a list of strings.
-
Word Frequency Counter Write a function to count the frequency of each word in a given text.
-
Two Sum: Given an array of integers, find two numbers such that they add up to a specific target.
-
Valid Parentheses: Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.
-
Maximum Subarray Sum: Find the contiguous subarray with the largest sum.
-
Linked List Cycle: Given a linked list, determine if it has a cycle.
-
Reverse Linked List: Reverse a linked list.
-
Rotate Array: Rotate an array to the right by k steps.
-
Longest Increasing Subsequence: Find the length of the longest increasing subsequence in an array of integers.
-
Palindrome Linked List: Check if a linked list is a palindrome.
-
Count and Say: The count-and-say sequence is a series of strings where each string is the result of counting and saying the digits of the previous string.
-
Merge Intervals: Given a collection of intervals, merge any overlapping intervals.
-
Valid Sudoku: Determine if a 9x9 Sudoku board is valid.
-
First Missing Positive: Given an unsorted integer array, find the smallest missing positive integer.
-
Container With Most Water: Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining.
-
Implement a Trie (Prefix Tree): Implement a trie with insert, search, and startsWith methods.
-
Evaluate Reverse Polish Notation: Evaluate the value of an arithmetic expression in Reverse Polish Notation.
-
Valid Anagram: Given two strings, check if they are valid anagrams of each other.
-
Minimum Path Sum: Given a 2D grid filled with non-negative numbers, find the minimum sum path from the top-left to the bottom-right, moving only right or down.
-
Intersection of Two Arrays: Given two arrays, write a function to compute their intersection.
-
ZigZag Conversion: Convert a given string to a zigzag pattern given a number of rows.
-
Group Anagrams: Given an array of strings, group anagrams together.
-
Word Search: Given a 2D board and a word, determine if the word exists in the grid.
-
Unique Paths: A robot is located at the top-left corner of a m x n grid. It can only move either down or right. Count the number of unique paths to reach the bottom-right corner.
-
Sort Colors: Given an array with n objects colored red, white, or blue, sort them in-place.
-
Combination Sum: Given a set of candidate numbers and a target sum, find all unique combinations where the candidate numbers sum to the target.
-
Longest Substring Without Repeating Characters: Given a string, find the length of the longest substring without repeating characters.
-
Jump Game: Given an array of non-negative integers, you are initially positioned at the first index and each element in the array represents your maximum jump length. Determine if you can reach the last index.
-
Symmetric Tree: Given a binary tree, check whether it is a mirror of itself.
-
Find Peak Element: Find the peak element in an array. An element is a peak if it is greater than or equal to its neighbors
-
Binary Tree Inorder Traversal: Implement inorder traversal of a binary tree.
-
Valid Sudoku: Determine if a 9x9 Sudoku board is valid.
-
Maximum Depth of Binary Tree: Find the maximum depth of a binary tree.
-
Number of Islands: Given a 2D grid map of '1's (land) and '0's (water), count the number of islands.
-
Top K Frequent Elements: Given an array, find the k most frequent elements.
-
Rotate Image: Rotate an N x N 2D matrix (representing an image) 90 degrees.
-
Minimum Window Substring: Given a string S and a string T, find the minimum window in S that contains all the characters in T.
-
Construct Binary Tree from Preorder and Inorder Traversal: Given preorder and inorder traversal of a tree, construct the binary tree.
-
Valid Palindrome: Given a string, determine if it is a valid palindrome, considering only alphanumeric characters and ignoring cases.
-
Word Break: Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words.
-
Longest Palindromic Substring: Given a string, find the longest palindromic substring.
-
Meeting Rooms II: Given an array of meeting time intervals, find the minimum number of conference rooms required.
-
Best Time to Buy and Sell Stock: Given an array representing stock prices on different days, find the maximum profit that can be obtained by making a single transaction.
-
Spiral Matrix: Given an m x n matrix, return all elements of the matrix in spiral order.
-
Reverse Words in a String: Given a string, reverse each word in it while maintaining the order of words.
-
Valid Sudoku: Determine if a 9x9 Sudoku board is valid. The rules are as follows:
- Each row must contain the digits 1-9 without repetition.
- Each column must contain the digits 1-9 without repetition.
- Each of the 9 3x3 sub-boxes must contain the digits 1-9 without repetition.
-
Subarray Sum Equals K: Given an array of integers and an integer k, find the total number of continuous subarrays whose sum equals k.
-
Letter Combinations of a Phone Number: Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent on a phone keypad.
-
Maximum Depth of Binary Tree: Given a binary tree, find its maximum depth.
-
Valid Palindrome: Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.
-
Merge k Sorted Lists: Merge k sorted linked lists and return it as one sorted list.
-
Find the Duplicate Number: Given an array containing n + 1 integers where each integer is between 1 and n (inclusive), find the duplicate one.
-
Set Matrix Zeroes: Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in-place.
-
Longest Common Subsequence: Given two strings, find the length of the longest common subsequence.
-
Combination Sum II: Given a collection of candidate numbers and a target, find all unique combinations in candidates where the candidate numbers sum to the target.
-
Find All Anagrams in a String: Given a string s and a non-empty string p, find all the start indices of p's anagrams in s.
-
Counting Bits: Given a non-negative integer num, for every number i in the range 0 ≤ i ≤ num, calculate the number of 1's in their binary representation.
-
Implement Trie (Prefix Tree): Implement a trie with insert, search, and startsWith methods.
-
Find the Missing Element: Given two lists, find the missing element in one of the lists.
-
Merge Sorted Lists: Merge two sorted lists into a single sorted list.
-
Shuffle Deck of Cards: Implement a function to shuffle a deck of cards represented as a list.
-
Remove Nth Node From End: Given a linked list, remove the n-th node from the end.
-
Find Common Elements: Given two lists, find the common elements between them.
-
Move Zeros to End: Given an array, move all zeros to the end without changing the order of non-zero elements.
-
Rotate List: Rotate a list to the right by k steps.
-
Implement Stack Using Lists: Implement a stack data structure using Python lists.
-
Implement Queue Using Lists: Implement a queue data structure using Python lists.
-
Maximum Subarray Sum: Find the maximum sum of a contiguous subarray in a given list.
-
Find Majority Element: Given a list, find the majority element (element appearing more than n/2 times).
-
Minimum Element in Stack: Implement a stack that supports push, pop, top, and retrieving the minimum element in constant time.
-
Flatten Nested List Iterator: Implement an iterator to flatten a nested list.
-
Check for Anagrams in a List of Words: Write a function to check for anagrams in a given list of words.
-
Substring with Concatenation of All Words: You are given a string s and a list of words. Write a function to find all the starting indices of substring(s) in s that is a concatenation of each word in words.
-
Rotate Image: Given an N x N matrix representing an image, write a function to rotate the image by 90 degrees (clockwise).
-
Reverse Linked List: Implement a function to reverse a linked list.
-
Longest Common Prefix: Write a function to find the longest common prefix string amongst an array of strings.
-
Validate Email Address: Write a function to validate an email address based on certain criteria (e.g., presence of '@' and '.' symbols, proper placement, etc.).
-
String Compression: Write a function that performs basic string compression. For a string like "aabcccccaaa," return "a2b1c5a3." If the compressed string is not smaller than the original, return the original string.