brain

tamnd's digital brain — notes, problems, research

42641 notes

LeetCode 378 - Kth Smallest Element in a Sorted Matrix

The problem gives us an n x n matrix where both rows and columns are sorted in ascending order. This means two ordering guarantees exist simultaneously: - Every row is sorted from left to right. - Every column is sorted from top to bottom.

leetcodemediumarraybinary-searchsortingheap-(priority-queue)matrix
CF 67E - Save the City!

We are given a simple polygon listed in clockwise order. The first two vertices form a horizontal edge AB, and every other vertex lies strictly on the same side of that edge. Along the segment AB, every integer-coordinate point is a possible location for a watchtower.

codeforcescompetitive-programminggeometry
LeetCode 1700 - Number of Students Unable to Eat Lunch

This problem simulates a school cafeteria where students line up to take sandwiches from a stack. Each student has a preference for either a circular sandwich (0) or a square sandwich (1).

leetcodeeasyarraystackqueuesimulation
LeetCode 357 - Count Numbers with Unique Digits

The problem asks us to count how many integers in the range 0 <= x < 10^n contain no repeated digits. For example, when n = 2, the valid range is: This means we consider every number from 0 to 99. Among these numbers, we only count those whose digits are all unique.

leetcodemediummathdynamic-programmingbacktracking
LeetCode 448 - Find All Numbers Disappeared in an Array

The problem asks us to find all the integers in the range [1, n] that are missing from an input array nums of length n.

leetcodeeasyarrayhash-table
LeetCode 371 - Sum of Two Integers

The problem asks us to compute the sum of two integers without using the arithmetic operators + and -. Instead of relying on normal arithmetic, we must use bit manipulation to simulate how addition works at the binary level. The input consists of two integers, a and b.

leetcodemediummathbit-manipulation
LeetCode 506 - Relative Ranks

The problem gives us an array named score, where each element represents the score earned by an athlete in a competition. Every athlete has a unique score, which means there are no ties to worry about when determining rankings.

leetcodeeasyarraysortingheap-(priority-queue)
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 267 - Palindrome Permutation II

The problem asks us to generate every unique palindrome that can be formed by rearranging the characters of a given string. A palindrome is a string that reads the same forward and backward. For example, "abba" and "racecar" are palindromes.

leetcodemediumhash-tablestringbacktracking
LeetCode 1709 - Biggest Window Between Visits

The UserVisits table stores records of when users visited a retailer. Each row contains a userid and a visitdate. A user may appear multiple times because they can visit on many different days.

leetcodemediumdatabase
LeetCode 1273 - Delete Tree Nodes

The problem provides a tree rooted at node 0, represented in two parallel arrays: parent and value. The parent[i] array

leetcodemediumarraytreedepth-first-searchbreadth-first-search
LeetCode 525 - Contiguous Array

This problem asks us to find the maximum length of a contiguous subarray in a binary array where the number of 0s and 1s are equal. A contiguous subarray means the elements must appear consecutively in the original array. We are not allowed to rearrange elements or skip indices.

leetcodemediumarrayhash-tableprefix-sum
CF 47C - Crossword

We are given six words and must arrange them into a very specific crossword shape. The shape looks like a rectangular infinity symbol. There are three horizontal words and three vertical words, and they intersect at fixed positions.

codeforcescompetitive-programmingimplementation
LeetCode 1278 - Palindrome Partitioning III

The problem gives us a string s and an integer k. We are allowed to modify characters in the string, and our goal is to

leetcodehardstringdynamic-programming
LeetCode 1469 - Find All The Lonely Nodes

This problem asks us to traverse a binary tree and identify every node that is considered "lonely". A node is lonely if

leetcodeeasytreedepth-first-searchbreadth-first-searchbinary-tree
LeetCode 1143 - Longest Common Subsequence

The problem asks us to find the length of the longest subsequence that appears in both input strings. A subsequence is formed by deleting some characters from a string while keeping the remaining characters in the same relative order. The characters do not need to be contiguous.

leetcodemediumstringdynamic-programming
CF 54B - Cutting Jigsaw Puzzle

We are given a rectangular picture represented as an A × B grid of letters. The task is to determine how many ways we can cut this picture into smaller rectangular pieces such that each piece is unique up to rotations, and to identify the smallest possible piece size among…

