brain

tamnd's digital brain — notes, problems, research

42648 notes

CF 115A - Party

We are asked to organize a company party such that no group contains both a manager and their subordinate, directly or indirectly. The input describes each employee's immediate manager: a number from 1 to n, or -1 if they have no manager.

codeforcescompetitive-programmingdfs-and-similargraphstrees
LeetCode 179 - Largest Number

This problem asks us to rearrange a list of non-negative integers so that, when concatenated together, they form the largest possible number. At first glance, this may look like a straightforward sorting problem where we simply sort the numbers in descending order.

leetcodemediumarraystringgreedysorting
LeetCode 610 - Triangle Judgement

The problem is asking us to determine, for each row in a table called Triangle, whether the three given line segments can form a valid triangle. Each row contains three integers x, y, and z representing the lengths of the segments.

leetcodeeasydatabase
CF 16E - Fish

We have n fish in a lake. Every day, exactly one unordered pair of currently alive fish is chosen uniformly at random. When fish i meets fish j, fish i eats fish j with probability a[i][j], and fish j eats fish i with probability a[j][i] = 1 - a[i][j].

codeforcescompetitive-programmingbitmasksdpprobabilities
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
LeetCode 1137 - N-th Tribonacci Number

The problem asks us to compute the n-th number in the Tribonacci sequence. The Tribonacci sequence is very similar to the Fibonacci sequence, except that instead of summing the previous two numbers, each value is formed by summing the previous three numbers.

leetcodeeasymathdynamic-programmingmemoization
LeetCode 1515 - Best Position for a Service Centre

The problem asks us to find the optimal location for a service center on a 2D map such that the total Euclidean distance

leetcodehardarraymathgeometryrandomized
LeetCode 908 - Smallest Range I

The problem gives us an integer array nums and an integer k. For every element in the array, we are allowed to modify it once by adding any integer value in the range [-k, k].

leetcodeeasyarraymath
LeetCode 1345 - Jump Game IV

The problem is asking for the minimum number of steps required to reach the last index of an integer array, starting fro

leetcodehardarrayhash-tablebreadth-first-search
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 754 - Reach a Number

The problem asks us to find the minimum number of moves required to reach a specific position on an infinite number line starting from position 0. Each move i allows you to move exactly i steps, either to the left or the right.

leetcodemediummathbinary-search
LeetCode 1389 - Create Target Array in the Given Order

This problem asks us to build a new array called target by following a sequence of insertion operations. We are given tw

leetcodeeasyarraysimulation
LeetCode 562 - Longest Line of Consecutive One in Matrix

The problem gives us a binary matrix mat of size m x n, where every cell contains either 0 or 1. We need to find the length of the longest consecutive sequence of 1s that appears in any of four directions: 1. Horizontal, from left to right 2. Vertical, from top to bottom 3.

leetcodemediumarraydynamic-programmingmatrix
LeetCode 363 - Max Sum of Rectangle No Larger Than K

The problem asks us to find the rectangular submatrix whose sum is as large as possible while still being less than or equal to a given integer k. A rectangle in a matrix is any contiguous block of cells formed by choosing a range of rows and a range of columns.

leetcodehardarraybinary-searchmatrixprefix-sumordered-set
LeetCode 907 - Sum of Subarray Minimums

The problem asks us to compute the sum of the minimum value of every possible contiguous subarray of a given array. For an array arr, every contiguous slice of the array is considered a subarray. For each subarray, we determine its minimum element.

leetcodemediumarraydynamic-programmingstackmonotonic-stack
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
LeetCode 1764 - Form Array by Concatenating Subarrays of Another Array

The problem asks us to determine whether we can select disjoint subarrays from a given array nums such that each subarray matches exactly one of the subarrays in the groups array, in order.

leetcodemediumarraytwo-pointersgreedystring-matching
LeetCode 490 - The Maze

This problem asks us to determine whether a rolling ball can stop exactly at a destination cell inside a maze. The maze is represented as a two-dimensional grid where: - 0 represents an empty space the ball can roll through - 1 represents a wall The important detail is that…

leetcodemediumarraydepth-first-searchbreadth-first-searchmatrix
LeetCode 283 - Move Zeroes

The problem gives us an integer array nums and asks us to move every 0 element to the end of the array while preserving the relative order of all non-zero elements. The phrase "relative order" is extremely important.

leetcodeeasyarraytwo-pointers
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 703 - Kth Largest Element in a Stream

The problem asks us to design a data structure that continuously tracks the kth largest element in a stream of integers. We are given an integer k and an initial list of numbers called nums. After initialization, new numbers are added one at a time using the add method.

