Welcome to the Comprehensive Data Structures and Algorithms (DSA) Roadmap for beginners! This roadmap equips you with a detailed understanding of fundamental concepts in Data Structures (DS) and Algorithms (Algo) during your first week of learning. Each section delves into specific topics with ample sample questions and practical exercises.
- Foundational Concepts
- Arrays
- Linked Lists
- Strings
- Searching Algorithms
- Recursion
- JavaScript Built-in Data Structures
- Understand how DS organize data efficiently and Algo solve problems with step-by-step instructions.
- Explore real-world examples of DS usage (e.g., shopping lists - arrays, social network connections - graphs).
- Sample Questions:
- What are the different types of Data Structures? Explain their advantages and disadvantages.
- How do Algorithms help us solve computational problems? Provide examples of common algorithms used in daily life.
- Grasp how programs manage memory during execution.
- Understand the concept of memory leaks (unreleased memory) and their impact on program performance.
- Sample Questions:
- Explain the difference between static and dynamic memory allocation.
- How do memory leaks occur in programs? Describe their consequences and prevention techniques.
- Learn how to measure the efficiency of algorithms based on time and space complexity.
- Focus on Big-O Notation for asymptotic analysis, understanding how input size affects algorithm performance.
- Sample Questions:
- Define time complexity and space complexity. How do they differ?
- Explain the concept of Big-O Notation. Analyze the time complexity of simple algorithms like finding the maximum element in an array.
- Explore different time complexities (Constant, Linear, Logarithmic, Quadratic, Exponential) with code examples.
- Master the concept of arrays, their fixed size, and contiguous memory allocation.
- Understand common array operations:
- Initialization: Creating an array with specific values.
- Accessing elements using indices.
- Modifying elements (Set, Update).
- Traversing through all elements (iteration).
- Inserting elements at specific positions.
- Deleting elements from specific positions.
- Sample Questions:
- Implement functions to initialize an array with user-defined values and display its contents.
- Write code to find the sum or average of elements in an array.
- Practice inserting an element at the beginning, middle, or end of an array (shifting elements if needed).
- Implement a function to delete an element at a specific position and handle cases like deleting the first or last element.
- Reverse the order of elements in an array.
- Understand linked lists, their dynamic nature, and non-contiguous memory allocation.
- Explore different types of linked lists: Singly Linked List (one pointer per node), Doubly Linked List (two pointers per node), Circular Linked List (tail points back to head).
- Sample Questions:
- Differentiate between arrays and linked lists. Explain the advantages and disadvantages of each.
- Illustrate the concept of nodes in a linked list with diagrams.
- Describe the differences between Singly, Doubly, and Circular Linked Lists.
- Implement functions to create Singly and Doubly linked lists in your chosen programming language.
- Understand how nodes are connected through pointers.
- Sample Questions:
- Write code to create a Singly Linked List with a head node containing a specific value.
- Implement a function to insert a new node at the beginning of a Singly Linked List.
- Practice creating a Doubly Linked List with functionalities to add a node at the end.
- Master linked list operations for both Singly and Doubly Linked Lists:
- Initialization (creating an empty list).
- Accessing elements (consider limitations due to non-indexed nature).
- Modifying elements (updating data within a node).
- Traversing through the list (iterating using pointers).
- Inserting elements at specific positions (handling edge cases like inserting at the beginning or end).
- Deleting elements with a specific value or at a specific position.
- Sample Questions:
- Implement a function to traverse a Singly Linked List and print the data of each node.
- Write code to delete the head node, a specific node in the middle, or the last node in a Singly Linked List.
- Implement a function to reverse a Singly Linked List (iterative and recursive approaches).
- (For Doubly Linked Lists) Practice inserting a node before or after a specific node with a given value.
- (For Doubly Linked Lists) Write code to delete a node by just its reference (without searching for its value).
- Implement functions to convert an array to a linked list and vice versa.
- Write code to take an array of integers and create a Singly Linked List with those elements.
- Practice converting a Singly Linked List back into an array, preserving the element order.
- Sample Questions :
- Discuss the scenarios where arrays are preferable over linked lists and vice versa.
- Analyze the time and space complexity of common operations (access, insertion, deletion) for both arrays and linked lists.
- Explore strings as data structures, understand primitive vs. object strings.
- Grasp common string operations:
- Initialization: Creating a string with specific characters.
- Accessing characters using indices.
- Modifying characters (limited in most languages).
- Finding the length of a string.
- Concatenation: Joining two or more strings.
- Searching for substrings within a string.
- Extracting substrings from a string.
- String comparison (lexicographic order).
- Sample Questions:
- Implement functions to initialize a string with user input and display its characters.
- Write code to find the first or last occurrence of a specific character within a string.
- Practice extracting a substring from a string based on starting and ending indices.
- Implement a function to compare two strings lexicographically (alphabetical order).
- Write code to reverse a string (iterative and recursive approaches).
- Explore string manipulation techniques like replacing characters, finding the frequency of each character, etc.
- Understand the concept of linear search, iterating through a list to find a specific element.
- Sample Questions:
- Implement a function for linear search in arrays.
- Analyze the time complexity of linear search (worst-case scenario).
- Practice using linear search to find an element in a Singly Linked List (consider the limitations).
- Learn the efficient binary search algorithm for sorted arrays, repeatedly halving the search space.
- Sample Questions:
- Implement a function for binary search in sorted arrays.
- Explain why binary search only works on sorted arrays.
- Analyze the time complexity of binary search (logarithmic).
- Practice using binary search to find an element in a sorted Singly Linked List (potentially converting it to an array first).
- Grasp the concept of recursive functions, where a function calls itself.
- Understand the importance of base cases to prevent infinite recursion.
- Sample Questions:
- Explain the concept of recursion with a simple example (e.g., factorial calculation).
- Identify potential issues with recursion (stack overflow errors) and how to avoid them.
- Implement functions using recursion for problems like calculating factorial, finding Fibonacci numbers, performing a depth-first search on a tree (advanced).
- Explore built-in methods like:
- push(): Add an element to the end of an array.
- pop(): Remove the last element from an array.
- shift(): Remove the first element from an array.
- unshift(): Add an element to the beginning of an array.
- forEach(): Execute a function for each element.
- map(): Create a new array with elements transformed by a function.
- filter(): Create a new array with elements that pass a test implemented by a function.
- reduce(): Reduce an array to a single value using a provided function.
- concat(): Merge two or more arrays.
- slice(): Extract a section of an array.
- splice(): Add/remove.
- Sample Questions (Continued):
- Write code to use
forEach
to iterate through an array and print each element. - Practice using
map
to create a new array with squares of all elements in the original array. - Implement a function using
filter
to find all even numbers in an array. - Explore using
reduce
to find the sum or average of elements in an array.
- Write code to use
- Understand object operations:
- Creating objects with key-value pairs.
- Accessing properties using dot notation or bracket notation.
- Modifying property values.
- Adding or removing properties.
- Checking if a property exists.
- Explore built-in methods like:
- Object.keys(): Get an array of all object property names.
- Object.values(): Get an array of all object property values.
- Object.entries(): Get an array of key-value pairs as arrays.
- Sample Questions:
- Implement code to create an object representing a person with properties like name, age, and city.
- Write code to access and modify a specific property value within an object.
- Practice using
Object.keys
to iterate through all properties of an object and print their values. - Explore using
Object.entries
to create a new array containing key-value pairs from an object.
- Linear vs. Non-linear Data Structures (e.g., Arrays vs. Trees, Graphs)
- Contiguous vs. Non-contiguous Memory Allocation (related to Arrays vs. Linked Lists)
- Stack vs. Heap Memory (different memory management regions)
- Garbage Collection (automatic memory management in languages like JavaScript)
- Jagged Arrays (arrays of arrays)
- Pros and Cons of Recursion (efficiency considerations)
- Factorial, Fibonacci, Prime Number Calculations (with and without recursion)
- Practice consistently!
- Experiment with code examples and test your understanding with additional problems.
- Refer to online tutorials and visualizations for better comprehension.
This roadmap equips you with fundamental knowledge of sorting algorithms, stacks & queues, and hash tables in your second week of learning Data Structures (DS) and Algorithms (Algo).
Grasp the concept of sorting algorithms for rearranging elements based on a specific order (ascending or descending). Explore various techniques for different scenarios.
We'll cover five common sorting algorithms, each with complexities, advantages, and disadvantages:
- Bubble Sort: Simple but inefficient for large datasets - quadratic time complexity.
- Insertion Sort: Iterative approach, good for partially sorted data - average case closer to linear time complexity.
- Selection Sort: Repeatedly finding minimum/maximum element and placing it - quadratic time complexity.
- Implement functions for Bubble Sort, Insertion Sort, and Selection Sort.
- Analyze the time complexity (best, average, worst case) of each sorting algorithm.
- Discuss the strengths and weaknesses of each sorting technique.
Explore more complex but efficient sorting algorithms for larger datasets:
- Quick Sort: Divide-and-conquer strategy, pivoting elements to partition the data - average near linear time complexity, but can degrade to worst-case quadratic.
- Merge Sort: Another divide-and-conquer approach, recursively dividing data until single elements, then merging sorted sub-lists - near linear time complexity.
- Implement functions for Quick Sort and Merge Sort.
- Analyze the time complexity of Quick Sort and Merge Sort.
- Compare the performance of Quick Sort and Merge Sort in different scenarios (stability, in-place vs. extra space).
Understand when to choose specific sorting algorithms based on data size, desired order, and stability requirements.
Grasp the concept of stacks (LIFO - Last In First Out) and queues (FIFO - First In First Out) as linear data structures. Explore their real-world applications.
Implement stacks using arrays and linked lists. Master stack operations:
- Push: Add an element to the top of the stack.
- Pop: Remove and return the top element from the stack.
- Peek: Access the top element without removing it.
- IsEmpty: Check if the stack is empty.
- IsFull: Check if the stack is full (relevant for array implementation).
- Write code to implement a stack using an array and perform push, pop, peek, and isEmpty operations.
- Implement a stack using a linked list with similar functionalities.
Implement queues using arrays and linked lists. Master queue operations:
- Enqueue: Add an element to the back of the queue.
- Dequeue: Remove and return the front element from the queue.
- Peek: Access the front element without removing it.
- IsEmpty: Check if the queue is empty.
- IsFull: Check if the queue is full (relevant for array implementation).
- Write code to implement a queue using an array and perform enqueue, dequeue, peek, and isEmpty operations.
- Implement a queue using a linked list with similar functionalities.
Explore additional stack and queue concepts:
- Circular Queue: A queue where the last element wraps around to the beginning.
- Priority Queue: A queue where elements are prioritized based on a specific value (e.g., importance).
- Implement a circular queue using an array, handling the wrapping behavior.
- Discuss the use cases of priority queues and how they prioritize elements.
Understand the various applications of stacks and queues in real-world scenarios (e.g., function call stack, undo/redo functionality, task scheduling).
Grasp the concept of hash tables, a data structure for efficient key-value lookup. Understand how hash tables use hash functions to map keys to unique indices in an array. Explore the advantages of hash tables for fast retrieval based on keys.
Learn about hash functions, algorithms that convert keys into unique indices within a specific range. Explore different hash function properties like efficiency and collision avoidance.
- Implement a simple hash function for strings (e.g., sum of character codes modulo table size).
Explore ways to implement hash tables using arrays. Understand how to handle collisions (situations where multiple keys map to the same index).
- Implement a basic hash table with separate chaining for collision handling (storing colliding elements in a linked list at the corresponding index).
Deep dive into various collision handling techniques:
- Separate Chaining: Storing colliding elements in a linked list at the index.
- Open Addressing: Probing for the next available slot in the array when a collision occurs (linear probing, quadratic probing, double hashing).
- Implement a hash table with linear probing for collision handling.
- Discuss the trade-offs between separate chaining and open addressing techniques.
Briefly explore the concept of perfect hashing, where a hash function guarantees no collisions (advanced topic).
Understand the concept of re-hashing, resizing the hash table when the load factor (number of elements divided by table size) becomes too high.
Compare and contrast hash tables and sets, understanding their key differences and use cases.
- Discuss scenarios where a hash table might be preferable over a set, and vice versa.
Differentiate between hash keys (used for lookup) and array indices (fixed positions in an array).
Explore how hash tables can dynamically resize themselves to maintain efficiency.
Briefly discuss week set and week map as specialized hash table implementations (advanced topic).
For interested learners, delve deeper into specific collision handling techniques like:
- Linear Probing: Probing for the next available slot in a linear fashion.
- Quadratic Probing: Probing with a quadratic function to reduce clustering of collided elements.
- Double Hashing: Using a secondary hash function to probe for a different set of indices in case of a collision.
Understand the concept of clustering in hash tables, where collisions tend to group together, impacting performance.
Explore advanced collision handling techniques like:
- Cuckoo Hashing: Utilizing two hash tables to resolve collisions.
- Robin Hood Hashing: Stealing elements from less loaded buckets to improve balance.
Briefly introduce the concept of secure hashing algorithms like SHA, used for data integrity and security purposes.
- Practice implementing hash tables with different collision handling techniques.
- Experiment with various hash functions and analyze their impact on performance.
- Refer to online resources for further exploration of advanced hashing concepts.
- This roadmap equips you with a solid foundation for understanding sorting algorithms, stacks & queues, and hash tables. Keep practicing and
- Understand Sets, collections of unique values.
- Explore common Set operations:
- Adding elements (add()).
- Checking if an element exists (has()).
- Removing elements (delete()).
- Finding the size of the Set (size()).
- Removing all elements (clear()).
- Sample Questions:
- Write code to create a Set containing unique names from an array of strings.
- Implement a function to check if a specific element exists in a Set.
- Practice removing duplicate elements from an array using Sets.
- Understand Maps, collections that use key-value pairs (like objects but can have any data type as keys).
- Explore common Map operations (similar to Sets):
- Setting key-value pairs (set()).
- Getting the value for a key (get()).
- Checking if a key exists (has()).
- Removing a key-value pair (delete()).
- Finding the size of the Map (size()).
- Removing all elements (clear()).
- Sample Questions:
- Implement code to create a Map where keys are student IDs and values are student names.
- Write a function to retrieve the name of a student given their ID (using a Map).
- Practice using Maps to store configuration settings with key-value pairs.
- Sample Questions:
- Discuss the use cases for Arrays vs. Sets and Objects vs. Maps.
- Analyze the time complexity of common operations (add, remove, search) for Arrays, Sets, and Maps.
- Review linear data structures (arrays, linked lists) for sequential access.
- Introduce non-linear data structures (trees, graphs) for hierarchical relationships.
- Understand hierarchical structures with parent-child relationships.
- Grasp the concept of trees, a collection of nodes connected by edges.
- Explore tree terminology: parent, child, root, leaf, sibling, ancestor, descendant, path, distance, degree, depth, height, edge, subtree.
- Binary Tree: Each node has at most two children (left and right).
- Ternary Tree: Each node has at most three children.
- K-ary Tree: Each node has at most K children.
- Threaded Binary Tree: A space-efficient binary tree variation with implicit pointers.
- Complete Tree: All levels except possibly the last are completely filled.
- Full Tree: Every node except possibly leaves has two children.
- Perfect Tree: Every internal node has two children and all leaves are at the same level.
- Degenerate Tree: A tree where most nodes have only one child.
- Left-Skew Tree: More nodes lean left than right.
- Right-Skew Tree: More nodes lean right than left.
- BST vs. Binary Tree: Understand the additional properties of a BST.
- Uses of BST: Efficient searching and sorting of data with a specific ordering.
- Balanced vs. Unbalanced Tree: Explore the impact of balance on BST performance.
- Properties of BST: Ordering property (left subtree < root < right subtree).
- BST Operations:
- Insertion: Maintain BST property while adding new elements.
- Deletion: Remove an element while preserving BST order.
- Traversal:
- Depth-First Search (DFS):
- InOrder: Visit left subtree, root, then right subtree (sorted order for BST).
- PreOrder: Visit root, then left subtree, then right subtree.
- PostOrder: Visit left subtree, then right subtree, then root.
- Breadth-First Search (BFS): Visit nodes level by level.
- Depth-First Search (DFS):
- AVL Tree: A self-balancing BST with a height difference constraint (logarithmic search time).
- Red-Black Tree: Another self-balancing BST with specific node color properties (logarithmic search time).
- String vs. Trie: Explore how tries efficiently store and retrieve strings with a prefix search functionality.
- Trie Operations:
- Initialization: Create an empty trie.
- Insertion: Insert a new string into the trie.
- Deletion: Delete a string from the trie (if it exists).
- Search: Search for a specific string prefix in the trie.
- Prefix and Suffix Trees: Specialized tries for efficient prefix and suffix searches.
- Terminator character: A special character marking the end of a string in the trie.
- Compressed Trie: Techniques for reducing memory usage in tries (e.g., Radix Trie).
- Understand heaps, tree-based structures where the root has the highest (max heap) or lowest (min heap) value compared to its children.
- Heap Operations:
- Get Value of Children/Parent: Access child or parent node values based on their positions.
- Initialization/Heapify: Convert an array into a valid heap structure.
- Insertion: Add a new element to the heap while maintaining the heap property.
- Deletion: Remove the root element (min/max value) from the heap and re-organize.
- Heapsort: Sorting algorithm utilizing a heap structure for efficient time complexity (average/near worst-case - n log n).
- Understand graphs, data structures consisting of vertices (nodes) connected by edges (links) representing relationships.
- Explore graph terminology: vertex, edge, adjacency list, adjacency matrix.
- Directed (Unidirectional): Edges have a direction (from one vertex to another).
- Undirected (Bidirectional): Edges have no direction (connect two vertices).
- Cyclic: A graph containing a closed loop (cycle) of vertices.
- Disconnected: A graph where some vertices are not reachable from others.
- Weighted Graph: Edges have associated weights (costs).
- Unweighted Graph: Edges have no weights (all connections are considered equal).
- Bipartite Graph: A graph where vertices can be divided into two sets such that no edges connect vertices within the same set.
- Breadth-First Search (BFS): Explore vertices level by level, starting from a source vertex.
- Depth-First Search (DFS): Explore vertices along a path until a dead end is reached, then backtrack and explore another path.
- Modeling networks (social, computer, transportation).
- Route finding (GPS navigation).
- Task scheduling (dependency relationships).
- Minimum spanning tree (finding the most efficient set of connections).
- River Size Problem: Finding the size (number of nodes) of the connected component containing a given vertex.
Some algorithms heavily utilize the data structures covered this week.
- Greedy Method: An algorithmic approach that makes the optimal choice at each step with the aim of finding a near-optimal solution overall.
- Graph Algorithms:
- Minimum Spanning Tree (MST) Algorithms:
- Kruskal's Algorithm: A greedy algorithm to find a MST for a weighted graph.
- Prim's Algorithm: Another greedy algorithm for finding a MST.
- Shortest Path Algorithms:
- Dijkstra's Algorithm: Finding the shortest path between a source vertex and all other reachable vertices in a weighted graph.
- Bellman-Ford Algorithm: Can handle graphs with negative edge weights (Dijkstra's works for non-negative weights).
- Topological Sorting: Ordering vertices in a directed acyclic graph (DAG) such that for every directed edge from u to v, u appears before v in the ordering.
- Floyd-Warshall Algorithm: Finding the shortest paths between all pairs of vertices in a weighted graph.
- Bipartite Graph Checking: Determining if a graph is a bipartite graph.
- Max Flow Algorithm (Ford-Fulkerson Algorithm): Finding the maximum flow of data through a network.
- Minimum Spanning Tree (MST) Algorithms:
- Graph vs. Tree: Understand the key differences and relationships between trees and graphs.
- Forest (in Tree): A collection of disconnected trees.
- Operators:
- Binary Operators: Operations involving two operands (e.g., +, -, *).
- Priority: Order of operations based on precedence rules (e.g., multiplication before addition).
- Infix, Prefix (Polish Notation), Postfix (Reverse Polish Notation): Different ways to represent expressions.
- General Concepts:
- Logarithms: Understand the concept of logarithms and their applications in computer science (e.g., time complexity analysis).
- File Structure vs. Data Structure: Differentiate between file structures for data storage and data structures for in-memory data organization.
- Data Structure Applications: Explore how data structures are used in various programming domains.
- Void vs. Null: Understand the difference between void (absence of a value) and null (a special pointer value).
- Dynamic Data Structures: Data structures that can grow or shrink in size at runtime.
- Dynamic Memory Management/Allocation: Techniques for allocating and freeing memory during program execution.
- Heap vs. Stack: Understand the differences between heaps (used for dynamic allocation) and stacks (used for function calls and local variables).
- Pointers in Data Structures:
- Mastering pointers is crucial for many data structures (especially trees and graphs).
- Explore how pointers allow efficient memory management and navigation within data structures.
- Recursive Algorithms:
- Understand the concept of recursion, a function that calls itself.
- Explore how recursion can be a powerful tool for solving problems that can be broken down into smaller, self-similar subproblems.
- Be aware of potential drawbacks of recursion, such as stack overflow for very deep recursion.
- Divide and Conquer on Recursion:
- Understand divide-and-conquer, a common algorithmic paradigm that recursively divides a problem into smaller subproblems, solves those subproblems, and combines the solutions.
- Which is the Fastest Sorting Algorithm Available?
- The answer depends on factors like data size, pre-sortedness, and memory usage.
- Heapsort (average/near worst-case - n log n) is often a good choice for general-purpose sorting.
- Quicksort (average - n log n, but worst-case - n^2) can be faster on average but has a worse worst-case scenario.
- Merge Sort (n log n) is generally slower than Heapsort or Quicksort on average but has a guaranteed n log n time complexity.
- Multi-Linked Lists:
- A data structure where each node can have multiple pointers to other nodes.
- Useful for representing complex relationships between data elements.
- Sparse Matrices:
- Matrices where most elements are zero.
- Special storage techniques can be used to efficiently represent and manipulate sparse matrices.
- Disadvantages of Implementing Queues Using Arrays:
- Fixed size: Arrays cannot grow or shrink dynamically, limiting flexibility.
- Queue overflow/underflow: Handling these conditions can be complex with arrays.
- Void Pointer:
- A pointer that can point to any data type.
- Useful for generic programming techniques.
- Lexical Analysis:
- The process of breaking down text into meaningful units (tokens) like keywords, identifiers, operators.
- Lexeme:
- A meaningful sequence of characters identified during lexical analysis (e.g., a keyword like "if").
- Pattern Matching:
- Finding specific patterns (sequences of characters or symbols) within text or data.
- Closest Path (Graph):
- Finding the shortest path between two vertices in a graph.
- Often solved using graph traversal algorithms like Dijkstra's algorithm.
- Degree of the Node (Graph):
- The number of edges connected to a node in a graph.
- Spanning Tree:
- A subgraph of a graph that connects all its vertices without cycles.
- Minimum Spanning Tree (MST):
- A spanning tree with the minimum total edge weight.
- Useful for finding the most efficient set of connections in a weighted graph (e.g., Kruskal's or Prim's algorithm).
- AVL Tree:
- A self-balancing binary search tree with a maximum height difference of 1 between subtrees, ensuring efficient search time (logarithmic).
- B-Tree:
- A self-balancing tree designed for efficient storage and retrieval of large datasets, particularly useful for databases.
- Full Tree:
- Every node except possibly leaves has two children.
- Complete Tree:
- All levels except possibly the last are completely filled.
- Perfect Tree:
- Every internal node has two children and all leaves are at the same level.
- Heap Applications:
- Priority queues (e.g., scheduling tasks based on priority).
- Heapsort (efficient sorting algorithm).
- BFS Complexity:
- Breadth-First Search has a time complexity of O(V + E), where V is the number of vertices and E is the number of edges in the graph.
- Shortest Path Algorithm:
- Dijkstra's algorithm and Bellman-Ford algorithm are commonly used shortest path algorithms with varying complexities depending on the graph type (weighted/unweighted, presence of negative edge weights).
- Dijkstra's Algorithm:
- Finds the shortest paths from a source vertex to all reachable vertices in a weighted graph with non-negative edge weights. Time complexity: O(V^2) in the worst case, but often performs better in practice (average complexity depends on the graph structure).
- Bellman-Ford Algorithm:
- Can handle graphs with negative edge weights. Time complexity: O(V * E).
- Topological Sorting:
- Ordering vertices in a directed acyclic graph (DAG) such that for every directed edge from u to v, u appears before v in the ordering. Time complexity: O(V + E).
- Acyclic Travel:
- Traversing acyclic
- Acyclic graphs (graphs without cycles) can be traversed efficiently using algorithms like topological sorting.
- Graph vs. Tree:
- Trees are hierarchical structures with a single root node and parent-child relationships.
- Graphs can be more general, allowing for cycles and representing arbitrary relationships between nodes.
- Additional Types of Graphs:
- Complete Graph: Every pair of vertices is connected by an edge.
- Graph Indexing: Techniques for efficiently searching and retrieving data within a graph structure.
- Representing Graphs in Memory: Different approaches to store graphs in memory using adjacency lists or adjacency matrices.
- Cycles Detection:
- Algorithms like depth-first search (DFS) can be used to detect cycles in graphs.
- Practical Questions Asked:
- Be prepared for interview-style questions that test your understanding of data structures and algorithms covered in Week 3. This could involve implementing algorithms, analyzing time and space complexity, or explaining trade-offs between different data structures.
- Two Sum (1)
- Maximum Subarray (3)
- Best Time to Buy and Sell Stock (121)
- Missing Number (268)
- Move Zeroes (283)
- 3Sum (15)
- Remove Duplicates from Sorted Array (26)
- Rotate Array (189)
- Merge Intervals (56)
- Majority Element (169)
- Longest Substring Without Repeating Characters (3)
- Roman to Integer (13)
- Valid Parentheses (20)
- Reverse String (344)
- Longest Common Prefix (14)
- Group Anagrams (49)
- Edit Distance (72)
- Merge Two Sorted Lists (21)
- Majority Element (169)
- Merge Sorted Arrays (88)
- Sort Colors (75)
- Sort an Array (912)
- Kth Largest Element in an Array (215)
- Min Stack (155)
- Implement Queue using Stacks (232)
- Binary Tree Level Order Traversal (102)
- Implement Queue using Stacks (232)
- Binary Tree Level Order Traversal (102)
- Implement Stack using Queues (225)
- Two Sum (1)
- Isomorphic Strings (205)
- Top K Frequent Elements (347)
- Longest Substring Without Repeating Characters (3)
- Group Anagrams (49)
- Implement Trie (Prefix Tree) (208)
- Binary Tree Inorder Traversal (94)
- Symmetric Tree (101)
- Path Sum (112)
- Validate Binary Search Tree (98)
- Same Tree (100)
- Kth Smallest Element in a BST (230)
- Kth Largest Element in an Array (215)
- Sum of Two Integers (371)
- Clone Graph (133)
- Number of Islands
Hey folks! 👋 If you're diving into the world of LeetCode and looking for a structured path to improve your skills, I've curated a list of questions in the order of increasing complexity. 📈
This resource is specifically designed for beginners, making your LeetCode journey a bit smoother. 💡 Feel free to check out the list and let me know if you have any questions or suggestions! 🚀
Math
2235. Add Two Integers
: Simplest Leetcode Question412. Fizz Buzz
2469 Convert the Temperature
1952. Three Divisors
2455. Average Value of Even Numbers That Are Divisible by Three
3028. Ant on the Boundary
1313. Decompress Run-Length Encoded List
3099. Harshad Number
507. Perfect Number
1614. Maximum Nesting Depth of the Parentheses
657. Robot Return to Origin
367. Valid Perfect Square
561. Array Partition
2833. Furthest Point From Origin
: You can use if else condition if didn't know hashmaps2427. Number of Common Factors
1979. Find Greatest Common Divisor of Array
2974. Minimum Number Game
9. Palindrome Number
1281. Subtract the Product and Sum of Digits of an Integer
2413. Smallest Even Multiple
1431. Kids With the Greatest Number of Candies
2706. Buy Two Chocolates
268. Missing Number
383. Ransom Note
896. Monotonic Array
2965. Find Missing and Repeated Values
2894. Divisible and Non-divisible Sums Difference
2769. Find the Maximum Achievable Number
2535. Difference Between Element Sum and Digit Sum of an Array
2544. Alternating Digit Sum
2154. Keep Multiplying Found Values by Two
1351. Count Negative Numbers in a Sorted Matrix
1317. Convert Integer to the Sum of Two No-Zero Integers
1720. Decode XORed Array
2574. Left and Right Sum Differences
3000. Maximum Area of Longest Diagonal Rectangle
191. Number of 1 Bits
2859. Sum of Values at Indices With K Set Bits
509. Fibonacci Number
70. Climbing Stairs
: Similiar to Fibonacci231. Power of Two
326. Power of Three
342. Power of Four
35. Search Insert Position
: Binary Search Implementation455. Assign Cookies
1385. Find the Distance Value Between Two Arrays
121. Best Time to Buy and Sell Stock
1588. Sum of All Odd Length Subarrays
645. Set Mismatch
977. Squares of a Sorted Array
628. Maximum Product of Three Numbers
414. Third Maximum Number
2119. A Number After a Double Reversal
1304. Find N Unique Integers Sum up to Zero
2475. Number of Unequal Triplets in Array
1688. Count of Matches in Tournament
389. Find the Difference
1512. Number of Good Pairs
2180. Count Integers With Even Digit Sum
7. Reverse Integer
1710. Maximum Units on a Truck
66. Plus One
2824. Count Pairs Whose Sum is Less than Target
2540. Minimum Common Value
: Two pointer approach442. Find All Duplicates in an Array
: Medium - Easy level2807. Insert Greatest Common Divisors in Linked List
: Medium Question but Medium - Easy level2125. Number of Laser Beams in a Bank
: Medium - Easy level2870. Minimum Number of Operations to Make Array Empty
: Medium - Easy level2396. Strictly Palindromic Number.go
2610. Convert an Array Into a 2D Array With Conditions
: Medium380. Insert Delete GetRandom O(1)
: Medium46. Permutations
: Medium (Recursion)1481. Least Number of Unique Integers after K Removals
: Medium O(N) Solution1291. Sequential Digits
: Medium
Array
2455. Average Value of Even Numbers That Are Divisible by Three
3028. Ant on the Boundary
961. N-Repeated Element in Size 2N Array
561. Array Partition
1313. Decompress Run-Length Encoded List
1614. Maximum Nesting Depth of the Parentheses
2089. Find Target Indices After Sorting Array
2974. Minimum Number Game
2215. Find the Difference of Two Arrays
2798. Number of Employees Who Met the Target
1431. Kids With the Greatest Number of Candies
2706. Buy Two Chocolates
383. Ransom Note
3000. Maximum Area of Longest Diagonal Rectangle
191. Number of 1 Bits
2864. Maximum Odd Binary Number
2859. Sum of Values at Indices With K Set Bits
1672. Richest Customer Wealth
2441. Largest Positive Integer That Exists With Its Negative
2544. Alternating Digit Sum
1720. Decode XORed Array
268. Missing Number
2965. Find Missing and Repeated Values
1207. Unique Number of Occurrences
2574. Left and Right Sum Differences
455. Assign Cookies
3005. Count Elements With Maximum Frequency
896. Monotonic Array
977. Squares of a Sorted Array
- `1385. Find the Distance Value Between Two Arrays
121. Best Time to Buy and Sell Stock
2475. Number of Unequal Triplets in Array
1913. Maximum Product Difference Between Two Pairs
2176. Count Equal and Divisible Pairs in an Array
26. Remove Duplicates from Sorted Array
2540. Minimum Common Value
: Two pointer approach349. Intersection of Two Arrays
350. Intersection of Two Arrays II
643. Maximum Average Subarray I
1089. Duplicate Zeros
: Given a fixed-length integer array arr, duplicate each occurrence of zero, shifting the remaining elements to the right.2006. Count Number of Pairs With Absolute Difference K
628. Maximum Product of Three Numbers
1710. Maximum Units on a Truck
66. Plus One
2433. Find The Original Array of Prefix Xor
2824. Count Pairs Whose Sum is Less than Target
1588. Sum of All Odd Length Subarrays
- `3090. Maximum Length Substring With Two Occurrences
442. Find All Duplicates in an Array
: Medium - Easy level2125. Number of Laser Beams in a Bank
: Medium - Easy level2870. Minimum Number of Operations to Make Array Empty
: Medium - Easy level2396. Strictly Palindromic Number.go
2610. Convert an Array Into a 2D Array With Conditions
: Medium380. Insert Delete GetRandom O(1)
: Medium46. Permutations
: Medium (Recursion)1481. Least Number of Unique Integers after K Removals
: Medium O(N) Solution
Strings
1108. Defanging an IP Address
657. Robot Return to Origin
2833. Furthest Point From Origin
: You can use if else condition if didn't know hashmaps2351. First Letter to Appear Twice
387. First Unique Character in a String
383. Ransom Note
1704. Determine if String Halves Are Alike
2108. Find First Palindromic String in the Array
744. Find Smallest Letter Greater Than Target
1816. Truncate Sentence
1528. Shuffle String
191. Number of 1 Bits
1773. Count Items Matching a Rule
2114. Maximum Number of Words Found in Sentences
1662. Check If Two String Arrays are Equivalent
1678. Goal Parser Interpretation
2273. Find Resultant Array After Removing Anagrams
2828. Check if a String Is an Acronym of Words
2942. Find Words Containing Character
1624. Largest Substring Between Two Equal Characters
1689. Partitioning Into Minimum Number Of Deci-Binary Numbers
- `3090. Maximum Length Substring With Two Occurrences
1347. Minimum Number of Steps to Make Two Strings Anagram
: Medium - Easy2186. Minimum Number of Steps to Make Two Strings Anagram II
: Medium1657. Determine if Two Strings Are Close
: Medium567. Permutation in String
: Sliding Window Approach438. Find All Anagrams in a String
: Sliding Window
Hash Maps / Hash Table / Set /Dictionary
1. Two Sum
217. Contains Duplicate
: Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct.961. N-Repeated Element in Size 2N Array
2833. Furthest Point From Origin
1748. Sum of Unique Elements
1207. Unique Number of Occurrences
2351. First Letter to Appear Twice
387. First Unique Character in a String
2215. Find the Difference of Two Arrays
1941. Check if All Characters Have Equal Number of Occurrences
287. Find the Duplicate Number
2154. Keep Multiplying Found Values by Two
575. Distribute Candies
3005. Count Elements With Maximum Frequency
1512. Number of Good Pairs
169. Majority Element
2190. Most Frequent Number Following Key In an Array
383. Ransom Note
1624. Largest Substring Between Two Equal Characters
205. Isomorphic Strings
242. Valid Anagram
1832. Check if the Sentence Is Pangram
771. Jewels and Stones
202. Happy Number
2965. Find Missing and Repeated Values
1282. Group the People Given the Group Size They Belong To
349. Intersection of Two Arrays
350. Intersection of Two Arrays II
2357. Make Array Zero by Subtracting Equal Amounts
1370. Increasing Decreasing String
2367. Number of Arithmetic Triplets
219. Contains Duplicate II
2404. Most Frequent Even Element
- `3090. Maximum Length Substring With Two Occurrences
442. Find All Duplicates in an Array
: Medium - Easy level1347. Minimum Number of Steps to Make Two Strings Anagram
: Medium - Easy2186. Minimum Number of Steps to Make Two Strings Anagram II
: Medium1657. Determine if Two Strings Are Close
: Medium380. Insert Delete GetRandom O(1)
: Medium49. Group Anagrams
: Medium
Linked List
1290. Convert Binary Number in a Linked List to Integer
: Given head which is a reference node to a singly-linked list. The value of each node in the linked list is either 0 or 1. The linked list holds the binary representation of a number. Return the decimal value of the number in the linked list.876. Middle of the Linked List
: Given the head of a singly linked list, return the middle node of the linked list. If there are two middle nodes, return the second middle node.206. Reverse Linked List
234. Palindrome Linked List
160. Intersection of Two Linked Lists
: Given the heads of two singly linked-lists headA and headB, return the node at which the two lists intersect. If the two linked lists have no intersection at all, return null.141. Linked List Cycle
: Given head, the head of a linked list, determine if the linked list has a cycle in it.19. Remove Nth Node From End of List
: Given the head of a linked list, remove the nth node from the end of the list and return its head.2095. Delete the Middle Node of a Linked List
: You are given the head of a linked list. Delete the middle node, and return the head of the modified linked list.2807. Insert Greatest Common Divisors in Linked List
: Medium Question but Medium - Easy level707. Design Linked List
: (Medium) Design your implementation of the linked list.
SQL
1757. Recyclable and Low Fat Products
584. Find Customer Referee
595. Big Countries
1148. Article Views I
1683. Invalid Tweets
1378. Replace Employee ID With The Unique Identifier
1068. Product Sales Analysis I
2356. Number of Unique Subjects Taught by Each Teacher
1581. Customer Who Visited but Did Not Make Any Transactions
Sorting
1089. Duplicate Zeros
: Given a fixed-length integer array arr, duplicate each occurrence of zero, shifting the remaining elements to the right.
Recursion
Tree
Stack
1089. Duplicate Zeros
: Given a fixed-length integer array arr, duplicate each occurrence of zero, shifting the remaining elements to the right.
Queue
1089. Duplicate Zeros
: Given a fixed-length integer array arr, duplicate each occurrence of zero, shifting the remaining elements to the right.
Heap
1089. Duplicate Zeros
: Given a fixed-length integer array arr, duplicate each occurrence of zero, shifting the remaining elements to the right.
Trie
1089. Duplicate Zeros
: Given a fixed-length integer array arr, duplicate each occurrence of zero, shifting the remaining elements to the right.