codeforcescompetitive-programminghashingimplementation
LeetCode 871 - Minimum Number of Refueling Stops

The problem describes a car traveling from position 0 to a destination located target miles away. The car starts with startFuel liters of fuel, and every mile driven consumes exactly one liter of fuel.

leetcodehardarraydynamic-programminggreedyheap-(priority-queue)
CF 20B - Equation

We are asked to solve a quadratic equation of the form , where , , and are integers in the range . The goal is to find all real roots of the equation, count them, and print them in ascending order with high precision.

codeforcescompetitive-programmingmath
LeetCode 1644 - Lowest Common Ancestor of a Binary Tree II

This problem asks us to find the lowest common ancestor (LCA) of two given nodes, p and q, in a binary tree, under the c

leetcodemediumtreedepth-first-searchbinary-tree
LeetCode 223 - Rectangle Area

The problem gives the coordinates of two axis-aligned rectangles on a 2D plane. Each rectangle is represented using two corner points: - Bottom-left corner (x1, y1) - Top-right corner (x2, y2) For the first rectangle, the coordinates are: - (ax1, ay1) for the bottom-left -…

leetcodemediummathgeometry
LeetCode 824 - Goat Latin

This problem asks us to transform a given sentence into a fictional language called Goat Latin, following a specific set of string manipulation rules. The input is a string called sentence, where words are separated by a single space.

leetcodeeasystring
CF 115C - Plumber

We have an n × m grid. Every cell must contain one of four corner-shaped pipe pieces. Each piece connects exactly two adjacent sides of the cell.

codeforcescompetitive-programmingmath
LeetCode 800 - Similar RGB Color

The problem is asking us to find the shorthand RGB color that is most similar to a given full-length RGB color string.

leetcodeeasymathstringenumeration
LeetCode 1739 - Building Boxes

The problem gives us n identical unit cubes that must be placed inside a cubic room. The goal is to minimize how many boxes directly touch the floor. The placement rule is the important part of the problem.

leetcodehardmathbinary-searchgreedy
LeetCode 1134 - Armstrong Number

In this problem, we are given an integer n, and we must determine whether it is an Armstrong number. An Armstrong number is defined as follows: - Let k be the number of digits in n. - Take every digit in the number. - Raise each digit to the power k.

leetcodeeasymath
LeetCode 456 - 132 Pattern

The problem asks us to determine whether an array contains a specific ordering pattern called a "132 pattern". A valid 132 pattern consists of three indices i, j, and k such that: - i < j < k - nums[i] < nums[k] < nums[j] The name "132" comes from the relative ordering of the…

leetcodemediumarraybinary-searchstackmonotonic-stackordered-set
LeetCode 913 - Cat and Mouse

In this problem, we are given an undirected graph where two players, Mouse and Cat, move alternately across the graph according to specific rules. The graph is represented as an adjacency list, where graph[a] contains all nodes directly connected to node a.

leetcodehardmathdynamic-programminggraph-theorytopological-sortmemoizationgame-theory
CF 11E - Forward, march!

Jack repeats a cyclic sequence consisting of three possible actions. L means a left-foot step, R means a right-foot step, and X means standing still for one beat. The sergeant expects the infinite alternating pattern:

codeforcescompetitive-programmingbinary-searchdpgreedy
LeetCode 242 - Valid Anagram

The problem asks us to determine whether two strings are anagrams of each other. Two strings are considered anagrams if they contain exactly the same characters with exactly the same frequencies, but possibly in a different order.

leetcodeeasyhash-tablestringsorting
LeetCode 1222 - Queens That Can Attack the King

In this problem, we are given the positions of several black queens and exactly one white king on a standard 8 x 8 chessboard. The board uses 0-indexed coordinates, meaning every position is represented as [row, column], where both values range from 0 to 7.

leetcodemediumarraymatrixsimulation
LeetCode 1052 - Grumpy Bookstore Owner

This problem asks us to maximize the number of satisfied customers in a bookstore over n minutes. We are given two arrays: customers, which indicates how many customers arrive each minute, and grumpy, which indicates whether the bookstore owner is grumpy (1) or not grumpy (0)…

leetcodemediumarraysliding-window
CF 61E - Enemy is weak

