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

easy
We 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

easy
Reversing an integer means to reverse all its digits.

Account Balance After Rounded Purchase

easy
Initially, you have a bank account balance of 100 dollars.

Add Binary

easy
Given two binary strings a and b, return their sum as a binary string.

Add Digits

easy
Given an integer num, repeatedly add all its digits until the result has only one digit, and return it.

Add Strings

easy
Given 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

easy
The array-form of an integer num is an array representing its digits in left to right order.

Adjacent Increasing Subarrays Detection I

easy
Given 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

easy
You are given a positive integer n.

Alternating Groups I

easy
There is a circle of red and blue tiles.

Ant on the Boundary

easy
An ant is on a boundary.

Apple Redistribution into Boxes

easy
You are given an array apple of size n and an array capacity of size m.

Apply Operations to an Array

easy
You are given a 0-indexed array nums of size n consisting of non-negative integers.

Arranging Coins

easy
You have n coins and you want to build a staircase with these coins.

Array Partition

easy
Given 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

easy
Assume you are an awesome parent and want to give your children some cookies.

Available Captures for Rook

easy
You are given an 8 x 8 matrix representing a chessboard.

Average Salary Excluding the Minimum and Maximum Salary

easy
You 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

easy
Given an integer array nums of positive integers, return the average value of all even integers that are divisible by 3.

Backspace String Compare

easy
Given two strings s and t, return true if they are equal when both are typed into empty text editors.

Base 7

easy
Given an integer num, return a string of its base 7 representation.

Week 2: Arrays & Strings Basics

Best Poker Hand

easy
You are given an integer array ranks and a character array suits.

Best Time to Buy and Sell Stock

easy
You are given an array prices where prices[i] is the price of a given stock on the ith day.

Binary Prefix Divisible By 5

easy
You are given a binary array nums (0-indexed).

Binary Search

easy
Given 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

easy
Given 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

easy
Given 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

easy
You 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

easy
You are given an integer array prices representing the prices of various chocolates in a store.

Calculate Amount Paid in Taxes

easy
You 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

easy
You are given a string s consisting of digits and an integer k.

Can Make Arithmetic Progression From Sequence

easy
A sequence of numbers is called an arithmetic progression if the difference between any two consecutive elements is the same.

Can Place Flowers

easy
You have a long flowerbed in which some of the plots are planted, and some are not.

Capitalize the Title

easy
You 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

easy
A 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

easy
There is an m x n matrix that is initialized to all 0's.

Check Array Formation Through Concatenation

easy
You 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

easy
You are given a string num consisting of only digits.

Check Distances Between Same Letters

easy
You 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

easy
Given 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

easy
Given 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

easy
Given 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

easy
Build a height-balanced binary search tree from an array sorted in ascending order.

Fibonacci Number

easy
The 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

easy
Alice and Bob are playing a game.

Invert Binary Tree

easy
Flip a binary tree into its mirror image by swapping every node's left and right children.

Power of Four

easy
Given an integer n, return true if it is a power of four.

Power of Three

easy
Given an integer n, return true if it is a power of three.

Power of Two

easy
Given an integer n, return true if it is a power of two.

Range Sum of a BST

easy
Sum every node value in a binary search tree that falls within a given inclusive range.

Reverse a Linked List

easy
Reverse a singly-linked list in place and return the reversed list.

Symmetric Tree

easy
Determine whether a binary tree is a mirror of itself around its center.

Unique 3-Digit Even Numbers

easy
You are given an array of digits called digits.

Count Collisions of Monkeys on a Polygon

medium
There is a regular convex polygon with n vertices.

Count Good Numbers

medium
A 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

medium
Given an encoded string, return its decoded string.

Delete a Node in a Binary Search Tree

medium
Remove the node with a given value from a binary search tree while preserving its ordering property.

Diameter of Binary Tree

medium
Find the length, in edges, of the longest path between any two nodes in a binary tree.

Different Ways to Add Parentheses

medium
Given 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

medium
You 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

medium
Given 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

medium
There are n friends that are playing a game.

K-th Symbol in Grammar

medium
We build a table of n rows (1-indexed).

Week 4: Sorting Fundamentals

Check if Array is Good

easy
You are given an integer array nums.