leetcodeeasytreedesignbinary-search-treeheap-(priority-queue)binary-treedata-stream
LeetCode 1505 - Minimum Possible Integer After at Most K Adjacent Swaps On Digits

The problem gives us a numeric string num and an integer k. Each operation allows us to swap two adjacent digits. We may

leetcodehardstringgreedybinary-indexed-treesegment-tree
LeetCode 1526 - Minimum Number of Increments on Subarrays to Form a Target Array

The problem gives us a target array and asks us to build it starting from an array of all zeros. The only operation allowed is selecting any contiguous subarray and incrementing every element in that subarray by exactly one.

leetcodehardarraydynamic-programmingstackgreedymonotonic-stack
LeetCode 379 - Design Phone Directory

The problem asks us to design a data structure that manages a fixed pool of phone numbers. Initially, every number from 0 to maxNumbers - 1 is available. The directory must support three operations efficiently. The get() operation should assign and return an available number.

leetcodemediumarrayhash-tablelinked-listdesignqueue
CF 22C - System Administrator

We are asked to design a network of servers where each server is a node, and each connection between two servers is an undirected edge. There are n servers and we are allowed exactly m connections.

codeforcescompetitive-programminggraphs
LeetCode 459 - Repeated Substring Pattern

The problem asks us to determine whether a given string can be formed by repeating one of its substrings multiple times. In other words, we want to know if there exists some substring pattern such that concatenating that pattern repeatedly recreates the entire string exactly.

leetcodeeasystringstring-matching
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
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
LeetCode 1177 - Can Make Palindrome from Substring

The problem asks us to determine whether certain substrings of a given string s can be rearranged and partially modified to form a palindrome. A palindrome is a string that reads the same forward and backward.

leetcodemediumarrayhash-tablestringbit-manipulationprefix-sum
LeetCode 151 - Reverse Words in a String

The problem asks us to take a string s containing words separated by spaces and return a new string where the words appear in reverse order. A word is defined as any sequence of non-space characters, and words can be separated by multiple spaces.

leetcodemediumtwo-pointersstring
LeetCode 250 - Count Univalue Subtrees

The problem asks us to count how many subtrees in a binary tree are "uni-value" subtrees. A uni-value subtree is a subtree in which every node has the same value. A subtree consists of a node together with all of its descendants.

leetcodemediumtreedepth-first-searchbinary-tree
LeetCode 1559 - Detect Cycles in 2D Grid

The problem asks us to detect cycles in a 2D grid of characters where all cells in the cycle must contain the same character. A cycle is defined as a path that starts and ends at the same cell and has a length of four or more.

leetcodemediumarraydepth-first-searchbreadth-first-searchunion-findmatrix
LeetCode 711 - Number of Distinct Islands II

In this problem, we are given a binary matrix where each cell contains either 0 or 1. A value of 1 represents land, while 0 represents water. An island is formed by connecting adjacent land cells in the four cardinal directions: up, down, left, and right.

leetcodehardarrayhash-tabledepth-first-searchbreadth-first-searchunion-findsortingmatrixhash-function
LeetCode 968 - Binary Tree Cameras

This problem asks us to determine the minimum number of cameras required to monitor all nodes in a binary tree. Each camera placed on a node can monitor its parent, itself, and its immediate children.

leetcodeharddynamic-programmingtreedepth-first-searchbinary-tree
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 1586 - Binary Search Tree Iterator II

The problem requires implementing a BSTIterator class that allows forward and backward traversal over the in-order sequence of a Binary Search Tree (BST). In-order traversal of a BST visits nodes in ascending order.

leetcodemediumstacktreedesignbinary-search-treebinary-treeiterator
CF 107C - Arrangement

We have n seats and n professors. Professor 1 is the most senior, professor n is the least senior. Some pairs of seats impose ordering constraints. If (a, b) is given, then the professor sitting in seat a must be more senior than the professor sitting in seat b.

codeforcescompetitive-programmingbitmasksdp
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 285 - Inorder Successor in BST

This problem asks us to find the in-order successor of a given node p inside a Binary Search Tree, abbreviated as BST. An in-order traversal of a BST visits nodes in sorted order: 1. Traverse the left subtree 2. Visit the current node 3.

leetcodemediumtreedepth-first-searchbinary-search-treebinary-tree
LeetCode 1159 - Market Analysis II

This problem asks us to determine, for every user in the marketplace system, whether the brand of the second item they sold matches their favorite brand. The database contains three tables: - The Users table stores user information, including their favoritebrand.

leetcodeharddatabase
LeetCode 768 - Max Chunks To Make Sorted II