We are given an array of distinct integers representing the power of soldiers standing in a line. We need to count how many index triples (i, j, k) satisfy two conditions at the same time: - The positions are ordered as i < j < k - The values are strictly decreasing as a[i]…

codeforcescompetitive-programmingdata-structurestrees
LeetCode 595 - Big Countries

This problem asks us to query a database table named World and return a subset of countries that qualify as big countries.

leetcodeeasydatabase
LeetCode 1370 - Increasing Decreasing String

The problem requires us to reorder a string s by repeatedly picking characters in a specific increasing and decreasing p

leetcodeeasyhash-tablestringcounting
CF 100F - Polynom

We are given a polynomial already factorized into linear terms: $$p(x) = (x + a1)(x + a2)dots(x + an)$$ The task is to expand this product and print the polynomial in the usual descending-power form: $$x^n + b1x^{n-1} + dots + bn$$ The tricky part is not the expansion itself.

codeforcescompetitive-programming*specialimplementation
CF 121C - Lucky Permutation

We are asked to examine permutations of numbers from 1 to n and focus on "lucky numbers" - integers that contain only the digits 4 and 7.

codeforcescompetitive-programmingbrute-forcecombinatoricsnumber-theory
LeetCode 1378 - Replace Employee ID With The Unique Identifier

This problem asks us to combine information from two database tables and return the result in a specific format. We are

leetcodeeasydatabase
LeetCode 924 - Minimize Malware Spread

In this problem, we are given an undirected graph represented as an adjacency matrix. Each node represents a computer in a network, and an edge between two nodes means those computers are directly connected. Some subset of nodes is initially infected with malware.

leetcodehardarrayhash-tabledepth-first-searchbreadth-first-searchunion-findgraph-theory
LeetCode 1073 - Adding Two Negabinary Numbers

The problem asks us to add two numbers that are represented in negabinary, which is base -2. Unlike standard binary (base 2), each bit in negabinary contributes a value multiplied by powers of -2.

leetcodemediumarraymath
LeetCode 117 - Populating Next Right Pointers in Each Node II

The problem asks us to populate the next pointer for every node in a binary tree so that it points to the node immediately to its right on the same level. If no such node exists, the next pointer should remain NULL.

leetcodemediumlinked-listtreedepth-first-searchbreadth-first-searchbinary-tree
LeetCode 1781 - Sum of Beauty of All Substrings

The problem asks us to calculate the sum of beauty for all substrings of a given string s. The beauty of a substring is defined as the difference between the highest frequency and the lowest frequency of any character that occurs in that substring.

leetcodemediumhash-tablestringcounting
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
LeetCode 1097 - Game Play Analysis V

This problem requires calculating the day one retention metric for a game based on user activity data. The input is an Activity table, where each row represents a login session of a player on a particular day, including the device used and the number of games played.

leetcodeharddatabase
CF 60E - Mushroom Gnomes

We are given a line of mushrooms, each with a weight, initially sorted in non-decreasing order. Every minute, new mushrooms grow between every pair of neighboring mushrooms, and the weight of each new mushroom equals the sum of the two neighboring mushrooms.

codeforcescompetitive-programmingmathmatrices
CF 120D - Three Sons

We have a rectangular cornfield represented as a grid of size n × m, where each cell contains a certain number of tons of corn. The father wants to divide this field among three sons in such a way that each son receives exactly a predetermined amount of corn: A, B, or C tons.

codeforcescompetitive-programmingbrute-force
LeetCode 878 - Nth Magical Number

The problem asks us to find the nth positive integer that is divisible by either a or b. A number is considered magical if at least one of the following is true: - It is divisible by a - It is divisible by b We are given three integers: - n, the position of the magical number…

leetcodehardmathbinary-search
CF 130H - Balanced brackets

We are asked to determine if a string of round brackets is balanced. A balanced sequence is one where every opening bracket «(» has a corresponding closing bracket «)», and brackets are properly nested.

codeforcescompetitive-programming*special
LeetCode 1783 - Grand Slam Titles

This problem asks us to compute how many Grand Slam tennis titles each player has won across all years recorded in the database. We are given two tables: The Players table contains information about tennis players.

