Below you can find a curated list of exercises for each topic covered in the DSA course.
Each exercise links to a dedicated page with a problem summary, the key techniques involved, and a TypeScript solution walkthrough.
Arrays
| Exercise | Description |
|---|
| Best Time to Buy and Sell Stock | Given an array of stock prices where prices[i] is the price on the i-th day, find the maximum profit by choosing a single day to buy and a different future day to sell. |
| Best Time to Buy and Sell Stock II | Given an array of stock prices, you can buy and sell the stock multiple times — find the maximum total profit you can achieve. |
| First Missing Positive | Given an unsorted integer array nums, return the smallest missing positive integer. The algorithm must run in O(n) time and use constant extra space. |
| Increasing Triplet Subsequence | Given an integer array nums, return true if there exists a triple of indices (i, j, k) such that i < j < k and nums[i] < nums[j] < nums[k]. |
| Majority Element | Given an array nums of size n, return the majority element — the element that appears more than ⌊n / 2⌋ times. The majority element always exists in the array. |
| Move Zeroes | Given an integer array nums, move all 0s to the end of it while maintaining the relative order of the non-zero elements, in-place. |
| Number of Zero-Filled Subarrays | Given an integer array nums, return the number of subarrays entirely filled with 0s. A subarray is a contiguous non-empty sequence of elements within an array. |
| Product of Array Except Self | Given an integer array nums, return an array where each element is the product of all other elements, without using division, in O(n) time. |
| Remove Duplicates from Sorted Array | Given a sorted array nums, remove duplicates in-place so each unique element appears only once and return the count of unique elements. |
| Rotate Array | Given an array, rotate it to the right by k steps, where k is non-negative, using an in-place reversal technique. |
Strings
| Exercise | Description |
|---|
| Guess the Word | You are given an array of unique strings words where words[i] is six letters long. One word of words was chosen as a secret word. |
| Is Subsequence | Given two strings s and t, return true if s is a subsequence of t, or false otherwise. |
| Longest Common Prefix | Write a function to find the longest common prefix string amongst an array of strings. |
| Reverse Words in a String | Given an input string s, reverse the order of the words. |
| Valid Palindrome | A phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. |
| Zigzag Conversion | The string PAYPALISHIRING is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) |
Backtracking
| Exercise | Description |
|---|
| Combination Sum | Given an array of distinct integers candidates and a target integer target, return *a list of all unique combinations of *candidates* where the chosen numbers sum to *target*.* You ... |
| Combination Sum II | Given a collection of candidate numbers (candidates) and a target number (target), find all unique combinations in candidates where the candidate numbers sum to target. |
| Generate Parentheses | Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. |
| 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. Return the answer in any order. |
| N-Queens | The n-queens puzzle is the problem of placing n queens on an n x n chessboard such that no two queens attack each other. |
| Palindrome Partitioning | Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. |
| Permutations | Given an array nums of distinct integers, return all the possible permutations. You can return the answer in any order. |
| Subsets | Given an integer array nums of unique elements, return all possible subsets (the power set). |