brain

tamnd's digital brain — notes, problems, research

43815 notes

LeetCode 778 - Swim in Rising Water

In this problem, we are given an n x n grid where each cell contains a unique integer representing its elevation. Rain begins falling, and the water level rises over time.

leetcodehardarraybinary-searchdepth-first-searchbreadth-first-searchunion-findheap-(priority-queue)matrix
LeetCode 441 - Arranging Coins

The problem asks us to determine how many complete rows of a coin staircase can be formed using exactly n coins. A staircase arrangement follows a very specific structure: - The first row contains 1 coin - The second row contains 2 coins - The third row contains 3 coins -…

leetcodeeasymathbinary-search
CF 10D - LCIS

We are given two integer arrays. We need to build the longest sequence that satisfies two conditions at the same time.

codeforcescompetitive-programmingdp
CF 86D - Powerful array

We are given an array of positive integers and many interval queries. For each query [l, r], we look only at the subarray between those indices and compute a value called its power. If a number x appears k times inside the subarray, then x contributes k² x to the answer.

codeforcescompetitive-programmingdata-structuresimplementationmathtwo-pointers
LeetCode 1384 - Total Sales Amount by Year

This is a SQL database problem where we need to calculate the total sales amount per product for each year, even when a

leetcodeharddatabase
LeetCode 634 - Find the Derangement of An Array

The problem asks us to count how many permutations of the numbers 1 through n are valid derangements. A derangement is a permutation where no element remains in its original position. For example, when n = 3, the original array is [1, 2, 3].

leetcodemediummathdynamic-programmingcombinatorics
LeetCode 576 - Out of Boundary Paths

This problem asks us to count how many different ways a ball can leave the boundaries of a grid within a limited number of moves.

leetcodemediumdynamic-programming
CF 29A - Spit Problem

Each camel stands at a unique coordinate on a number line. A camel at position x spits exactly toward position x + d. If another camel stands there, it gets hit. We need to determine whether there exists a pair of camels such that each one hits the other.

codeforcescompetitive-programmingbrute-force
LeetCode 631 - Design Excel Sum Formula

The problem asks us to design a miniature spreadsheet system similar to Microsoft Excel. The spreadsheet contains cells arranged in rows and columns, where rows are numbered starting from 1 and columns are labeled using uppercase letters such as A, B, C, and so on.

leetcodehardarrayhash-tablestringgraph-theorydesigntopological-sortmatrix
LeetCode 1749 - Maximum Absolute Sum of Any Subarray

The problem asks us to calculate the maximum absolute sum of any contiguous subarray in a given integer array nums. A subarray is a sequence of consecutive elements, and its absolute sum is defined as the absolute value of the sum of all elements in that subarray.

leetcodemediumarraydynamic-programming
CF 137E - Last Chance

We are given a string s consisting of uppercase and lowercase Latin letters, and we are asked to analyze its substrings according to a specific property: a substring is "good" if the number of vowels it contains is at most twice the number of consonants.

codeforcescompetitive-programmingdata-structuresimplementationstrings
LeetCode 98 - Validate Binary Search Tree

This problem asks us to determine whether a given binary tree satisfies the rules of a Binary Search Tree, commonly abbreviated as BST. A binary tree consists of nodes where each node contains a value and pointers to a left child and a right child.

leetcodemediumtreedepth-first-searchbinary-search-treebinary-tree
LeetCode 1054 - Distant Barcodes

The problem is asking us to rearrange a list of barcodes so that no two adjacent barcodes are the same. The input is an array barcodes of integers where each integer represents a type of barcode. The output should be a rearranged array that satisfies the adjacency constraint.

leetcodemediumarrayhash-tablegreedysortingheap-(priority-queue)counting
CF 60B - Serial Time!

We are given a three-dimensional grid representing the inside of a plate. The grid has k layers, each layer has n rows and m columns. Every cell is either empty . or blocked . Water starts entering from one specific cell on the top layer.