The problem asks us to partition an array into the maximum possible number of contiguous chunks such that, after sorting each chunk independently and concatenating the results, the entire array becomes globally sorted. The key detail is that each chunk must remain contiguous.

leetcodehardarraystackgreedysortingmonotonic-stack
LeetCode 1391 - Check if There is a Valid Path in a Grid

The problem presents a grid where each cell represents a street segment with a specific orientation, denoted by a number

leetcodemediumarraydepth-first-searchbreadth-first-searchunion-findmatrix
CF 83E - Two Subsequences

We are given a sequence of binary strings, all of equal length, and we need to split them into two subsequences in a way that minimizes the sum of the lengths of their compressed forms.

codeforcescompetitive-programmingbitmasksdp
LeetCode 1595 - Minimum Cost to Connect Two Groups of Points

The problem is asking us to find the minimum cost to connect two groups of points, where the first group has size1 point

leetcodehardarraydynamic-programmingbit-manipulationmatrixbitmask
CF 128C - Games with Rectangle

We start with a rectangle drawn on grid paper. Only the border matters, not the interior. Players repeatedly draw a strictly smaller rectangle inside the previous one.

codeforcescompetitive-programmingcombinatoricsdp
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 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
LeetCode 1669 - Merge In Between Linked Lists

The problem asks us to merge two singly linked lists in a very specific way. We are given list1 and list2, with sizes n

leetcodemediumlinked-list
LeetCode 1208 - Get Equal Substrings Within Budget

The problem asks us to determine the longest contiguous substring of s that can be transformed into the corresponding substring of t without exceeding a given budget, maxCost.

leetcodemediumstringbinary-searchsliding-windowprefix-sum
LeetCode 568 - Maximum Vacation Days

This problem asks us to maximize the total number of vacation days over k weeks while traveling between n cities under specific flight constraints. We start in city 0 on the Monday morning of week 0.

leetcodehardarraydynamic-programmingmatrix
LeetCode 880 - Decoded String at Index

The problem gives us an encoded string s that represents a potentially enormous decoded string. The decoding process works incrementally from left to right. When we encounter a letter, we append it directly to the decoded tape.

leetcodemediumstringstack
CF 15D - Map

We are given a rectangular map of size n × m, where each cell has a non-negative height. Peter wants to build cities of size a × b. To place a city, he must level the ground inside its rectangle by reducing all cells to the minimum height within that rectangle.

codeforcescompetitive-programmingdata-structuresimplementationsortings
LeetCode 770 - Basic Calculator IV

The problem requires parsing and evaluating a mathematical expression that includes integers, variables, addition, subtraction, multiplication, and parentheses, while also applying a substitution map for certain variables.

leetcodehardhash-tablemathstringstackrecursion
LeetCode 1193 - Monthly Transactions I

The problem is asking us to produce aggregated statistics on transactions, grouped by month and country, from the Transactions table.

leetcodemediumdatabase
LeetCode 1799 - Maximize Score After N Operations

The problem asks us to maximize the total score obtained by performing n operations on an array nums of size 2 n.

leetcodehardarraymathdynamic-programmingbacktrackingbit-manipulationnumber-theorybitmask
LeetCode 390 - Elimination Game

The problem gives us a sorted list containing every integer from 1 to n. We repeatedly eliminate numbers in alternating directions until only one number remains.

leetcodemediummathrecursion
LeetCode 294 - Flip Game II

This problem describes a two-player impartial game played on a string consisting only of '+' and '-' characters. A valid move consists of selecting any pair of consecutive "++" characters and flipping them into "--". The players alternate turns.

leetcodemediummathdynamic-programmingbacktrackingmemoizationgame-theory
LeetCode 491 - Non-decreasing Subsequences

The problem gives us an integer array nums and asks us to return every distinct subsequence that is non-decreasing and has length at least two. A subsequence is formed by deleting zero or more elements from the array without changing the relative order of the remaining elements.

leetcodemediumarrayhash-tablebacktrackingbit-manipulation
LeetCode 955 - Delete Columns to Make Sorted II

This problem asks us to remove the minimum number of columns from a list of equal length strings so that the resulting array of strings becomes lexicographically sorted.

leetcodemediumarraystringgreedy
LeetCode 1091 - Shortest Path in Binary Matrix

The problem asks us to find the shortest path from the top-left corner (0, 0) to the bottom-right corner (n-1, n-1) of a given n x n binary matrix grid. A cell with a value of 0 is passable, while a cell with a value of 1 is blocked.

leetcodemediumarraybreadth-first-searchmatrix
LeetCode 1197 - Minimum Knight Moves

