DSA from Zero — 12 Weeks
Start from true zero: complexity analysis, recursion basics, and sorting/searching fundamentals before you ever touch a pattern. A 250-question, 12-week beginner path.
Week 1: Complexity Analysis & Big-O
1-bit and 2-bit Characters
easyWe have two special characters: Given a binary array bits that ends with 0, return true if the last character must be a one-bit character.
A Number After a Double Reversal
easyReversing an integer means to reverse all its digits.
Account Balance After Rounded Purchase
easyInitially, you have a bank account balance of 100 dollars.
Add Binary
easyGiven two binary strings a and b, return their sum as a binary string.
Add Digits
easyGiven an integer num, repeatedly add all its digits until the result has only one digit, and return it.
Add Strings
easyGiven two non-negative integers, num1 and num2 represented as string, return the sum of num1 and num2 as a string.
Add to Array-Form of Integer
easyThe array-form of an integer num is an array representing its digits in left to right order.
Adjacent Increasing Subarrays Detection I
easyGiven an array nums of n integers and an integer k, determine whether there exist two adjacent subarrays of length k such that both subarrays are strictly increasing.
Alternating Digit Sum
easyYou are given a positive integer n.
Alternating Groups I
easyThere is a circle of red and blue tiles.
Ant on the Boundary
easyAn ant is on a boundary.
Apple Redistribution into Boxes
easyYou are given an array apple of size n and an array capacity of size m.
Apply Operations to an Array
easyYou are given a 0-indexed array nums of size n consisting of non-negative integers.
Arranging Coins
easyYou have n coins and you want to build a staircase with these coins.
Array Partition
easyGiven an integer array nums of 2n integers, group these integers into n pairs (a1, b1), (a2, b2), ..., (an, bn) such that the sum of min(ai, bi) for all i is maximized.
Assign Cookies
easyAssume you are an awesome parent and want to give your children some cookies.
Available Captures for Rook
easyYou are given an 8 x 8 matrix representing a chessboard.
Average Salary Excluding the Minimum and Maximum Salary
easyYou are given an array of unique integers salary where salary[i] is the salary of the ith employee.
Average Value of Even Numbers That Are Divisible by Three
easyGiven an integer array nums of positive integers, return the average value of all even integers that are divisible by 3.
Backspace String Compare
easyGiven two strings s and t, return true if they are equal when both are typed into empty text editors.
Base 7
easyGiven an integer num, return a string of its base 7 representation.
Week 2: Arrays & Strings Basics
Best Poker Hand
easyYou are given an integer array ranks and a character array suits.
Best Time to Buy and Sell Stock
easyYou are given an array prices where prices[i] is the price of a given stock on the ith day.
Binary Prefix Divisible By 5
easyYou are given a binary array nums (0-indexed).
Binary Search
easyGiven an array of integers nums which is sorted in ascending order, and an integer target, write a function to search target in nums.
Buddy Strings
easyGiven two strings s and goal, return true if you can swap two letters in s so the result is equal to goal, otherwise, return false.
Build Array from Permutation
easyGiven a zero-based permutation nums (0-indexed), build an array ans of the same length where ans[i] = nums[nums[i]] for each 0 <= i < nums.length and return it.
Button with Longest Push Time
easyYou are given a 2D array events which represents a sequence of events where a child pushes a series of buttons on a keyboard.
Buy Two Chocolates
easyYou are given an integer array prices representing the prices of various chocolates in a store.
Calculate Amount Paid in Taxes
easyYou are given a 0-indexed 2D integer array brackets where brackets[i] = [upperi, percenti] means that the ith tax bracket has an upper bound of upperi and is taxed at a rate of...
Calculate Digit Sum of a String
easyYou are given a string s consisting of digits and an integer k.
Can Make Arithmetic Progression From Sequence
easyA sequence of numbers is called an arithmetic progression if the difference between any two consecutive elements is the same.
Can Place Flowers
easyYou have a long flowerbed in which some of the plots are planted, and some are not.
Capitalize the Title
easyYou are given a string title consisting of one or more words separated by a single space, where each word consists of English letters.
Cells in a Range on an Excel Sheet
easyA cell (r, c) of an excel sheet is represented as a string "<col><row>" where: You are given a string s in the format "<col1><row1>:<col2><row2>", where <col1> represents the...
Cells with Odd Values in a Matrix
easyThere is an m x n matrix that is initialized to all 0's.
Check Array Formation Through Concatenation
easyYou are given an array of distinct integers arr and an array of integer arrays pieces, where the integers in pieces are distinct.
Check Balanced String
easyYou are given a string num consisting of only digits.
Check Distances Between Same Letters
easyYou are given a 0-indexed string s consisting of only lowercase English letters, where each letter in s appears exactly twice.
Check if a String Is an Acronym of Words
easyGiven an array of strings words and a string s, determine if s is an acronym of words.
Check If a Word Occurs As a Prefix of Any Word in a Sentence
easyGiven a sentence that consists of some words separated by a single space, and a searchWord, check if searchWord is a prefix of any word in sentence.
Check If All 1's Are at Least Length K Places Away
easyGiven an binary array nums and an integer k, return true if all 1's are at least k places away from each other, otherwise return false.
Week 3: Recursion Basics
Convert a Sorted Array to a Balanced BST
easyBuild a height-balanced binary search tree from an array sorted in ascending order.
Fibonacci Number
easyThe Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1.
Find the K-th Character in String Game I
easyAlice and Bob are playing a game.
Invert Binary Tree
easyFlip a binary tree into its mirror image by swapping every node's left and right children.
Power of Four
easyGiven an integer n, return true if it is a power of four.
Power of Three
easyGiven an integer n, return true if it is a power of three.
Power of Two
easyGiven an integer n, return true if it is a power of two.
Range Sum of a BST
easySum every node value in a binary search tree that falls within a given inclusive range.
Reverse a Linked List
easyReverse a singly-linked list in place and return the reversed list.
Symmetric Tree
easyDetermine whether a binary tree is a mirror of itself around its center.
Unique 3-Digit Even Numbers
easyYou are given an array of digits called digits.
Count Collisions of Monkeys on a Polygon
mediumThere is a regular convex polygon with n vertices.
Count Good Numbers
mediumA digit string is good if the digits (0-indexed) at even indices are even and the digits at odd indices are prime (2, 3, 5, or 7).
Decode String
mediumGiven an encoded string, return its decoded string.
Delete a Node in a Binary Search Tree
mediumRemove the node with a given value from a binary search tree while preserving its ordering property.
Diameter of Binary Tree
mediumFind the length, in edges, of the longest path between any two nodes in a binary tree.
Different Ways to Add Parentheses
mediumGiven a string expression of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators.
Elimination Game
mediumYou have a list arr of all integers in the range [1, n] sorted in a strictly increasing order.
Find Kth Bit in Nth Binary String
mediumGiven two positive integers n and k, the binary string Sn is formed as follows: Where + denotes the concatenation operation, reverse(x) returns the reversed string x, and...
Find the Winner of the Circular Game
mediumThere are n friends that are playing a game.
K-th Symbol in Grammar
mediumWe build a table of n rows (1-indexed).
Week 4: Sorting Fundamentals
Check if Array is Good
easyYou are given an integer array nums.
Check If N and Its Double Exist
easyGiven an array arr of integers, check if there exist two indices i and j such that :
Contains Duplicate
easyGiven an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct.
Count Elements With Strictly Smaller and Greater Elements
easyGiven an integer array nums, return the number of elements that have both a strictly smaller and a strictly greater element appear in nums.
Coupon Code Validator
easyYou are given three arrays of length n that describe the properties of n coupons: code, businessLine, and isActive.
Delete Greatest Value in Each Row
easyYou are given an m x n matrix grid consisting of positive integers.
Divide an Array Into Subarrays With Minimum Cost I
easyYou are given an array of integers nums of length n.
Fair Candy Swap
easyAlice and Bob have a different total number of candies.
Find Resultant Array After Removing Anagrams
easyYou are given a 0-indexed string array words, where words[i] consists of lowercase English letters.
Find Subsequence of Length K With the Largest Sum
easyYou are given an integer array nums and an integer k.
Find Target Indices After Sorting Array
easyYou are given a 0-indexed integer array nums and a target element target.
Find the Difference
easyYou are given two strings s and t.
Find the Distance Value Between Two Arrays
easyGiven two integer arrays arr1 and arr2, and the integer d, return the distance value between the two arrays.
Finding 3-Digit Even Numbers
easyYou are given an integer array digits, where each element is a digit.
Height Checker
easyA school is trying to take an annual photo of all the students.
How Many Numbers Are Smaller Than the Current Number
easyGiven the array nums, for each nums[i] find out how many numbers in the array are smaller than it.
Intersection of Two Arrays
easyGiven two integer arrays nums1 and nums2, return an array of their intersection.
Intersection of Two Arrays II
easyGiven two integer arrays nums1 and nums2, return an array of their intersection.
Keep Multiplying Found Values by Two
easyYou are given an array of integers nums.
Largest Number After Digit Swaps by Parity
easyYou are given a positive integer num.
Largest Number At Least Twice of Others
easyYou are given an integer array nums where the largest integer is unique.
Week 5: Searching Fundamentals
Count Negative Numbers in a Sorted Matrix
easyGiven a m x n matrix grid which is sorted in non-increasing order both row-wise and column-wise, return the number of negative numbers in grid.
Count the Number of Incremovable Subarrays I
easyYou are given a 0-indexed array of positive integers nums.
Find Smallest Letter Greater Than Target
easyYou are given an array of characters letters that is sorted in non-decreasing order, and a character target.
Fruits Into Baskets II
easyYou are given two arrays of integers, fruits and baskets, each of length n, where fruits[i] represents the quantity of the ith type of fruit, and baskets[j] represents the...
Kth Missing Positive Number
easyGiven an array arr of positive integers sorted in a strictly increasing order, and an integer k.
Longest Subsequence With Limited Sum
easyYou are given an integer array nums of length n, and an integer array queries of length m.
Maximum Count of Positive Integer and Negative Integer
easyGiven an array nums sorted in non-decreasing order, return the maximum between the number of positive integers and the number of negative integers.
Minimum Common Value
easyGiven two integer arrays nums1 and nums2, sorted in non-decreasing order, return the minimum integer common to both arrays.
Missing Number
easyGiven an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array.
Search Insert Position
easyGiven a sorted array of distinct integers and a target value, return the index if the target is found.
Special Array With X Elements Greater Than or Equal X
easyYou are given an array nums of non-negative integers.
Sqrt(x)
easyGiven a non-negative integer x, return the square root of x rounded down to the nearest integer.
Valid Perfect Square
easyGiven a positive integer num, return true if num is a perfect square or false otherwise.
132 Pattern
mediumGiven an array of n integers nums, a 132 pattern is a subsequence of three integers nums[i], nums[j] and nums[k] such that i < j < k and nums[i] < nums[k] < nums[j].
Adjacent Increasing Subarrays Detection II
mediumGiven an array nums of n integers, your task is to find the maximum value of k for which there exist two adjacent subarrays of length k each, such that both subarrays are strictly...
Avoid Flood in The City
mediumYour country has an infinite number of lakes.
Capacity To Ship Packages Within D Days
mediumA conveyor belt has packages that must be shipped from one port to another within days days.
Closest Equal Element Queries
mediumYou are given a circular array nums and an array queries.
Compare Strings by Frequency of the Smallest Character
mediumLet the function f(s) be the frequency of the lexicographically smallest character in a non-empty string s.
Count Number of Rectangles Containing Each Point
mediumYou are given a 2D integer array rectangles where rectangles[i] = [li, hi] indicates that ith rectangle has a length of li and a height of hi.
Count the Number of Fair Pairs
mediumGiven a 0-indexed integer array nums of size n and two integers lower and upper, return the number of fair pairs.
Week 6: Hash Maps & Sets
Check if All Characters Have Equal Number of Occurrences
easyGiven a string s, return true if s is a good string, or false otherwise.
Check if All the Integers in a Range Are Covered
easyYou are given a 2D integer array ranges and two integers left and right.
Check if Any Element Has Prime Frequency
easyYou are given an integer array nums.
Check if Every Row and Column Contains All Numbers
easyAn n x n matrix is valid if every row and every column contains all the integers from 1 to n (inclusive).
Check if Number Has Equal Digit Count and Digit Value
easyYou are given a 0-indexed string num of length n consisting of digits.
Check if One String Swap Can Make Strings Equal
easyYou are given two strings s1 and s2 of equal length.
Check if The Number is Fascinating
easyYou are given an integer n that consists of exactly 3 digits.
Check if the Sentence Is Pangram
easyA pangram is a sentence where every letter of the English alphabet appears at least once.
Check Whether Two Strings are Almost Equivalent
easyTwo strings word1 and word2 are considered almost equivalent if the differences between the frequencies of each letter from 'a' to 'z' between word1 and word2 is at most 3.
Contains Duplicate II
easyGiven an integer array nums and an integer k, return true if there are two distinct indices i and j in the array such that nums[i] == nums[j] and abs(i - j) <= k.
Count Common Words With One Occurrence
easyGiven two string arrays words1 and words2, return the number of strings that appear exactly once in each of the two arrays.
Count Distinct Numbers on Board
easyYou are given a positive integer n, that is initially placed on a board.
Count Elements With Maximum Frequency
easyYou are given an array nums consisting of positive integers.
Count Largest Group
easyYou are given an integer n.
Count Number of Pairs With Absolute Difference K
easyGiven an integer array nums and an integer k, return the number of pairs (i, j) where i < j such that |nums[i] - nums[j]| == k.
Count Pairs Of Similar Strings
easyYou are given a 0-indexed string array words.
Count Pairs That Form a Complete Day I
easyGiven an integer array hours representing times in hours, return an integer denoting the number of pairs i, j where i < j and hours[i] + hours[j] forms a complete day.
Count Special Quadruplets
easyGiven a 0-indexed integer array nums, return the number of distinct quadruplets (a, b, c, d) such that:
Count the Number of Consistent Strings
easyYou are given a string allowed consisting of distinct characters and an array of strings words.
Count the Number of Special Characters I
easyYou are given a string word.
Count Vowel Substrings of a String
easyA substring is a contiguous (non-empty) sequence of characters within a string.
Week 7: Linked Lists
Linked List Cycle Detection
easyDetermine whether a singly-linked list loops back on itself instead of ending in null.
Merge Two Sorted Linked Lists
easySplice two sorted singly-linked lists together into a single sorted list.
Middle of the Linked List
easyFind the value stored in the middle node of a singly-linked list in a single pass.
Minimum Pair Removal to Sort Array I
easyGiven an array nums, you can perform the following operation any number of times: Return the minimum number of operations needed to make the array non-decreasing.
Palindrome Linked List
easyCheck whether the values in a singly-linked list read the same forwards and backwards.
Remove Duplicates From a Sorted Linked List
easyCollapse consecutive duplicate values in a sorted singly-linked list so each value appears once.
Remove Linked List Elements
easyDelete every node in a singly-linked list whose value matches a given target.
Add Two Numbers as Linked Lists
mediumAdd two non-negative integers stored as reverse-order digit linked lists and return the sum in the same format.
Odd-Even Linked List
mediumRegroup a singly-linked list so all odd-positioned nodes come before all even-positioned nodes.
Partition a List Around a Value
mediumStably rearrange a linked list so every node less than a pivot value comes before every node greater than or equal to it.
Remove the Nth Node From the End of a List
mediumRemove the node that sits n positions from the end of a singly-linked list, then return the list.
Reorder a Linked List
mediumRearrange a singly-linked list by alternating nodes from the front and the back until they meet in the middle.
Rotate a Linked List
mediumRotate a singly-linked list to the right by k places, wrapping around as needed.
Steps to Make Array Non-decreasing
mediumYou are given a 0-indexed integer array nums.
Swap Nodes in Pairs
mediumSwap every two adjacent nodes in a singly-linked list and return the new head.
Merge K Sorted Linked Lists
hardMerge k independently sorted linked lists into a single sorted linked list.
Minimum Pair Removal to Sort Array II
hardGiven an array nums, you can perform the following operation any number of times: Return the minimum number of operations needed to make the array non-decreasing.
Week 8: Stacks & Queues
Clear Digits
easyYou are given a string s.
Crawler Log Folder
easyA file system keeps a log each time some user performs a change folder operation.
Final Prices With a Special Discount in a Shop
easyYou are given an integer array prices where prices[i] is the price of the ith item in a shop.
First Unique Character in a String
easyGiven a string s, find the first non-repeating character in it and return its index.
Make The String Great
easyGiven a string s of lower and upper case English letters.
Maximum Nesting Depth of the Parentheses
easyGiven a valid parentheses string s, return the nesting depth of s.
Minimum String Length After Removing Substrings
easyYou are given a string s consisting only of uppercase English letters.
Next Greater Element I
easyThe next greater element of some element x in an array is the first greater element that is to the right of x in the same array.
Number of Students Unable to Eat Lunch
easyThe school cafeteria offers circular and square sandwiches at lunch break, referred to by numbers 0 and 1 respectively.
Remove All Adjacent Duplicates In String
easyYou are given a string s consisting of lowercase English letters.
Remove Outermost Parentheses
easyA valid parentheses string is either empty "", "(" + A + ")", or A + B, where A and B are valid parentheses strings, and + represents string concatenation.
Reverse Prefix of Word
easyGiven a 0-indexed string word and a character ch, reverse the segment of word that starts at index 0 and ends at the index of the first occurrence of ch (inclusive).
Time Needed to Buy Tickets
easyThere are n people in a line queuing to buy tickets, where the 0th person is at the front of the line and the (n - 1)th person is at the back of the line.
Valid Parentheses
easyDetermine if a string of brackets is properly matched and nested.
Asteroid Collision
mediumWe are given an array asteroids of integers representing asteroids in a row.
Basic Calculator II
mediumGiven a string s which represents an expression, evaluate this expression and return its value.
Beautiful Towers I
mediumYou are given an array heights of n integers representing the number of bricks in n consecutive towers.
Beautiful Towers II
mediumYou are given a 0-indexed array maxHeights of n integers.
Build an Array With Stack Operations
mediumYou are given an integer array target and an integer n.
Car Fleet
mediumThere are n cars at given miles away from the starting mile 0, traveling to reach the mile target.
Check if a Parentheses String Can Be Valid
mediumA parentheses string is a non-empty string consisting only of '(' and ')'.
Week 9: Trees Basics
Get All Root-to-Leaf Paths
easyReturn every root-to-leaf path in a binary tree as a list of node values, instead of an arrow-joined string.
Binary Tree Basics
easyAn introduction to the Node and BinTree building blocks used throughout the Binary Trees series, plus a sample tree these exercises build on.
Binary Tree Paths
easyReturn every root-to-leaf path in a binary tree as an arrow-joined string.
Binary Tree Traversals: Preorder, Inorder, Postorder
easyAdd preorder, inorder, and postorder traversal methods to BinTree and see how each visits the same sample tree in a different order.
Minimum Absolute Difference in a BST
easyFind the smallest absolute difference between the values of any two distinct nodes in a binary search tree.
Search in a Binary Search Tree
easyFind the node with a given value in a binary search tree and return the subtree rooted there.
Binary Tree Left Side View
mediumReturn the value of the leftmost node visible at each level of a binary tree, from top to bottom.
Print Left View of a Binary Tree
mediumPrint the first node visible at each level of the sample tree, extending level order traversal with a single boolean flag.
Binary Tree Level Order Traversal
mediumAdd a queue-based level order (breadth-first) traversal to BinTree, visiting the sample tree one level at a time.
Count Nodes With the Highest Score
mediumThere is a binary tree rooted at 0 consisting of n nodes.
Count Pairs of Connectable Servers in a Weighted Tree Network
mediumYou are given an unrooted weighted tree with n vertices representing servers numbered from 0 to n - 1, an array edges where edges[i] = [ai, bi, weighti] represents a bidirectional...
Count the Number of Good Nodes
mediumThere is an undirected tree with n nodes labeled from 0 to n - 1, and rooted at node 0.
Find Subtree Sizes After Changes
mediumYou are given a tree rooted at node 0 that consists of n nodes numbered from 0 to n - 1.
Insert into a Binary Search Tree
mediumInsert a new value into a binary search tree while preserving its ordering property.
Kth Smallest Element in a BST
mediumFind the k-th smallest value stored in a binary search tree.
Lowest Common Ancestor in a BST
mediumFind the lowest common ancestor of two given values in a binary search tree, using the tree's ordering to avoid a generic tree search.
Make Costs of Paths Equal in a Binary Tree
mediumYou are given an integer n representing the number of nodes in a perfect binary tree consisting of nodes numbered from 1 to n.
Maximize the Number of Target Nodes After Connecting Trees I
mediumThere exist two undirected trees with n and m nodes, with distinct labels in ranges [0, n - 1] and [0, m - 1], respectively.
Maximum Score After Applying Operations on a Tree
mediumThere is an undirected tree with n nodes labeled from 0 to n - 1, and rooted at node 0.
Minimum Fuel Cost to Report to the Capital
mediumThere is a tree (i.e., a connected, undirected graph with no cycles) structure country network consisting of n cities numbered from 0 to n - 1 and exactly n - 1 roads.
Minimum Increments to Equalize Leaf Paths
mediumYou are given an integer n and an undirected tree rooted at node 0 with n nodes numbered from 0 to n - 1.
Week 10: Graphs Basics
Find Center of Star Graph
easyThere is an undirected star graph consisting of n nodes labeled from 1 to n.
Find if Path Exists in Graph
easyThere is a bi-directional graph with n vertices, where each vertex is labeled from 0 to n - 1 (inclusive).
Find the Town Judge
easyIn a town, there are n people labeled from 1 to n.
Flood Fill
easyYou are given an image represented by an m x n grid of integers image, where image[i][j] represents the pixel value of the image.
Island Perimeter
easyYou are given row x col grid representing a map where grid[i][j] = 1 represents land and grid[i][j] = 0 represents water.
01 Matrix
mediumGiven an m x n binary matrix mat, return the distance of the nearest 0 for each cell.
Accounts Merge
mediumGiven a list of accounts where each element accounts[i] is a list of strings, where the first element accounts[i][0] is a name, and the rest of the elements are emails...
All Paths From Source to Target
mediumGiven a directed acyclic graph (DAG) of n nodes labeled from 0 to n - 1, find all possible paths from node 0 to node n - 1 and return them in any order.
Array Nesting
mediumYou are given an integer array nums of length n where nums is a permutation of the numbers in the range [0, n - 1].
As Far from Land as Possible
mediumGiven an n x n grid containing only values 0 and 1, where 0 represents water and 1 represents land, find a water cell such that its distance to the nearest land cell is maximized,...
Battleships in a Board
mediumGiven an m x n matrix board where each cell is a battleship 'X' or empty '.', return the number of the battleships on board.
Bulb Switcher II
mediumThere is a room with n bulbs labeled from 1 to n that all are turned on initially, and four buttons on the wall.
Cheapest Flights Within K Stops
mediumThere are n cities connected by some number of flights.
Check if There is a Valid Path in a Grid
mediumYou are given an m x n grid.
Check Knight Tour Configuration
mediumThere is a knight on an n x n chessboard.
Coin Change
mediumYou are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money.
Coloring A Border
mediumYou are given an m x n integer matrix grid, and three integers row, col, and color.
Count Islands With Total Value Divisible by K
mediumYou are given an m x n matrix grid and a positive integer k.
Count Servers that Communicate
mediumYou are given a map of a server center, represented as a m * n integer matrix grid, where 1 means that on that cell there is a server and 0 means that it is no server.
Count Sub Islands
mediumYou are given two m x n binary matrices grid1 and grid2 containing only 0's (representing water) and 1's (representing land).
Count the Number of Complete Components
mediumYou are given an integer n.
Week 11: Two Pointers & Sliding Window
Check If String Is a Prefix of Array
easyGiven a string s and an array of strings words, determine whether s is a prefix string of words.
Count Binary Substrings
easyGiven a binary string s, return the number of non-empty substrings that have the same number of 0's and 1's, and all the 0's and all the 1's in these substrings are grouped...
Count Substrings That Satisfy K-Constraint I
easyYou are given a binary string s and an integer k.
Defuse the Bomb
easyYou have a bomb to defuse, and your time is running out!
DI String Match
easyA permutation perm of n + 1 integers of all the integers in the range [0, n] can be represented as a string s of length n where: Given a string s, reconstruct the permutation perm...
Duplicate Zeros
easyGiven a fixed-length integer array arr, duplicate each occurrence of zero, shifting the remaining elements to the right.
Find All K-Distant Indices in an Array
easyYou are given a 0-indexed integer array nums and two integers key and k.
Find First Palindromic String in the Array
easyGiven an array of strings words, return the first palindromic string in the array.
Find Indices With Index and Value Difference I
easyYou are given a 0-indexed integer array nums having length n, an integer indexDifference, and an integer valueDifference.
Find the Array Concatenation Value
easyYou are given a 0-indexed integer array nums.
Find the Index of the First Occurrence in a String
easyGiven two strings needle and haystack, return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.
Find the K-Beauty of a Number
easyThe k-beauty of an integer num is defined as the number of substrings of num when it is read as a string that meet the following conditions: Given integers num and k, return the...
Find X-Sum of All K-Long Subarrays I
easyYou are given an array nums of n integers and two integers k and x.
Flipping an Image
easyGiven an n x n binary matrix image, flip the image horizontally, then invert it, and return the resulting image.
Happy Number
easyWrite an algorithm to determine if a number n is happy.
Is Subsequence
easyGiven two strings s and t, return true if s is a subsequence of t, or false otherwise.
Largest Positive Integer That Exists With Its Negative
easyGiven an integer array nums that does not contain any zeros, find the largest positive integer k such that -k also exists in the array.
Lexicographically Smallest Palindrome
easyYou are given a string s consisting of lowercase English letters, and you are allowed to perform operations on it.
Long Pressed Name
easyYour friend is typing his name into a keyboard.
Longest Even Odd Subarray With Threshold
easyYou are given a 0-indexed integer array nums and an integer threshold.
Longest Harmonious Subsequence
easyWe define a harmonious array as an array where the difference between its maximum value and its minimum value is exactly 1.
Week 12: Review & Mixed Practice
Binary Watch
easyA binary watch has 4 LEDs on the top to represent the hours (0-11), and 6 LEDs on the bottom to represent the minutes (0-59).
Check if All A's Appears Before All B's
easyGiven a string s consisting of only the characters 'a' and 'b', return true if every 'a' appears before every 'b' in the string.
Check if Array Is Sorted and Rotated
easyGiven an array nums, return true if the array was originally sorted in non-decreasing order, then rotated some number of positions (including zero).
Check if Binary String Has at Most One Segment of Ones
easyGiven a binary string s without leading zeros, return true if s contains at most one contiguous segment of ones.
Check if Bitwise OR Has Trailing Zeros
easyYou are given an array of positive integers nums.
Check If Digits Are Equal in String After Operations I
easyYou are given a string s consisting of digits.
Check if Grid Satisfies Conditions
easyYou are given a 2D matrix grid of size m x n.
Check If It Is a Straight Line
easyYou are given an array coordinates, coordinates[i] = [x, y], where [x, y] represents the coordinate of a point.
Check if Matrix Is X-Matrix
easyA square matrix is said to be an X-Matrix if both of the following conditions hold: Given a 2D integer array grid of size n x n representing a square matrix, return true if grid...
Check if Numbers Are Ascending in a Sentence
easyA sentence is a list of tokens separated by a single space with no leading or trailing spaces.
Check if Strings Can be Made Equal With Operations I
easyYou are given two strings s1 and s2, both of length 4, consisting of lowercase English letters.
Check if Two Chessboard Squares Have the Same Color
easyYou are given two strings, coordinate1 and coordinate2, representing the coordinates of a square on an 8 x 8 chessboard.
Check If Two String Arrays are Equivalent
easyGiven two string arrays word1 and word2, return true if the two arrays represent the same string, and false otherwise.
Check if Word Equals Summation of Two Words
easyThe letter value of a letter is its position in the alphabet starting from 0 (i.e.
Circular Sentence
easyA sentence is a list of words that are separated by a single space with no leading or trailing spaces.
Climbing Stairs
easyYou are climbing a staircase.
Concatenation of Array
easyGiven an integer array nums of length n, you want to create an array ans of length 2n where ans[i] == nums[i] and ans[i + n] == nums[i] for 0 <= i < n (0-indexed).
Consecutive Characters
easyThe power of the string is the maximum length of a non-empty substring that contains only one unique character.
Construct the Minimum Bitwise Array I
easyYou are given an array nums consisting of n prime integers.