codeforcescompetitive-programmingdfs-and-similardsu
LeetCode 110 - Balanced Binary Tree

This problem asks us to determine whether a given binary tree is height-balanced. A binary tree is considered height-balanced if, for every node in the tree, the height difference between its left and right subtrees is at most 1.

leetcodeeasytreedepth-first-searchbinary-tree
LeetCode 1489 - Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree

The problem gives us a connected, weighted, undirected graph with n vertices and a list of edges. Each edge is represented as [u, v, weight], meaning there is a bidirectional connection between vertices u and v with the given cost.

leetcodehardunion-findgraph-theorysortingminimum-spanning-treestrongly-connected-component
LeetCode 1906 - Minimum Absolute Difference Queries

The problem asks us to compute the minimum absolute difference in subarrays of a given integer array nums for multiple q

leetcodemediumarrayprefix-sum
LeetCode 988 - Smallest String Starting From Leaf

The problem gives us the root of a binary tree where every node stores an integer between 0 and 25. Each integer corresponds to a lowercase English letter: - 0 - 'a' - 1 - 'b' - ... - 25 - 'z' We need to construct strings that begin at a leaf node and move upward toward the root.

leetcodemediumstringbacktrackingtreedepth-first-searchbinary-tree
LeetCode 230 - Kth Smallest Element in a BST

This problem gives us the root of a Binary Search Tree, abbreviated as BST, along with an integer k. We need to return the kth smallest value in the tree. A Binary Search Tree has a very important property: - Every value in the left subtree is smaller than the current node.

leetcodemediumtreedepth-first-searchbinary-search-treebinary-tree
LeetCode 3052 - Maximize Items

The problem requires determining how many items can be stored in a warehouse with a limited square footage of 500,000. T

leetcodeharddatabase
LeetCode 1341 - Movie Rating

This problem works with three relational database tables: Movies, Users, and MovieRating. The goal is to produce a result containing exactly two rows. The first row should contain the name of the user who rated the greatest number of movies.

leetcodemediumdatabase
LeetCode 1058 - Minimize Rounding Error to Meet Target

The problem asks us to round an array of decimal prices to integers such that the sum of the rounded numbers equals a given target, while minimizing the total rounding error. Each price can be rounded either down (Floor) or up (Ceil).

leetcodemediumarraymathstringgreedysorting
CF 136B - Ternary Logic

We are given two decimal integers, a and c. The computer in this problem does not use binary xor. Instead, it uses a ternary operation called tor. To apply tor, both numbers are written in base 3.

codeforcescompetitive-programmingimplementationmath
LeetCode 1837 - Sum of Digits in Base K

The problem is asking us to convert a given integer n from base 10 into another base k, then compute the sum of its digits in that base. For example, if n is 34 and k is 6, first we convert 34 into base 6, which yields 54, and then sum the digits: 5 + 4 = 9.

leetcodeeasymath
CF 29E - Quarrel

We are asked to route two people, Bob and Alex, across a town represented as an undirected graph with n crossroads and m roads. Bob starts at node 1 and wants to reach node n, while Alex starts at node n and wants to reach node 1.

codeforcescompetitive-programminggraphsshortest-paths
LeetCode 760 - Find Anagram Mappings

The problem asks us to build an index mapping from nums1 to nums2, where nums2 is guaranteed to be an anagram of nums1. Since an anagram means the same elements appear in both arrays, but possibly in a different order, every value in nums1 must appear somewhere in nums2.

leetcodeeasyarrayhash-table
LeetCode 1655 - Distribute Repeating Integers

This problem asks whether we can satisfy a set of customer requests using repeated integers from the array nums. Each customer wants a certain quantity of numbers, given by quantity[i]. The important restriction is that every number given to a single customer must be identical.

leetcodehardarrayhash-tabledynamic-programmingbacktrackingbit-manipulationcountingbitmask
CF 121B - Lucky Transformation

