brain

tamnd's digital brain — notes, problems, research

43815 notes

LeetCode 1245 - Tree Diameter

The problem asks us to find the diameter of a tree, which is defined as the number of edges in the longest path between any two nodes. We are given an undirected tree represented as a list of edges. Each edge connects two nodes, labeled from 0 to n - 1.

leetcodemediumtreedepth-first-searchbreadth-first-searchgraph-theorytopological-sort
LeetCode 438 - Find All Anagrams in a String

The problem gives two strings, s and p, both containing only lowercase English letters. We need to find every starting index in s where a substring is an anagram of p.

leetcodemediumhash-tablestringsliding-window
LeetCode 679 - 24 Game

The problem is asking us to determine whether it is possible to use exactly four numbers, each between 1 and 9 inclusive, to form a mathematical expression that evaluates to exactly 24. The numbers are given in an array called cards of length 4.

leetcodehardarraymathbacktracking
LeetCode 1626 - Best Team With No Conflicts

The problem asks us to build a basketball team with the maximum possible total score, while ensuring that the team does not contain any conflicts.

leetcodemediumarraydynamic-programmingsorting
CF 101C - Vectors

We start with a vector A = (x1, y1) and want to transform it into another vector B = (x2, y2). Two operations are allowed. We may rotate the current vector by 90 degrees clockwise, and we may add vector C = (x3, y3) any number of times. The operations may be mixed in any order.

codeforcescompetitive-programmingimplementationmath
LeetCode 1010 - Pairs of Songs With Total Durations Divisible by 60

The problem asks us to find pairs of songs whose total duration is divisible by 60. Specifically, we are given an array time where each element represents the length of a song in seconds. We need to count all unique pairs (i, j) where i < j and (time[i] + time[j]) % 60 == 0.

leetcodemediumarrayhash-tablecounting
CF 72C - Extraordinarily Nice Numbers

We are asked to determine whether a positive integer $x$ is extraordinarily nice. By the problem's definition, a number is extraordinarily nice if it has exactly the same number of even divisors as odd divisors. The input is a single integer $x$ between 1 and 1000.

codeforcescompetitive-programming*specialmath
CF 39B - Company Income Growth

We are given a sequence of integers representing the yearly income of a company starting from 2001. The first number is the income in 2001, the second in 2002, and so on. These values may be negative if the company incurred a loss that year.

codeforcescompetitive-programminggreedy
CF 86B - Tetris revisited

We have a rectangular board where some cells are already blocked by and the remaining cells . must be covered by polyominoes. The allowed pieces are extremely flexible: any connected shape consisting of 2, 3, 4, or 5 cells may be used, with arbitrary rotations and reflections.

codeforcescompetitive-programmingconstructive-algorithmsgraph-matchingsgreedymath
LeetCode 146 - LRU Cache

The problem asks us to design an efficient cache that follows the Least Recently Used, or LRU, eviction policy. A cache stores a limited number of key-value pairs.

leetcodemediumhash-tablelinked-listdesigndoubly-linked-list
LeetCode 132 - Palindrome Partitioning II

The problem asks us to split a string into substrings such that every substring is a palindrome. Among all valid palindrome partitions, we must return the minimum number of cuts required. A cut divides the string into two parts.

leetcodehardstringdynamic-programming
LeetCode 461 - Hamming Distance

The problem asks us to compute the Hamming distance between two integers. The Hamming distance is defined as the number of bit positions where the two numbers differ in their binary representation. For example, consider x = 1 and y = 4.

leetcodeeasybit-manipulation
LeetCode 545 - Boundary of Binary Tree

This problem asks us to compute the boundary traversal of a binary tree in a very specific order. The boundary is formed by combining four parts: 1. The root node 2. The left boundary, excluding leaves 3. All leaf nodes from left to right 4.

leetcodemediumtreedepth-first-searchbinary-tree
LeetCode 583 - Delete Operation for Two Strings

The problem asks us to determine the minimum number of deletion steps required to make two strings identical. We are given two input strings, word1 and word2, and in each step, we can delete exactly one character from either string.

leetcodemediumstringdynamic-programming
LeetCode 1751 - Maximum Number of Events That Can Be Attended II

You are given a list of events, where each event is represented as: - startDay - endDay - value If you attend an event, you must attend the entire interval from startDay to endDay, inclusive.

