> Uploading knowledge... _
[░░░░░░░░░░░░░░░░░░░░░░░░] 0%
blog logo
> CHICIO CODING_Pixels. Code. Unplugged.

DSA Exercises

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

ExerciseDescription
Best Time to Buy and Sell StockGiven 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 IIGiven an array of stock prices, you can buy and sell the stock multiple times — find the maximum total profit you can achieve.
First Missing PositiveGiven 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 SubsequenceGiven 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 ElementGiven 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 ZeroesGiven 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 SubarraysGiven 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 SelfGiven 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 ArrayGiven a sorted array nums, remove duplicates in-place so each unique element appears only once and return the count of unique elements.
Rotate ArrayGiven an array, rotate it to the right by k steps, where k is non-negative, using an in-place reversal technique.

Strings

ExerciseDescription
Guess the WordYou 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 SubsequenceGiven two strings s and t, return true if s is a subsequence of t, or false otherwise.
Longest Common PrefixWrite a function to find the longest common prefix string amongst an array of strings.
Reverse Words in a StringGiven an input string s, reverse the order of the words.
Valid PalindromeA 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 ConversionThe 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

ExerciseDescription
Combination SumGiven 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 IIGiven 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 ParenthesesGiven n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.
Letter Combinations of a Phone NumberGiven 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-QueensThe 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 PartitioningGiven a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s.
PermutationsGiven an array nums of distinct integers, return all the possible permutations. You can return the answer in any order.
SubsetsGiven an integer array nums of unique elements, return all possible subsets (the power set).