We are given a decimal string and an operation count k. Each operation looks for the leftmost occurrence of the substring "47". Suppose the substring "47" starts at position x using 1-based indexing. If x is odd, we replace both digits with '4', so "47" becomes "44".

codeforcescompetitive-programmingstrings
LeetCode 31 - Next Permutation

The problem asks us to modify an integer array so that it becomes the next lexicographically greater permutation of its current arrangement. A permutation is simply an ordering of the elements. Lexicographical order works the same way dictionary order works for words.

leetcodemediumarraytwo-pointers
LeetCode 428 - Serialize and Deserialize N-ary Tree

LeetCode 428, LeetCode Serialize and Deserialize N-ary Tree, asks us to design a reversible encoding system for an N-ary tree. The problem is not asking for a specific serialization format.

leetcodehardstringtreedepth-first-searchbreadth-first-search
LeetCode 647 - Palindromic Substrings

The problem asks us to count how many palindromic substrings exist inside a given string s. A substring is any contiguous segment of the string. This means we cannot rearrange characters or skip positions.

leetcodemediumtwo-pointersstringdynamic-programming
LeetCode 700 - Search in a Binary Search Tree

This problem gives us the root node of a Binary Search Tree, commonly abbreviated as a BST, along with an integer value val. Our goal is to locate the node whose value is exactly equal to val and return that node.

leetcodeeasytreebinary-search-treebinary-tree
CF 76C - Mutation

We are given a string representing the genome of an organism, where each character is one of the first K capital letters. Adjacent genes contribute to the total “risk of disease” according to a given K × K matrix of non-negative integers.

codeforcescompetitive-programmingbitmasksdpmath
LeetCode 1001 - Grid Illumination

This problem models a very large chessboard-like grid where certain cells contain active lamps. A lamp illuminates four directions simultaneously: - Its entire row - Its entire column - Its main diagonal, identified by row - col - Its anti-diagonal, identified by row + col For…

leetcodehardarrayhash-table
LeetCode 1343 - Number of Sub-arrays of Size K and Average Greater than or Equal to Threshold

This problem asks us to count how many contiguous subarrays of length k have an average value greater than or equal to a

leetcodemediumarraysliding-window
LeetCode 1466 - Reorder Routes to Make All Paths Lead to the City Zero

The problem gives us a directed graph of cities connected by roads. There are n cities numbered from 0 to n - 1, and exactly n - 1 roads. Since the graph contains n - 1 edges and there is exactly one path between any pair of cities, the graph forms a tree.

leetcodemediumdepth-first-searchbreadth-first-searchgraph-theory
LeetCode 386 - Lexicographical Numbers

The problem asks us to generate all integers from 1 to n, but not in normal numerical order. Instead, the numbers must appear in lexicographical order, also called dictionary order. Lexicographical order compares numbers as strings rather than as numeric values.

leetcodemediumdepth-first-searchtrie
LeetCode 138 - Copy List with Random Pointer

This problem asks us to create a completely independent copy of a linked list where each node contains two pointers: - next, which points to the next node in the list - random, which can point to any node in the list or null The key requirement is that the copied list must be…

leetcodemediumhash-tablelinked-list
LeetCode 1317 - Convert Integer to the Sum of Two No-Zero Integers

The problem asks us to split a given integer n into two positive integers a and b such that: - a + b = n - Neither a nor b contains the digit 0 anywhere in their decimal representation Such integers are called No-Zero integers.

leetcodeeasymath
LeetCode 360 - Sort Transformed Array

The problem gives us a sorted integer array nums and a quadratic transformation function: We must apply this function to every element in the array and return the transformed values in sorted order.

leetcodemediumarraymathtwo-pointerssorting
LeetCode 1262 - Greatest Sum Divisible by Three

The problem asks us to find the maximum sum of elements from an integer array nums such that the sum is divisible by thr

leetcodemediumarraydynamic-programminggreedysorting
CF 28C - Bath Queue