leetcodemediumdatabase
LeetCode 1116 - Print Zero Even Odd

The problem requires us to implement a multithreaded class ZeroEvenOdd that coordinates three separate threads to print numbers in a specific sequence. Thread A prints 0s, Thread B prints even numbers, and Thread C prints odd numbers.

leetcodemediumconcurrency
LeetCode 994 - Rotting Oranges

You are given a 2D grid where each cell represents one of three possible states: - 0 means the cell is empty. - 1 means the cell contains a fresh orange. - 2 means the cell contains a rotten orange.

leetcodemediumarraybreadth-first-searchmatrix
LeetCode 2308 - Arrange Table by Gender

The problem asks us to rearrange the rows of a Genders table in a specific repeating order while maintaining internal so

leetcodemediumdatabase
LeetCode 1633 - Percentage of Users Attended a Contest

This problem asks us to calculate the percentage of users who attended each contest. We are given two tables: Users and

leetcodeeasydatabase
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 46 - Permutations

The problem gives us an array of distinct integers called nums, and asks us to generate every possible permutation of those numbers. A permutation is an arrangement of elements in a specific order.

leetcodemediumarraybacktracking
LeetCode 640 - Solve the Equation

The problem is asking us to solve a linear equation containing a single variable 'x' and integer coefficients, expressed as a string. The equation may include addition '+', subtraction '-', and the equality operator '='.

leetcodemediummathstringsimulation
LeetCode 84 - Largest Rectangle in Histogram

This problem asks us to find the largest rectangular area that can be formed inside a histogram. A histogram is represented as an array of integers called heights, where each integer describes the height of a bar, and every bar has a width of exactly 1.

leetcodehardarraystackmonotonic-stack
CF 6C - Alice, Bob and Chocolate

We have a row of chocolate bars, and each bar takes a certain amount of time to eat. Alice starts from the left end and keeps moving right. Bob starts from the right end and keeps moving left.

codeforcescompetitive-programminggreedytwo-pointers
CF 87A - Trains

Vasya is at the central station of a subway branch with two endpoints. Each endpoint corresponds to one of his girlfriends: Dasha or Masha. Trains to Dasha’s station arrive every a minutes and trains to Masha’s station arrive every b minutes.

codeforcescompetitive-programmingimplementationmath
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
LeetCode 721 - Accounts Merge

This problem asks us to merge user accounts based on shared email addresses. Each account is represented as a list of strings. The first string is the user's name, and every remaining string is an email address associated with that account.

leetcodemediumarrayhash-tablestringdepth-first-searchbreadth-first-searchunion-findsorting
LeetCode 728 - Self Dividing Numbers

The problem asks us to find all numbers within a given inclusive range [left, right] that satisfy the definition of a self-dividing number. A self-dividing number has two important properties: 1. Every digit inside the number must divide the number evenly. 2.

leetcodeeasymath
CF 122A - Lucky Division

We are asked to determine whether a given number is almost lucky. A number is almost lucky if it is divisible by at least one lucky number. Lucky numbers are positive integers composed entirely of the digits 4 and 7, like 4, 7, 44, 47, 74, and so on.

codeforcescompetitive-programmingbrute-forcenumber-theory
LeetCode 550 - Game Play Analysis IV

This problem is asking us to calculate a retention metric from a table of player activities. Specifically, we need to determine the fraction of players who log in on the day immediately following their first login.

leetcodemediumdatabase
CF 34D - Road Map

We are given a tree with n cities. Originally, city r1 is considered the capital, and for every other city we know its parent in the rooted tree. The value p[i] means that if we walk from the old capital toward city i, the last city before reaching i is p[i].

codeforcescompetitive-programmingdfs-and-similargraphs
LeetCode 935 - Knight Dialer

The problem asks us to count how many distinct phone numbers of length n can be generated by moving a chess knight across a numeric keypad. The keypad layout looks like this: A knight moves in an L-shape. From any current digit, it can jump only to specific other digits.

leetcodemediumdynamic-programming
LeetCode 2963 - Count the Number of Good Partitions

The problem asks us to count the number of ways we can partition a given array nums of positive integers into contiguous

leetcodehardarrayhash-tablemathcombinatorics
CF 18C - Stripe