Check If N and Its Double Exist

easy
Given an array arr of integers, check if there exist two indices i and j such that :

Contains Duplicate

easy
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.

Count Elements With Strictly Smaller and Greater Elements

easy
Given 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

easy
You are given three arrays of length n that describe the properties of n coupons: code, businessLine, and isActive.

Delete Greatest Value in Each Row

easy
You are given an m x n matrix grid consisting of positive integers.

Divide an Array Into Subarrays With Minimum Cost I

easy
You are given an array of integers nums of length n.

Fair Candy Swap

easy
Alice and Bob have a different total number of candies.

Find Resultant Array After Removing Anagrams

easy
You 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

easy
You are given an integer array nums and an integer k.

Find Target Indices After Sorting Array

easy
You are given a 0-indexed integer array nums and a target element target.

Find the Difference

easy
You are given two strings s and t.

Find the Distance Value Between Two Arrays

easy
Given two integer arrays arr1 and arr2, and the integer d, return the distance value between the two arrays.

Finding 3-Digit Even Numbers

easy
You are given an integer array digits, where each element is a digit.

Height Checker

easy
A school is trying to take an annual photo of all the students.

How Many Numbers Are Smaller Than the Current Number

easy
Given the array nums, for each nums[i] find out how many numbers in the array are smaller than it.

Intersection of Two Arrays

easy
Given two integer arrays nums1 and nums2, return an array of their intersection.

Intersection of Two Arrays II

easy
Given two integer arrays nums1 and nums2, return an array of their intersection.

Keep Multiplying Found Values by Two

easy
You are given an array of integers nums.

Largest Number After Digit Swaps by Parity

easy
You are given a positive integer num.

Largest Number At Least Twice of Others

easy
You are given an integer array nums where the largest integer is unique.

Week 5: Searching Fundamentals

Count Negative Numbers in a Sorted Matrix

easy
Given 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

easy
You are given a 0-indexed array of positive integers nums.

Find Smallest Letter Greater Than Target

easy
You are given an array of characters letters that is sorted in non-decreasing order, and a character target.

Fruits Into Baskets II

easy
You 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

easy
Given an array arr of positive integers sorted in a strictly increasing order, and an integer k.

Longest Subsequence With Limited Sum

easy
You 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

easy
Given 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

easy
Given two integer arrays nums1 and nums2, sorted in non-decreasing order, return the minimum integer common to both arrays.

Missing Number

easy
Given 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

easy
Given 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

easy
You are given an array nums of non-negative integers.

Sqrt(x)

easy
Given a non-negative integer x, return the square root of x rounded down to the nearest integer.

Valid Perfect Square

easy
Given a positive integer num, return true if num is a perfect square or false otherwise.

132 Pattern

medium
Given 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

medium
Given 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

medium
Your country has an infinite number of lakes.

Capacity To Ship Packages Within D Days

medium
A conveyor belt has packages that must be shipped from one port to another within days days.

Closest Equal Element Queries

medium
You are given a circular array nums and an array queries.

Compare Strings by Frequency of the Smallest Character

medium
Let 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

medium
You 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

medium
Given 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

easy
Given a string s, return true if s is a good string, or false otherwise.

Check if All the Integers in a Range Are Covered

easy
You are given a 2D integer array ranges and two integers left and right.

Check if Any Element Has Prime Frequency

easy
You are given an integer array nums.

Check if Every Row and Column Contains All Numbers

easy
An 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

easy
You are given a 0-indexed string num of length n consisting of digits.

Check if One String Swap Can Make Strings Equal

easy
You are given two strings s1 and s2 of equal length.

Check if The Number is Fascinating

easy
You are given an integer n that consists of exactly 3 digits.

Check if the Sentence Is Pangram

easy
A pangram is a sentence where every letter of the English alphabet appears at least once.

Check Whether Two Strings are Almost Equivalent

easy
Two 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

easy
Given 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

easy
Given 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

easy
You are given a positive integer n, that is initially placed on a board.

Count Elements With Maximum Frequency

easy
You are given an array nums consisting of positive integers.

Count Largest Group

easy
You are given an integer n.

Count Number of Pairs With Absolute Difference K

easy
Given 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

easy
You are given a 0-indexed string array words.