Every student independently chooses one of the bathroom rooms uniformly at random. A room may contain several wash basins, so students entering that room are split into several queues.

codeforcescompetitive-programmingcombinatoricsdpprobabilities
LeetCode 1407 - Top Travellers

This problem gives us two database tables, Users and Rides. The Users table contains information about each user. Every user has a unique id and a corresponding name. The Rides table contains ride records.

leetcodeeasydatabase
CF 94B - Friends

We have exactly five people. Some pairs of people know each other, and the input lists all such acquaintance relations. The task is to determine whether there exists either: 1. Three people where every pair knows each other. 2. Three people where no pair knows each other.

codeforcescompetitive-programminggraphsimplementationmath
LeetCode 1727 - Largest Submatrix With Rearrangements

The problem gives us a binary matrix, meaning every cell contains either 0 or 1. We are allowed to rearrange the columns of the matrix in any order we want.

leetcodemediumarraygreedysortingmatrix
LeetCode 35 - Search Insert Position

The problem gives us a sorted array of distinct integers and a target value. Our task is to determine where the target belongs in the array. If the target already exists, we return its index.

leetcodeeasyarraybinary-search
LeetCode 1360 - Number of Days Between Two Dates

The problem gives two dates in the format YYYY-MM-DD and asks us to compute the absolute number of days between them. Each input string represents a valid calendar date. The year, month, and day are separated by hyphens.

leetcodeeasymathstring
LeetCode 967 - Numbers With Same Consecutive Differences

The problem asks us to generate all integers of length n such that the absolute difference between every two consecutive digits is exactly k.

leetcodemediumbacktrackingbreadth-first-search
LeetCode 1681 - Minimum Incompatibility

The problem is asking us to partition an integer array nums into exactly k subsets of equal size, such that no subset co

leetcodehardarrayhash-tabledynamic-programmingbit-manipulationbitmask
LeetCode 1738 - Find Kth Largest XOR Coordinate Value

The problem asks us to compute the XOR coordinate value for each element in a given 2D matrix and then find the kth largest among them.

leetcodemediumarraydivide-and-conquerbit-manipulationsortingheap-(priority-queue)matrixprefix-sumquickselect
LeetCode 499 - The Maze III

This problem extends the mechanics introduced in earlier Maze problems, but adds two important complications. First, we are no longer looking for a simple reachable or unreachable answer. Instead, we must find the shortest path by travel distance.

leetcodehardarraystringdepth-first-searchbreadth-first-searchgraph-theoryheap-(priority-queue)matrixshortest-path
CF 80A - Panoramix's Prediction

Yesterday the Gauls defeated n Roman soldiers, and n is guaranteed to be a prime number. Today they defeated m soldiers, where m n. We need to decide whether m is exactly the next prime number that comes immediately after n. The key detail is the phrase "next prime".

codeforcescompetitive-programmingbrute-force
LeetCode 2018 - Check if Word Can Be Placed In Crossword

This problem asks us to determine whether a given word can be legally placed into a crossword board while respecting crossword placement rules.

leetcodemediumarraymatrixenumeration
CF 6E - Exposition

We are given a sequence of books by Berlbury, each with a known height, arranged chronologically. The library wants to organize an exposition by selecting consecutive books such that the difference between the tallest and shortest book in the selection does not exceed a given…

codeforcescompetitive-programmingbinary-searchdata-structuresdsutreestwo-pointers
LeetCode 627 - Swap Sex of Employees

The problem is asking us to swap the sex values of all employees in a Salary table. Each row in the table represents an employee with four columns: id, name, sex, and salary. The sex column is an ENUM with values 'm' for male and 'f' for female.

leetcodeeasydatabase
LeetCode 584 - Find Customer Referee

The problem provides a Customer table with three columns: id, name, and refereeid. Each row represents a customer, their unique identifier (id), their name, and optionally the id of the customer who referred them.

leetcodeeasydatabase
LeetCode 1050 - Actors and Directors Who Cooperated At Least Three Times