leetcodehardarraybinary-searchdynamic-programmingsorting
LeetCode 1776 - Car Fleet II

The problem is asking us to compute the time at which each car in a line of cars collides with the car immediately in front of it, or return -1 if it never collides. Each car is represented by its position and speed.

leetcodehardarraymathstackheap-(priority-queue)monotonic-stack
LeetCode 58 - Length of Last Word

The problem gives us a string s that contains English letters and spaces. Inside this string, words are separated by spaces, and there may also be extra spaces at the beginning or end of the string. Our task is to return the length of the last word in the string.

leetcodeeasystring
LeetCode 122 - Best Time to Buy and Sell Stock II

This problem asks us to maximize profit from stock trading over a sequence of days. We are given an array prices, where prices[i] represents the stock price on the ith day.

leetcodemediumarraydynamic-programminggreedy
LeetCode 171 - Excel Sheet Column Number

This problem asks us to convert an Excel-style column title into its corresponding numerical index. In Excel spreadsheets, columns are labeled alphabetically: The labeling system works similarly to a positional number system, except instead of digits 0-9, it uses letters A-Z…

leetcodeeasymathstring
CF 106C - Buns

Lavrenty has a fixed amount of dough and several types of stuffing. Each stuffing type has a limited quantity and requires a certain amount of dough to make a bun, and each bun yields a profit.

codeforcescompetitive-programmingdp
LeetCode 1302 - Deepest Leaves Sum

That is a long, comprehensive reference document with multiple sections and full code in two languages. To keep quality

leetcodemediumtreedepth-first-searchbreadth-first-searchbinary-tree
CF 41C - Email address

We are given a string representing an email address, but all the . symbols have been spelled out as dot and all the @ symbols as at. Our goal is to reconstruct the original, valid email address in its shortest form.

codeforcescompetitive-programmingexpression-parsingimplementation
LeetCode 1578 - Minimum Time to Make Rope Colorful

The problem requires transforming a rope of balloons into a "colorful" rope, which means no two consecutive balloons sha

leetcodemediumarraystringdynamic-programminggreedy
LeetCode 1604 - Alert Using Same Key-Card Three or More Times in a One Hour Period

The problem gives us two parallel arrays, keyName and keyTime. Each index represents a single key-card usage event. For example: Together, they describe when a specific employee used their key-card during a single day.

leetcodemediumarrayhash-tablestringsorting
LeetCode 1020 - Number of Enclaves

The problem gives us a binary matrix called grid, where: - 0 represents water - 1 represents land We can move only in four directions, up, down, left, and right.

leetcodemediumarraydepth-first-searchbreadth-first-searchunion-findmatrix
LeetCode 1641 - Count Sorted Vowel Strings

The problem asks us to count the number of strings of length n composed only of vowels a, e, i, o, u such that each stri

leetcodemediummathdynamic-programmingcombinatorics
CF 70B - Text Messaging

We are given the maximum length of a single SMS message and one complete text consisting of sentences separated by spaces. A sentence always ends with one of ., ?, or !. Words contain only letters.

codeforcescompetitive-programmingexpression-parsinggreedystrings
CF 73F - Plane of Tanks

We have a tank that wants to move from point A to point B along the straight segment connecting them. The tank moves with constant speed $v$, which we must choose as small as possible. There are $n$ enemy tanks placed on the plane.

codeforcescompetitive-programmingbrute-forcegeometry
LeetCode 663 - Equal Tree Partition

The problem asks whether it is possible to split a binary tree into two separate trees such that both resulting trees have the same sum of node values. The split must happen by removing exactly one edge from the original tree. A binary tree is given through its root node.

leetcodemediumtreedepth-first-searchbinary-tree
CF 58D - Calendar

We are asked to construct a calendar from a list of city names. Each line of the calendar must contain exactly two city names separated by a given symbol, and all lines must have identical length. The calendar must use each city name exactly once.

codeforcescompetitive-programminggreedystrings
LeetCode 1656 - Design an Ordered Stream

This problem asks us to simulate a data stream where each element arrives with a unique ID in arbitrary order. Each element consists of an integer idKey (between 1 and n) and a string value.

leetcodeeasyarrayhash-tabledesigndata-stream
CF 12B - Correct Solution?