We have a strip of cells, and each cell contains an integer. We may cut the strip only between adjacent cells, which splits the array into a left part and a right part. The task is to count how many cut positions produce two non-empty parts with equal sums.

codeforcescompetitive-programmingdata-structuresimplementation
CF 115D - Unambiguous Arithmetic Expression

We are asked to count the number of ways an arithmetic expression can be made unambiguous with parentheses so that, if all parentheses are removed, the expression is exactly the string given in the input.

codeforcescompetitive-programmingdpexpression-parsing
LeetCode 1779 - Find Nearest Point That Has the Same X or Y Coordinate

The problem gives your current position on a 2D Cartesian grid as (x, y) and a list of other points. Each point is represented as [ai, bi].

leetcodeeasyarray
LeetCode 468 - Validate IP Address

The problem asks us to determine whether a given string represents a valid IPv4 address, a valid IPv6 address, or neither.

leetcodemediumstring
LeetCode 414 - Third Maximum Number

The problem asks us to find the third distinct maximum number in an integer array. The key word is distinct. Duplicate values should only be counted once when determining rankings. For example, in the array [2,2,3,1], the distinct values are {3,2,1}.

leetcodeeasyarraysorting
LeetCode 799 - Champagne Tower

The problem asks us to simulate a process of pouring champagne into a pyramid of glasses. Each glass can hold exactly one cup of champagne, and any excess from a glass flows evenly to the two glasses immediately below it.

leetcodemediumdynamic-programming
LeetCode 255 - Verify Preorder Sequence in Binary Search Tree

The problem gives an array of unique integers called preorder. This array is supposed to represent the preorder traversal of a binary search tree, and we must determine whether such a BST could actually exist. In a preorder traversal, nodes are visited in this order: 1.

leetcodemediumarraystacktreebinary-search-treerecursionmonotonic-stackbinary-tree
LeetCode 929 - Unique Email Addresses

The problem gives us a list of email addresses and asks how many unique destinations actually receive emails after applying Gmail-like normalization rules.

leetcodeeasyarrayhash-tablestring
LeetCode 643 - Maximum Average Subarray I

The problem asks us to find the maximum average value among all contiguous subarrays of a fixed length k. In other words, given an integer array nums, we must examine every possible subarray whose size is exactly k, compute its average, and return the largest average found.

leetcodeeasyarraysliding-window
CF 69B - Bets

Each athlete runs through a contiguous interval of sections. While an athlete is inside a section, they spend exactly t[i] time on that section, so the winner of a section is simply the active athlete with the smallest t.

codeforcescompetitive-programminggreedyimplementation
CF 73E - Morrowindows

Each viewing mode groups the inventory into pages of size ai. If the inventory contains k items, then the game shows $bi = leftlceil frac{k}{ai} rightrceil$ pages in that mode. Vasya does not know the actual value of k, only that 2 ≤ k ≤ x.

codeforcescompetitive-programmingmathnumber-theory
LeetCode 1148 - Article Views I

The problem is asking us to identify all authors who have viewed at least one of their own articles. The input is a database table Views that contains information about articles, their authors, the viewers, and the dates on which the articles were viewed.

leetcodeeasydatabase
LeetCode 1381 - Design a Stack With Increment Operation

This problem requires designing a specialized stack data structure, called CustomStack, that not only supports the usual

leetcodemediumarraystackdesign
LeetCode 940 - Distinct Subsequences II

The problem asks us to count how many distinct non-empty subsequences can be formed from a given string s. A subsequence is formed by deleting zero or more characters while keeping the remaining characters in their original order.

leetcodehardstringdynamic-programming
CF 27B - Tournament

We are asked to reconstruct the missing result of a round-robin tournament. There are _n_ participants, and every participant plays against every other participant exactly once.

codeforcescompetitive-programmingbitmasksbrute-forcedfs-and-similargreedy
LeetCode 1269 - Number of Ways to Stay in the Same Place After Some Steps

This problem asks us to count how many different ways a pointer can end up back at index 0 after taking exactly steps mo

leetcodeharddynamic-programming
CF 50E - Square Equation Roots

We are asked to count all distinct real roots of quadratic equations of the form , where ranges from 1 to and ranges from 1 to . Each pair defines one quadratic. The output is the total number of distinct real roots across all these quadratics.