This problem asks us to identify every (actorid, directorid) pair where an actor and a director have collaborated at least three times. The input is a database table named ActorDirector. Each row represents one collaboration event between an actor and a director.

leetcodeeasydatabase
CF 56B - Spoilt Permutation

We start from the sorted permutation 1 2 3 ... n. Someone chooses exactly one contiguous segment and reverses it. We are given the final permutation and must determine whether it could have been produced by exactly one such reversal. The task is not to sort the array.

codeforcescompetitive-programmingimplementation
LeetCode 1732 - Find the Highest Altitude

In this problem, a biker starts at altitude 0 and travels through a sequence of roads. The input array gain describes how the biker's altitude changes between consecutive points on the trip. If gain[i] is positive, the biker climbs upward between point i and point i + 1.

leetcodeeasyarrayprefix-sum
LeetCode 1243 - Array Transformation

The problem requires simulating the transformation of an array over consecutive days according to a simple local rule. Each day, every element of the array (except the first and last) is compared with its immediate neighbors.

leetcodeeasyarraysimulation
CF 33C - Wonderful Randomized Sum

We are given a sequence of integers, and the task is to maximize its sum by performing two operations: first, we may choose any prefix of the sequence and multiply every element in it by -1; second, we may choose any suffix of the sequence and multiply every element in it by -1.

codeforcescompetitive-programminggreedy
LeetCode 1207 - Unique Number of Occurrences

The problem gives us an integer array arr and asks whether every distinct number appears a unique number of times. In other words, we first count how many times each value occurs in the array.

leetcodeeasyarrayhash-table
LeetCode 1454 - Active Users

The problem asks us to identify active users from a database containing two tables: Accounts and Logins. The Accounts ta

leetcodemediumdatabase
CF 68E - Contact

We are given exactly four triangles. Each triangle represents the shape of one spaceship. A landing platform is just a set of points in the plane, called columns. A ship can land if we can choose three columns that form a triangle congruent to the ship.

codeforcescompetitive-programminggeometry
CF 132D - Constants in the language of Shakespeare

We are asked to represent a positive integer given in binary as a sum of powers of two, with the option of using negative powers, such that the total number of terms is minimized. Formally, we want to write the number as a sum of expressions of the form +2^x or -2^x.

codeforcescompetitive-programmingconstructive-algorithmsdpgreedy
LeetCode 340 - Longest Substring with At Most K Distinct Characters

The problem asks us to find the length of the longest contiguous substring in a given string s such that the substring contains at most k distinct characters. A substring is a continuous portion of the string.

leetcodemediumhash-tablestringsliding-window
LeetCode 2012 - Sum of Beauty in the Array

The problem asks us to compute a "beauty" score for each element in an array nums, excluding the first and last elements. Specifically, for each index i in the range 1 <= i <= nums.length - 2, the beauty of nums[i] is determined by two conditions: 1.

leetcodemediumarray
CF 69E - Subsegments

We are given an array of integers and a fixed window size k. For each contiguous subarray (segment) of length k, we need to find the largest element that appears exactly once within that segment. If no element appears exactly once, we output "Nothing".

codeforcescompetitive-programmingdata-structuresimplementation
LeetCode 1359 - Count All Valid Pickup and Delivery Options

This problem asks us to count the number of valid sequences for performing pickups and deliveries for n orders. Each ord

leetcodehardmathdynamic-programmingcombinatorics
LeetCode 17 - Letter Combinations of a Phone Number

The problem gives a string of digits where each digit is between 2 and 9. Each digit corresponds to a set of letters on a traditional phone keypad: - 2 - "abc" - 3 - "def" - 4 - "ghi" - 5 - "jkl" - 6 - "mno" - 7 - "pqrs" - 8 - "tuv" - 9 - "wxyz" We must generate every possible…

leetcodemediumhash-tablestringbacktracking
CF 4A - Watermelon