Alice gives Bob a decimal number and asks him to rearrange its digits so that the resulting number is as small as possible, while still being a valid decimal number without leading zeroes.

codeforcescompetitive-programmingimplementationsortings
LeetCode 317 - Shortest Distance from All Buildings

The problem asks us to find the optimal location to build a house on a grid so that the total travel distance to all existing buildings is minimized. The input is an m x n grid of integers where each cell is either empty land (0), a building (1), or an obstacle (2).

leetcodehardarraybreadth-first-searchmatrix
LeetCode 56 - Merge Intervals

The problem gives an array of intervals, where each interval is represented as [start, end]. Each interval describes a continuous range of values from start to end, inclusive. The goal is to combine all intervals that overlap into a single larger interval.

leetcodemediumarraysorting
LeetCode 1022 - Sum of Root To Leaf Binary Numbers

This problem gives us the root of a binary tree where every node contains either 0 or 1. Each path from the root node to a leaf node represents a binary number, where the root contributes the most significant bit and each child adds another bit to the right.

leetcodeeasytreedepth-first-searchbinary-tree
LeetCode 1648 - Sell Diminishing-Valued Colored Balls

Here is the complete, detailed technical solution guide for LeetCode 1648 - Sell Diminishing-Valued Colored Balls follow

leetcodemediumarraymathbinary-searchgreedysortingheap-(priority-queue)
LeetCode 64 - Minimum Path Sum

The problem gives us a two dimensional grid of size m x n, where each cell contains a non-negative integer. We begin at the top-left corner of the grid, specifically at position (0, 0), and want to reach the bottom-right corner at position (m - 1, n - 1).

leetcodemediumarraydynamic-programmingmatrix
CF 79A - Bus Game

We are asked to simulate a turn-based game involving two players, Ciel and Hanako, who alternate taking coins from a common pile. The pile initially contains x 100-yen coins and y 10-yen coins. On each turn, the active player must remove exactly 220 yen.

codeforcescompetitive-programminggreedy
LeetCode 477 - Total Hamming Distance

The problem asks us to compute the total Hamming distance between every possible pair of integers in the array. The Hamming distance between two integers is defined as the number of bit positions where the two numbers differ.

leetcodemediumarraymathbit-manipulation
CF 37C - Old Berland Language

We need to construct a binary prefix code.

codeforcescompetitive-programmingdata-structuresgreedytrees
CF 94A - Restoring Password

We are given an encrypted password represented as a binary string of length 80. The original password had exactly 8 decimal digits, and each digit was encoded into a block of 10 binary characters.

codeforcescompetitive-programmingimplementationstrings
LeetCode 965 - Univalued Binary Tree

The problem gives us the root node of a binary tree and asks whether the tree is "uni-valued". A binary tree is considered uni-valued if every node in the tree contains exactly the same integer value.

leetcodeeasytreedepth-first-searchbreadth-first-searchbinary-tree
LeetCode 135 - Candy

This problem asks us to distribute candies to children standing in a line, based on their rating values. Each child must receive at least one candy, and any child with a higher rating than an adjacent neighbor must receive strictly more candies than that neighbor.

leetcodehardarraygreedy
LeetCode 1676 - Lowest Common Ancestor of a Binary Tree IV

This problem asks us to find the Lowest Common Ancestor, or LCA, of multiple nodes in a binary tree. Unlike the classic

leetcodemediumhash-tabletreedepth-first-searchbinary-tree
LeetCode 717 - 1-bit and 2-bit Characters

In this problem, we are given a binary array called bits. The array represents a sequence of encoded characters using the following rules: - A one-bit character is represented by a single 0 - A two-bit character is represented by either 10 or 11 The array is guaranteed to end…

leetcodeeasyarray
LeetCode 2002 - Maximum Product of the Length of Two Palindromic Subsequences

The problem is asking us to find two disjoint palindromic subsequences from a given string s such that the product of their lengths is maximized. A subsequence is derived by deleting zero or more characters from the original string while keeping the relative order intact.

leetcodemediumstringdynamic-programmingbacktrackingbit-manipulationbitmask
LeetCode 299 - Bulls and Cows

The problem gives two strings, secret and guess, representing two numbers of equal length. We need to compare them and return a hint in the format "xAyB". A "bull" is a digit that matches in both value and position.