This problem asks us to compute the minimum number of moves a knight needs to travel from the origin [0, 0] to a target position [x, y] on an infinite chessboard.

leetcodemediumbreadth-first-search
LeetCode 1527 - Patients With a Condition

The problem asks us to query a database table Patients and return the records of patients who have Type I Diabetes. Each

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 1502 - Can Make Arithmetic Progression From Sequence

The problem asks us to determine whether the elements of a given array can be rearranged so that they form an arithmetic

leetcodeeasyarraysorting
LeetCode 1753 - Maximum Score From Removing Stones

The problem is a combinatorial game involving three piles of stones with counts a, b, and c. In each move, you are allowed to pick two different non-empty piles and remove one stone from each, earning 1 point per move. The game ends when fewer than two piles have stones left.

leetcodemediummathgreedyheap-(priority-queue)
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 352 - Data Stream as Disjoint Intervals

This problem asks us to process a stream of non-negative integers and continuously maintain a compact representation of all numbers seen so far. Instead of storing every individual number separately, we want to group consecutive numbers into disjoint intervals.

leetcodehardhash-tablebinary-searchunion-finddesigndata-streamordered-set
LeetCode 608 - Tree Node

This problem gives us a database table named Tree, where each row represents a node in a tree structure. Every node has a unique identifier id and a pid column that stores the identifier of its parent node.

leetcodemediumdatabase
LeetCode 1553 - Minimum Number of Days to Eat N Oranges

This problem asks us to compute the minimum number of days required to eat exactly n oranges, given three possible actions that can be performed each day. On any single day, we may choose one of the following operations: 1. Eat exactly one orange. 2.

leetcodeharddynamic-programmingmemoization
CF 132B - Piet

We are asked to simulate a simplified Piet interpreter on a small rectangular grid. Each cell is a pixel with a color between 0 and 9, where 0 is black and other digits are colored blocks.

codeforcescompetitive-programmingimplementation
LeetCode 1227 - Airplane Seat Assignment Probability

This problem involves a scenario with n passengers and n seats on an airplane. Each passenger has a designated seat, but the first passenger has lost their ticket and picks a seat randomly.

leetcodemediummathdynamic-programmingbrainteaserprobability-and-statistics
LeetCode 1096 - Brace Expansion II

The problem asks us to interpret a string expression representing a set of words generated according to a specific grammar and return all distinct words sorted in lexicographical order. The expression can contain lowercase letters, curly braces {}, and commas ,.

leetcodehardhash-tablestringbacktrackingstackbreadth-first-searchsorting
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
LeetCode 1062 - Longest Repeating Substring

The problem asks us to find the length of the longest substring that appears at least twice in a given string s. A substring is a contiguous sequence of characters inside a string. The repeated substrings may overlap with each other, which is an important detail.

leetcodemediumstringbinary-searchdynamic-programmingrolling-hashsuffix-arrayhash-function
LeetCode 1731 - The Number of Employees Which Report to Each Employee

The Employees table stores information about employees inside a company. Each row represents one employee and contains four columns: | Column | Meaning | | --- | --- | | employeeid | Unique identifier for the employee | | name | Employee name | | reportsto | The manager this…

leetcodeeasydatabase
LeetCode 582 - Kill Process

This problem models processes in an operating system as a tree structure. Every process has exactly one parent, except for the root process, which has no parent and is identified by ppid[i] = 0.

leetcodemediumarrayhash-tabletreedepth-first-searchbreadth-first-search
LeetCode 1107 - New Users Daily Count

We are given a database table called Traffic that records different user activities on different dates. Each row contains a userid, an activity type, and an activitydate.

leetcodemediumdatabase
CF 11B - Jumping Jack

Jack starts at position 0 on a number line. His jumps have fixed lengths: the first jump must have length 1, the second jump length 2, the third jump length 3, and so on. For every jump he may choose either direction.

codeforcescompetitive-programmingmath
LeetCode 1385 - Find the Distance Value Between Two Arrays

The problem is asking us to compute the distance value between two arrays arr1 and arr2 given a threshold d. Specificall

leetcodeeasyarraytwo-pointersbinary-searchsorting
LeetCode 457 - Circular Array Loop

This problem asks us to determine whether a circular array contains a valid cycle under a specific movement rule. Each element in the array represents how far we move from the current index.

leetcodemediumarrayhash-tabletwo-pointers
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
CF 9B - Running Student

The student is already riding a bus that moves along the x-axis from left to right. The bus stops at fixed positions (xi, 0) in increasing order. At any stop except the first one, the student may get off and run directly to the university located at (xu, yu).