The problem gives a single integer w, the weight of a watermelon. We need to decide whether it can be split into two positive parts such that both parts are even numbers.

codeforcescompetitive-programmingbrute-forcemath
CF 19B - Checkout Assistant

Each item has two properties. If Bob pays for that item, the cashier spends t[i] seconds processing it and Bob also spends c[i] money. During those t[i] seconds, Bob can steal other items, one item per second.

codeforcescompetitive-programmingdp
CF 1941F - Rudolf and Imbalance

We start with a strictly increasing array of problem complexities. The imbalance of the set is defined as the largest difference between two neighboring elements after sorting.

codeforcescompetitive-programmingbinary-searchgreedysortingstwo-pointers
LeetCode 1457 - Pseudo-Palindromic Paths in a Binary Tree

This problem asks us to count how many root to leaf paths in a binary tree are "pseudo-palindromic". A palindrome is a s

leetcodemediumbit-manipulationtreedepth-first-searchbreadth-first-searchbinary-tree
CF 114A - Cifera

We are given two integers, k and l. The task is to determine whether l can be written as an exact power of k. In other words, we need to check whether there exists a non-negative integer n such that: $l = k^n$ If such an n exists, we print "YES" and also print the importance…

codeforcescompetitive-programmingmath
LeetCode 1495 - Friendly Movies Streamed Last Month

This problem asks us to find the titles of movies that satisfy three separate conditions at the same time. First, the content must be marked as kid-friendly. In the Content table, this is represented by the column Kidscontent = 'Y'. Second, the content must actually be a movie.

leetcodeeasydatabase
LeetCode 2224 - Minimum Number of Operations to Convert Time

The problem asks us to calculate the minimum number of operations to convert one 24-hour time string, current, into anot

leetcodeeasystringgreedy
CF 44C - Holidays

We are asked to verify a watering schedule for flowers over a set of consecutive holiday days. Each day must be watered exactly once. The schedule specifies, for each of several people, the range of days they are assigned to water the flowers.

codeforcescompetitive-programmingimplementation
LeetCode 533 - Lonely Pixel II

The problem gives us a matrix called picture, where each cell contains either 'B' for a black pixel or 'W' for a white pixel. We are also given an integer target. We need to count how many black pixels qualify as "lonely pixels" under two strict conditions.

leetcodemediumarrayhash-tablematrix
LeetCode 648 - Replace Words

The problem asks us to replace words in a sentence using a set of predefined root words. A root is a shorter word that can serve as a prefix for a longer derivative word.

leetcodemediumarrayhash-tablestringtrie
CF 58A - Chat room

The problem asks whether Vasya, who typed a string of lowercase letters, effectively managed to say "hello". The goal is not to check if the typed string is exactly "hello", but whether we can remove some letters (possibly zero) to produce the sequence h, e, l, l, o in order.

codeforcescompetitive-programminggreedystrings
LeetCode 1823 - Find the Winner of the Circular Game

The problem describes a variation of the classic Josephus problem. We have n friends sitting in a circle, numbered 1 through n clockwise. Starting from the first friend, we count k friends clockwise (inclusive of the starting friend).

leetcodemediumarraymathrecursionqueuesimulation
LeetCode 637 - Average of Levels in Binary Tree

In this problem, we are given the root node of a binary tree, and we need to compute the average value of all nodes at each depth level of the tree. A binary tree is organized into levels.

leetcodeeasytreedepth-first-searchbreadth-first-searchbinary-tree
CF 118D - Caesar's Legions

We are asked to count the number of ways to line up Caesar’s soldiers, consisting of a given number of footmen and horsemen, so that no more than a fixed number of the same type stand consecutively.

codeforcescompetitive-programmingdp
CF 45B - School

Each student points to exactly one other student, the person they call whenever they hear news. This creates a directed functional graph, every node has out-degree exactly one.

codeforcescompetitive-programmingdpdsu
CF 32C - Flea