leetcodemediumhash-tablestringcounting
LeetCode 1451 - Rearrange Words in a Sentence

The problem gives us a sentence where words are separated by single spaces, the very first character of the sentence is

leetcodemediumstringsorting
LeetCode 831 - Masking Personal Information

The problem requires creating a masked version of a personal information string s that can either be an email address or a phone number. The goal is to obscure sensitive information while keeping enough data to identify the user minimally.

leetcodemediumstring
LeetCode 1465 - Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts

This problem gives us a rectangular cake with height h and width w. We are also given two arrays: - horizontalCuts, whic

leetcodemediumarraygreedysorting
CF 103B - Cthulhu

We are given an undirected graph and need to decide whether it matches a very specific structure. The graph should contain exactly one simple cycle, and every other vertex must belong to a tree attached to some vertex on that cycle.

codeforcescompetitive-programmingdfs-and-similardsugraphs
CF 32B - Borze

We are given a string written in the Borze encoding system. Every digit of a ternary number is represented by one of three patterns:

codeforcescompetitive-programmingexpression-parsingimplementation
LeetCode 1053 - Previous Permutation With One Swap

The problem asks us to find the lexicographically largest permutation that is still smaller than the given array, using exactly one swap operation.

leetcodemediumarraygreedy
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 1439 - Find the Kth Smallest Sum of a Matrix With Sorted Rows

The problem requires finding the kth smallest sum obtainable by selecting exactly one element from each row of a matrix mat with sorted rows. Each row is sorted in non-decreasing order, and we must explore combinations of elements across rows to form sums.

leetcodehardarraybinary-searchheap-(priority-queue)matrix
LeetCode 585 - Investments in 2016

Here’s a full, detailed technical solution guide for LeetCode 585 following your exact formatting rules: The problem presents an Insurance table containing policyholder information, including a unique policy ID (pid), investment values for 2015 (tiv2015) and 2016 (tiv2016)…

leetcodemediumdatabase
LeetCode 1185 - Day of the Week

This problem asks us to determine which day of the week corresponds to a given calendar date. The input consists of three integers: - day, representing the day within the month - month, representing the month number from 1 to 12 - year, representing the year We must return the…

leetcodeeasymath
LeetCode 1260 - Shift 2D Grid

This problem asks us to simulate repeated shift operations on a 2D matrix. We are given an m x n grid and an integer k,

leetcodeeasyarraymatrixsimulation
LeetCode 676 - Implement Magic Dictionary

The problem asks us to design a dictionary-like data structure that supports two operations. First, we load a collection of distinct words into the structure.

leetcodemediumhash-tablestringdepth-first-searchdesigntrie
LeetCode 1230 - Toss Strange Coins

This problem is asking us to calculate the probability that, when tossing a set of coins, exactly a specific number of them come up heads. Each coin has its own individual probability of landing heads, which is given in the input array prob.

leetcodemediumarraymathdynamic-programmingprobability-and-statistics
LeetCode 2036 - Maximum Alternating Subarray Sum

The problem asks us to compute the maximum alternating subarray sum for a given integer array. A subarray is any contiguous sequence of elements from the array.

leetcodemediumarraydynamic-programming
CF 135A - Replacement

We start with an array of positive integers. We must change exactly one element to a different value, still between 1 and 10^9. After that single replacement, we sort the array in non-decreasing order.

codeforcescompetitive-programminggreedyimplementationsortings
LeetCode 1161 - Maximum Level Sum of a Binary Tree

In this problem, we are given the root node of a binary tree. Every node belongs to a specific level in the tree. The root is at level 1, its direct children are at level 2, their children are at level 3, and so on.

leetcodemediumtreedepth-first-searchbreadth-first-searchbinary-tree
LeetCode 668 - Kth Smallest Number in Multiplication Table

The problem gives us an m x n multiplication table where each cell contains the product of its row index and column index, using 1-based indexing. That means the value at position (i, j) is simply i j.

leetcodehardmathbinary-search
LeetCode 1076 - Project Employees II

This problem asks us to identify the project or projects that have the largest number of employees assigned to them. We are given two database tables. The Project table stores relationships between projects and employees.

leetcodeeasydatabase
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
CF 37A - Towers

We are given a set of wooden bars, each with a positive integer length. Vasya wants to build towers by stacking bars of the same length. Each tower must consist of bars that are identical in length, but different towers can have different lengths.