Count Pairs That Form a Complete Day I

easy
Given 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

easy
Given a 0-indexed integer array nums, return the number of distinct quadruplets (a, b, c, d) such that:

Count the Number of Consistent Strings

easy
You are given a string allowed consisting of distinct characters and an array of strings words.

Count the Number of Special Characters I

easy
You are given a string word.

Count Vowel Substrings of a String

easy
A substring is a contiguous (non-empty) sequence of characters within a string.

Week 7: Linked Lists

Linked List Cycle Detection

easy
Determine whether a singly-linked list loops back on itself instead of ending in null.

Merge Two Sorted Linked Lists

easy
Splice two sorted singly-linked lists together into a single sorted list.

Middle of the Linked List

easy
Find the value stored in the middle node of a singly-linked list in a single pass.

Minimum Pair Removal to Sort Array I

easy
Given 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

easy
Check whether the values in a singly-linked list read the same forwards and backwards.

Remove Duplicates From a Sorted Linked List

easy
Collapse consecutive duplicate values in a sorted singly-linked list so each value appears once.

Remove Linked List Elements

easy
Delete every node in a singly-linked list whose value matches a given target.

Add Two Numbers as Linked Lists

medium
Add two non-negative integers stored as reverse-order digit linked lists and return the sum in the same format.

Odd-Even Linked List

medium
Regroup a singly-linked list so all odd-positioned nodes come before all even-positioned nodes.

Partition a List Around a Value

medium
Stably 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

medium
Remove the node that sits n positions from the end of a singly-linked list, then return the list.

Reorder a Linked List

medium
Rearrange a singly-linked list by alternating nodes from the front and the back until they meet in the middle.

Rotate a Linked List

medium
Rotate a singly-linked list to the right by k places, wrapping around as needed.

Steps to Make Array Non-decreasing

medium
You are given a 0-indexed integer array nums.

Swap Nodes in Pairs

medium
Swap every two adjacent nodes in a singly-linked list and return the new head.

Merge K Sorted Linked Lists

hard
Merge k independently sorted linked lists into a single sorted linked list.

Minimum Pair Removal to Sort Array II

hard
Given 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

easy
You are given a string s.

Crawler Log Folder

easy
A file system keeps a log each time some user performs a change folder operation.

Final Prices With a Special Discount in a Shop

easy
You 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

easy
Given a string s, find the first non-repeating character in it and return its index.

Make The String Great

easy
Given a string s of lower and upper case English letters.

Maximum Nesting Depth of the Parentheses

easy
Given a valid parentheses string s, return the nesting depth of s.

Minimum String Length After Removing Substrings

easy
You are given a string s consisting only of uppercase English letters.

Next Greater Element I

easy
The 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

easy
The school cafeteria offers circular and square sandwiches at lunch break, referred to by numbers 0 and 1 respectively.

Remove All Adjacent Duplicates In String

easy
You are given a string s consisting of lowercase English letters.

Remove Outermost Parentheses

easy
A 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

easy
Given 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

easy
There 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

easy
Determine if a string of brackets is properly matched and nested.

Asteroid Collision

medium
We are given an array asteroids of integers representing asteroids in a row.

Basic Calculator II

medium
Given a string s which represents an expression, evaluate this expression and return its value.

Beautiful Towers I

medium
You are given an array heights of n integers representing the number of bricks in n consecutive towers.

Beautiful Towers II

medium
You are given a 0-indexed array maxHeights of n integers.

Build an Array With Stack Operations

medium
You are given an integer array target and an integer n.

Car Fleet

medium
There 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

medium
A parentheses string is a non-empty string consisting only of '(' and ')'.

Week 9: Trees Basics

Get All Root-to-Leaf Paths

easy
Return every root-to-leaf path in a binary tree as a list of node values, instead of an arrow-joined string.

Binary Tree Basics

easy
An 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

easy
Return every root-to-leaf path in a binary tree as an arrow-joined string.

Binary Tree Traversals: Preorder, Inorder, Postorder

easy
Add 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

easy
Find the smallest absolute difference between the values of any two distinct nodes in a binary search tree.

Search in a Binary Search Tree

easy
Find the node with a given value in a binary search tree and return the subtree rooted there.

Binary Tree Left Side View