We have a grid of size where each cell is 1 centimeter square. A flea starts at some cell and can jump exactly centimeters either vertically or horizontally, staying inside the board.

codeforcescompetitive-programmingmath
LeetCode 517 - Super Washing Machines

The problem gives us a line of washing machines, where each machine contains some number of dresses. In one move, we are allowed to choose any subset of machines, and every chosen machine may pass exactly one dress to one of its adjacent machines simultaneously.

leetcodehardarraygreedy
LeetCode 1127 - User Purchase Platform

The Spending table records purchases made by users on an e-commerce platform. Every row represents one user's spending on a specific date using either the mobile platform or the desktop platform.

leetcodeharddatabase
LeetCode 860 - Lemonade Change

This problem simulates a lemonade stand where each lemonade costs 5, 20 bill. The challenge is to provide exact change to every customer as they pay. The input is a list of integers bills, where each element represents the bill a customer gives.

leetcodeeasyarraygreedy
LeetCode 1723 - Find Minimum Time to Finish All Jobs

This problem is asking us to assign a set of jobs, each with a specific time requirement, to k workers such that every job is assigned to exactly one worker, and we minimize the maximum total working time among all workers.

leetcodehardarraydynamic-programmingbacktrackingbit-manipulationbitmask
LeetCode 287 - Find the Duplicate Number

The problem gives us an integer array nums of length n + 1, where every value is guaranteed to be in the range [1, n]. Since there are n + 1 numbers but only n possible distinct values, at least one number must appear more than once. The task is to return that duplicate value.

leetcodemediumarraytwo-pointersbinary-searchbit-manipulation
LeetCode 211 - Design Add and Search Words Data Structure

The problem asks us to design a data structure that supports two operations efficiently: 1. Adding words into the structure. 2. Searching for words, where the search pattern may contain the wildcard character '.'. The wildcard '.' represents any single lowercase English letter.

leetcodemediumstringdepth-first-searchdesigntrie
LeetCode 730 - Count Different Palindromic Subsequences

This problem asks us to count how many distinct non-empty palindromic subsequences exist in a string. A subsequence is formed by deleting characters while preserving the relative order of the remaining characters. Unlike substrings, subsequences do not need to be contiguous.

leetcodehardstringdynamic-programming
LeetCode 493 - Reverse Pairs

The problem asks us to count how many pairs of indices (i, j) satisfy two conditions: 1. i < j 2. nums[i] 2 nums[j] These pairs are called reverse pairs.

leetcodehardarraybinary-searchdivide-and-conquerbinary-indexed-treesegment-treemerge-sortordered-set
CF 92B - Binary Number

The task is to take a positive integer represented in binary and determine how many steps it takes to reduce it to 1 using a simple iterative process. In each step, if the number is odd, we increment it by 1, and if it is even, we divide it by 2.

codeforcescompetitive-programminggreedy
LeetCode 485 - Max Consecutive Ones

The problem gives us a binary array named nums, where every element is either 0 or 1. Our task is to determine the maximum number of consecutive 1s that appear anywhere in the array.

leetcodeeasyarray
LeetCode 143 - Reorder List

The problem gives us the head of a singly linked list and asks us to reorder the nodes in a very specific alternating pattern. A normal linked list looks like this: We must transform it into: The important detail is that we are not allowed to change node values.

leetcodemediumlinked-listtwo-pointersstackrecursion
LeetCode 901 - Online Stock Span

The problem asks us to design a class that processes stock prices one day at a time and, for every new price, returns the stock span for that day.

leetcodemediumstackdesignmonotonic-stackdata-stream
LeetCode 1767 - Find the Subtasks That Did Not Execute

This problem revolves around identifying which subtasks of a task were not executed. We are given two tables: Tasks and Executed.

leetcodeharddatabase
CF 57C - Array

We are asked to count the number of arrays of length n containing integers from 1 to n such that the array is either entirely non-decreasing or entirely non-increasing.

codeforcescompetitive-programmingcombinatoricsmath