codeforcescompetitive-programmingsortings
CF 12C - Fruits

Valera has a shopping list containing a number of fruits, possibly with duplicates if he wants more than one of the same type. At the market, the stall has _n_ types of fruits and _n_ price tags, but the tags are not yet attached to the fruits.

codeforcescompetitive-programminggreedyimplementationsortings
CF 78A - Haiku

We are given three lines representing the three phrases of a poem. A valid haiku must contain exactly 5 vowel letters in the first phrase, 7 in the second, and 5 in the third. For this problem, syllables are simplified into vowel counts.

codeforcescompetitive-programmingimplementationstrings
CF 85E - Guard Towers

We have n towers on a 2D plane. Every tower must belong to exactly one of two generals. For each general, the cost he demands is the maximum Manhattan distance between any two towers assigned to him. The king only pays the larger of the two costs.

codeforcescompetitive-programmingbinary-searchdsugeometrygraphssortings
LeetCode 1084 - Sales Analysis III

The problem asks us to identify products that were sold only during the first quarter of 2019, meaning between 2019-01-01 and 2019-03-31, inclusive. We are provided with two tables: Product and Sales.

leetcodeeasydatabase
CF 123C - Brackets

We are filling an n × m grid with brackets. Every cell contains either "(" or ")". The grid is called valid if every monotone path from the top-left corner to the bottom-right corner forms a correct bracket sequence. A monotone path only moves right or down.

codeforcescompetitive-programmingcombinatoricsdpgreedy
LeetCode 1718 - Construct the Lexicographically Largest Valid Sequence

The problem asks us to construct a special integer sequence using numbers from 1 to n. The resulting sequence has length 2 n - 1 because: - The number 1 appears exactly once. - Every number from 2 to n appears exactly twice.

leetcodemediumarraybacktracking
LeetCode 217 - Contains Duplicate

The problem gives an integer array nums and asks whether any number appears more than once. If at least one value is repeated, we return true. If every value appears exactly once, we return false. The input is a list of integers.

leetcodeeasyarrayhash-tablesorting
LeetCode 619 - Biggest Single Number

The problem gives us a database table named MyNumbers that contains a single column, num. The table may contain duplicate values because there is no primary key restriction. Our task is to find the largest number that appears exactly once in the table.

leetcodeeasydatabase
LeetCode 2032 - Two Out of Three

The problem asks us to identify all distinct integers that appear in at least two out of three given integer arrays. The input consists of three arrays nums1, nums2, and nums3, each containing integers in the range [1, 100].

leetcodeeasyarrayhash-tablebit-manipulation
LeetCode 891 - Sum of Subsequence Widths

The problem asks us to calculate the sum of widths for all non-empty subsequences of a given integer array nums. A subsequence is any sequence derived by removing zero or more elements from the original array while maintaining the order.

leetcodehardarraymathsorting
CF 6B - President's Office

The office is represented as a rectangular grid. Every uppercase letter represents part of a desk, and all cells with the same letter belong to the same rectangular desk. The president’s desk color is given as c.

codeforcescompetitive-programmingimplementation
CF 120A - Elevator

We are given two pieces of information about a person riding an elevator. The first input tells us which door the person used to enter, either the front door or the back door. The second input tells us which rail the person was holding, rail 1 or rail 2.

codeforcescompetitive-programmingbrute-forceimplementationmath
CF 37E - Trial for Chief

We are given a rectangular slab divided into an grid of squares. Each square is either black or white in the final design, which is provided as input. The slab initially starts entirely white.

codeforcescompetitive-programminggraphsgreedyshortest-paths
CF 22B - Bargaining Table

The office floor is represented as an n × m grid. Each cell is either free, written as 0, or blocked by furniture, written as 1. We want to place one rectangular table whose sides stay aligned with the grid. Every cell covered by the rectangle must be free.

codeforcescompetitive-programmingbrute-forcedp
LeetCode 1592 - Rearrange Spaces Between Words

The problem requires rearranging spaces in a given string text so that all words are separated by the maximum possible e

leetcodeeasystring
LeetCode 502 - IPO

The problem describes a scenario where we have a limited number of opportunities to invest in projects before an IPO.

leetcodehardarraygreedysortingheap-(priority-queue)
LeetCode 1307 - Verbal Arithmetic Puzzle