medium
Return 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

medium
Print 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

medium
Add 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

medium
There is a binary tree rooted at 0 consisting of n nodes.

Count Pairs of Connectable Servers in a Weighted Tree Network

medium
You 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

medium
There is an undirected tree with n nodes labeled from 0 to n - 1, and rooted at node 0.

Find Subtree Sizes After Changes

medium
You 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

medium
Insert a new value into a binary search tree while preserving its ordering property.

Kth Smallest Element in a BST

medium
Find the k-th smallest value stored in a binary search tree.

Lowest Common Ancestor in a BST

medium
Find 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

medium
You 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

medium
There 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

medium
There 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

medium
There 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

medium
You 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

easy
There is an undirected star graph consisting of n nodes labeled from 1 to n.

Find if Path Exists in Graph

easy
There is a bi-directional graph with n vertices, where each vertex is labeled from 0 to n - 1 (inclusive).

Find the Town Judge

easy
In a town, there are n people labeled from 1 to n.

Flood Fill

easy
You 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

easy
You 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

medium
Given an m x n binary matrix mat, return the distance of the nearest 0 for each cell.

Accounts Merge

medium
Given 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

medium
Given 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

medium
You 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

medium
Given 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

medium
Given 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

medium
There 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

medium
There are n cities connected by some number of flights.

Check if There is a Valid Path in a Grid

medium
You are given an m x n grid.

Check Knight Tour Configuration

medium
There is a knight on an n x n chessboard.

Coin Change

medium
You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money.

Coloring A Border

medium
You are given an m x n integer matrix grid, and three integers row, col, and color.

Count Islands With Total Value Divisible by K

medium
You are given an m x n matrix grid and a positive integer k.

Count Servers that Communicate

medium
You 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

medium
You 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

medium
You are given an integer n.

Week 11: Two Pointers & Sliding Window

Check If String Is a Prefix of Array

easy
Given a string s and an array of strings words, determine whether s is a prefix string of words.

Count Binary Substrings

easy
Given 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

easy
You are given a binary string s and an integer k.

Defuse the Bomb

easy
You have a bomb to defuse, and your time is running out!

DI String Match

easy
A 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

easy
Given 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

easy
You are given a 0-indexed integer array nums and two integers key and k.

Find First Palindromic String in the Array

easy
Given an array of strings words, return the first palindromic string in the array.

Find Indices With Index and Value Difference I

easy
You are given a 0-indexed integer array nums having length n, an integer indexDifference, and an integer valueDifference.

Find the Array Concatenation Value

easy
You are given a 0-indexed integer array nums.

Find the Index of the First Occurrence in a String

easy
Given 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

easy
The 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

easy
You are given an array nums of n integers and two integers k and x.

Flipping an Image

easy
Given an n x n binary matrix image, flip the image horizontally, then invert it, and return the resulting image.

Happy Number

easy
Write an algorithm to determine if a number n is happy.

Is Subsequence

easy
Given 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

easy
Given 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

easy
You are given a string s consisting of lowercase English letters, and you are allowed to perform operations on it.

Long Pressed Name

easy
Your friend is typing his name into a keyboard.

Longest Even Odd Subarray With Threshold

easy
You are given a 0-indexed integer array nums and an integer threshold.

Longest Harmonious Subsequence

easy
We 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

easy
A 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

easy
Given 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

easy
Given 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

easy
Given 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

easy
You are given an array of positive integers nums.

Check If Digits Are Equal in String After Operations I

easy
You are given a string s consisting of digits.

Check if Grid Satisfies Conditions

easy
You are given a 2D matrix grid of size m x n.

Check If It Is a Straight Line

easy
You are given an array coordinates, coordinates[i] = [x, y], where [x, y] represents the coordinate of a point.

Check if Matrix Is X-Matrix

easy
A 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

easy
A 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

easy
You 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

easy
You 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

easy
Given 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

easy
The letter value of a letter is its position in the alphabet starting from 0 (i.e.

Circular Sentence

easy
A sentence is a list of words that are separated by a single space with no leading or trailing spaces.

Climbing Stairs

easy
You are climbing a staircase.

Concatenation of Array

easy
Given 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

easy
The 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

easy
You are given an array nums consisting of n prime integers.