codeforcescompetitive-programmingmath
LeetCode 1629 - Slowest Key

This problem asks us to determine which key on a keypad was pressed for the longest duration during a test sequence. We

leetcodeeasyarraystring
CF 84C - Biathlon

We are given a set of circular targets, all lying on the Ox axis, each defined by its center coordinate and radius. Valera shoots multiple times, and each shot has an (x, y) coordinate.

codeforcescompetitive-programmingbinary-searchimplementation
LeetCode 654 - Maximum Binary Tree

The problem asks us to construct a maximum binary tree from a given integer array nums with unique elements. A maximum binary tree is a binary tree where each node is the maximum element of the subarray it represents.

leetcodemediumarraydivide-and-conquerstacktreemonotonic-stackbinary-tree
CF 4D - Mysterious Present

We are given a collection of envelopes, each with a width and height. A postcard already has fixed dimensions, and we want to build the longest possible nesting chain of envelopes such that:

codeforcescompetitive-programmingdpsortings
LeetCode 1190 - Reverse Substrings Between Each Pair of Parentheses

The problem gives us a string s containing lowercase English letters and balanced parentheses. Our task is to repeatedly reverse the substrings enclosed inside every matching pair of parentheses, starting from the innermost pair first.

leetcodemediumstringstack
LeetCode 1613 - Find the Missing IDs

The problem gives us a database table named Customers, where each row contains a unique customerid and a corresponding customername. Our task is to identify all missing customer IDs between 1 and the maximum customerid currently present in the table.

leetcodemediumdatabase
LeetCode 213 - House Robber II

This problem is a variation of the classic House Robber dynamic programming problem, with one important twist: the houses are arranged in a circle rather than a straight line.

leetcodemediumarraydynamic-programming
LeetCode 1214 - Two Sum BSTs

The problem gives us two binary search trees, root1 and root2, along with an integer target. We must determine whether there exists one node from the first tree and one node from the second tree such that their values add up exactly to target.

leetcodemediumtwo-pointersbinary-searchstacktreedepth-first-searchbinary-search-treebinary-tree
CF 39H - Multiplication Table

The task is to generate a multiplication table for numbers in a positional numeral system with a base k. Unlike the decimal system, the digits in this system range from 0 up to k-1. Petya wants to see products of numbers from 1 to k-1 expressed in this system.

codeforcescompetitive-programmingimplementation
LeetCode 1060 - Missing Element in Sorted Array

The problem asks us to find the k-th missing number in a sorted, strictly increasing array of unique integers. Given nums and an integer k, we need to identify the number that is missing from the sequence formed by consecutive integers starting from nums[0].

leetcodemediumarraybinary-search
CF 63D - Dividing Island

We are asked to divide an island into connected territories for multiple parties. The island is represented by two rectangles placed side by side: one of size a by b and another of size c by d.

codeforcescompetitive-programmingconstructive-algorithms
CF 38B - Chess

We are given the positions of two chess pieces on a standard 8 × 8 board, one rook and one knight. Their starting positions are guaranteed to be safe, meaning the rook does not attack the knight and the knight does not attack the rook.

codeforcescompetitive-programmingbrute-forceimplementationmath
LeetCode 1229 - Meeting Scheduler

This problem asks us to find the earliest overlapping time slot of a given duration between two people, given their individual availability schedules.

leetcodemediumarraytwo-pointerssorting
CF 26D - Tickets

We have a ticket seller, Charlie, who sells race tickets costing 10 euros each. Customers arrive in some random order: some have only 10 euro banknotes, some have only 20 euro banknotes. Charlie initially has k 10 euro banknotes.

codeforcescompetitive-programmingcombinatoricsmathprobabilities
LeetCode 2907 - Maximum Profitable Triplets With Increasing Prices I

This problem asks us to select exactly three items from a store while satisfying both an index ordering condition and a

leetcodemediumarraybinary-indexed-treesegment-tree
LeetCode 124 - Binary Tree Maximum Path Sum

The problem is asking us to find the maximum path sum in a binary tree. A path is defined as any sequence of nodes connected by edges, where each node is included at most once. The path does not need to start at the root or end at a leaf.

leetcodeharddynamic-programmingtreedepth-first-searchbinary-tree