The problem gives a collection of words on the left side of an equation and a single result word on the right side. Each distinct uppercase letter must be assigned a unique digit from 0 to 9.

leetcodehardarraymathstringbacktracking
LeetCode 1534 - Count Good Triplets

The problem asks us to count the number of good triplets in an integer array arr based on three difference constraints a, b, and c.

leetcodeeasyarrayenumeration
LeetCode 650 - 2 Keys Keyboard

The problem is asking for the minimum number of operations required to generate exactly n characters 'A' on a notepad starting with a single 'A'.

leetcodemediummathdynamic-programming
CF 117D - Not Quick Transformation

We start with the array [1, 2, 3, ..., n]. A recursive transformation rearranges it by repeatedly taking all elements at odd positions, transforming that subarray, then taking all elements at even positions and transforming that subarray.

codeforcescompetitive-programmingdivide-and-conquermath
CF 136A - Presents

We are given a party scenario where Petya invited n friends, each of whom gave exactly one gift to another friend. The input lists, for each friend in order, the friend they gave a gift to.

codeforcescompetitive-programmingimplementation
LeetCode 1188 - Design Bounded Blocking Queue

This problem asks us to implement a thread-safe bounded blocking queue, which is a data structure that stores elements in a first-in-first-out (FIFO) order, but with the added constraint that multiple threads may be concurrently accessing it.

leetcodemediumconcurrency
CF 45C - Dancing Lessons

We are given a line of people, each identified as a boy or a girl, and each with a numeric dancing skill. The line evolves over time as couples consisting of one boy and one girl who are adjacent and have the smallest difference in skill leave to dance.

codeforcescompetitive-programmingdata-structures
LeetCode 113 - Path Sum II

This problem asks us to find all root-to-leaf paths in a binary tree where the sum of the node values equals a given targetSum. A binary tree is provided through the root node, and every node contains an integer value. We are also given an integer targetSum.

leetcodemediumbacktrackingtreedepth-first-searchbinary-tree
LeetCode 1339 - Maximum Product of Splitted Binary Tree

That is a long, structured technical document with multiple required sections, complete Python and Go implementations, w

leetcodemediumtreedepth-first-searchbinary-tree
CF 42D - Strange town

We are asked to construct a fully connected graph of _N_ tourist attractions, where each road has a distinct positive integer cost not exceeding 1000.

codeforcescompetitive-programmingconstructive-algorithmsmath
LeetCode 817 - Linked List Components

The problem gives us a singly linked list where every node contains a unique integer value. We are also given an array nums, and every value in nums is guaranteed to appear somewhere in the linked list.

leetcodemediumarrayhash-tablelinked-list
LeetCode 268 - Missing Number

The problem gives an array nums containing n distinct integers. Every number is supposed to come from the range [0, n], which means there are actually n + 1 possible values in total. Since the array only contains n numbers, exactly one value from that range is missing.

leetcodeeasyarrayhash-tablemathbinary-searchbit-manipulationsorting
LeetCode 943 - Find the Shortest Superstring

The problem asks us to find the shortest superstring that contains all the given strings in the array words as substrings.

leetcodehardarraystringdynamic-programmingbit-manipulationbitmask
LeetCode 658 - Find K Closest Elements

The problem gives us a sorted integer array arr, along with two integers, k and x. We need to return exactly k elements from the array that are closest to x.

leetcodemediumarraytwo-pointersbinary-searchsliding-windowsortingheap-(priority-queue)
LeetCode 1424 - Diagonal Traverse II

The problem asks us to traverse a jagged 2D integer array nums diagonally. Specifically, elements are accessed by their

leetcodemediumarraysortingheap-(priority-queue)
CF 82A - Double Cola

Five people stand in a queue in a fixed order: Sheldon, Leonard, Penny, Rajesh, Howard. Whenever the person at the front buys a cola, that person immediately creates a copy of themselves, and both copies go to the back of the queue. The queue keeps growing forever.

codeforcescompetitive-programmingimplementationmath
CF 30C - Shooting Gallery

We are asked to help King Copa maximize his expected number of hits in a shooting gallery. The gallery is represented as a 2D plane, and each target appears at a specific point exactly at a specific time and disappears immediately afterward.

codeforcescompetitive-programmingdpprobabilities