codeforcescompetitive-programmingbrute-forcegeometryimplementation
CF 27C - Unordered Subsequence

We are given a sequence of integers, and we are asked to extract the shortest subsequence that is _not ordered_. A sequence is considered ordered if it is either entirely non-decreasing or entirely non-increasing.

codeforcescompetitive-programmingconstructive-algorithmsgreedy
LeetCode 187 - Repeated DNA Sequences

This problem asks us to find all repeated DNA subsequences of a fixed length, specifically length 10, inside a given DNA string. The input is a string s, where each character represents a DNA nucleotide.

leetcodemediumhash-tablestringbit-manipulationsliding-windowrolling-hashhash-function
LeetCode 2023 - Number of Pairs of Strings With Concatenation Equal to Target

The problem asks us to find the number of ordered pairs of indices (i, j) in a list of digit strings nums such that concatenating nums[i] and nums[j] produces exactly the string target.

leetcodemediumarrayhash-tablestringcounting
LeetCode 1404 - Number of Steps to Reduce a Number in Binary Representation to One

The problem gives us a binary number represented as a string s. Our task is to determine how many operations are require

leetcodemediumstringbit-manipulationsimulation
LeetCode 554 - Brick Wall

The problem gives us a wall made of multiple rows of bricks. Each row is represented as an array of integers, where each integer describes the width of a brick. Every brick has height 1, and all rows together form a rectangle with the same total width.

leetcodemediumarrayhash-table
LeetCode 1521 - Find a Value of a Mysterious Function Closest to Target

The problem defines a mysterious function func(arr, l, r) that computes the bitwise AND of all elements in the subarray

leetcodehardarraybinary-searchbit-manipulationsegment-tree
LeetCode 1059 - All Paths from Source Lead to Destination

This problem gives us a directed graph with n nodes labeled from 0 to n - 1. Each directed edge [a, b] means there is a one way path from node a to node b.

leetcodemediumgraph-theorytopological-sort
LeetCode 1102 - Path With Maximum Minimum Value

The problem asks us to find the maximum possible score of a path from the top-left corner (0, 0) to the bottom-right corner (m-1, n-1) of a 2D grid. Each cell in the grid contains an integer value, and the score of a path is defined as the minimum value along that path.

leetcodemediumarraybinary-searchdepth-first-searchbreadth-first-searchunion-findheap-(priority-queue)matrix
LeetCode 1006 - Clumsy Factorial

The problem asks us to compute a clumsy factorial for a given positive integer n. A standard factorial multiplies all integers from n down to 1, but the clumsy factorial modifies the operations: instead of multiplying all numbers, it cycles through '', '/', '+', and '-' in…

leetcodemediummathstacksimulation
LeetCode 1216 - Valid Palindrome III

The problem asks us to determine whether a given string s can become a palindrome after removing at most k characters. A palindrome is a string that reads the same forwards and backwards, and a k-palindrome is one that can be turned into a palindrome with at most k deletions.

leetcodehardstringdynamic-programming
LeetCode 2037 - Minimum Number of Moves to Seat Everyone

This problem asks us to assign students to seats such that every student occupies exactly one seat and no two students share the same seat. Each student can move left or right on a number line, and every movement by one position costs exactly one move.

leetcodeeasyarraygreedysortingcounting-sort
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
CF 33E - Helper

Valera has a list of subjects he knows how to solve. Every subject takes a fixed amount of working time. Students come with requests: each request has a subject, an exam deadline, and a reward. If Valera finishes the solution strictly before the exam starts, he gets paid.

codeforcescompetitive-programming
LeetCode 1829 - Maximum XOR for Each Query

The problem gives us a sorted array nums and an integer maximumBit. For every query, we must choose a number k such that: - 0 <= k < 2^maximumBit - The value of: is as large as possible.

leetcodemediumarraybit-manipulationprefix-sum
LeetCode 789 - Escape The Ghosts

This problem takes place on an infinite two dimensional grid. You begin at coordinate (0, 0) and want to reach a destination called target. At the same time, several ghosts also move on the grid from their own starting positions.

leetcodemediumarraymath
CF 81A - Plug-in

We are given a lowercase string that may contain accidental repeated keystrokes. Whenever two equal characters become adjacent, both characters must be deleted. After removing one pair, new adjacent equal pairs may appear, and those must also be removed.

codeforcescompetitive-programmingimplementation
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
CF 69C - Game

Each player owns a multiset of artifacts. Some artifacts are basic and can be purchased directly. Some are composite and can be crafted from several basic artifacts in fixed quantities. Whenever a player buys a basic artifact, it is added to their inventory.

codeforcescompetitive-programmingimplementation