brain

tamnd's digital brain — notes, problems, research

42648 notes

LeetCode 557 - Reverse Words in a String III

The problem requires reversing the characters of each individual word in a string while maintaining the original order of the words and the spacing between them. In other words, the sentence structure remains the same, but each word is mirrored in place.

leetcodeeasytwo-pointersstring
LeetCode 1684 - Count the Number of Consistent Strings

This problem asks us to determine how many strings in the words array are consistent with a given set of allowed charact

leetcodeeasyarrayhash-tablestringbit-manipulationcounting
LeetCode 1631 - Path With Minimum Effort

The problem gives us a grid called heights, where each cell contains an integer representing elevation. We start at the top-left corner (0, 0) and want to reach the bottom-right corner (rows - 1, columns - 1).

leetcodemediumarraybinary-searchdepth-first-searchbreadth-first-searchunion-findheap-(priority-queue)matrix
CF 110B - Lucky String

We need to build a lowercase string of length n that satisfies a special condition on repeated letters. For every character, we look at all positions where it appears.

codeforcescompetitive-programmingconstructive-algorithmsstrings
LeetCode 837 - New 21 Game

In this problem, Alice repeatedly draws random numbers until her score reaches at least k. Every draw independently produces an integer between 1 and maxPts, inclusive, and each value is equally likely.

leetcodemediummathdynamic-programmingsliding-windowprobability-and-statistics
LeetCode 454 - 4Sum II

The problem gives four integer arrays, nums1, nums2, nums3, and nums4, each containing n elements. We must count how many index tuples (i, j, k, l) satisfy: The important detail is that we are counting tuples of indices, not unique value combinations.

leetcodemediumarrayhash-table
CF 44J - Triminoes

We are given a rectangular board where some cells are missing. Every remaining cell is already colored either black or white in a chessboard pattern. The task is to cover all existing cells using straight triminoes of size 1 × 3 or 3 × 1.

codeforcescompetitive-programmingconstructive-algorithmsgreedy
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
LeetCode 1340 - Jump Game V

Here is a comprehensive solution guide for LeetCode 1340 following your requested format. The problem presents an array

leetcodehardarraydynamic-programmingsorting
LeetCode 510 - Inorder Successor in BST II

This problem asks us to find the in-order successor of a given node inside a Binary Search Tree, abbreviated as BST. Unlike the classic version of the problem, we are not given access to the root of the tree.

leetcodemediumtreebinary-search-treebinary-tree
LeetCode 162 - Find Peak Element

The problem gives us an integer array nums and asks us to find the index of any peak element. A peak element is defined as an element that is strictly greater than its immediate neighbors.

leetcodemediumarraybinary-search
LeetCode 1579 - Remove Max Number of Edges to Keep Graph Fully Traversable

The problem presents an undirected graph with n nodes and three types of edges: Type 1 for Alice, Type 2 for Bob, and Ty

leetcodehardunion-findgraph-theory
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 731 - My Calendar II

The problem asks us to design a calendar system that supports booking time intervals while enforcing one important rule: no point in time may be covered by three events simultaneously. Each event is represented as a half open interval [startTime, endTime).

leetcodemediumarraybinary-searchdesignsegment-treeprefix-sumordered-set
LeetCode 1816 - Truncate Sentence

The problem gives us a sentence s and an integer k. A sentence is guaranteed to contain words separated by exactly one space, with no extra spaces at the beginning or end. Our task is to return a new sentence that contains only the first k words from the original sentence.

leetcodeeasyarraystring
LeetCode 1788 - Maximize the Beauty of the Garden

We are given an integer array flowers, where each element represents the beauty value of a flower in a line. We may remove any flowers we want, while preserving the relative order of the remaining flowers. After removals, the remaining sequence must form a valid garden.

leetcodehardarrayhash-tablegreedyprefix-sum
CF 49D - Game

The game is played on a one-dimensional stripe of squares, each either black or white. Vasya paints the initial configuration, and Petya can then perform moves to achieve an alternating pattern, where no two adjacent squares share the same color.

codeforcescompetitive-programmingbrute-forcedpimplementation
LeetCode 1582 - Special Positions in a Binary Matrix

Here is a complete, detailed technical solution guide for LeetCode 1582 - Special Positions in a Binary Matrix, followin

leetcodeeasyarraymatrix
LeetCode 430 - Flatten a Multilevel Doubly Linked List

The problem gives us a special type of doubly linked list where every node contains four fields: The next and prev pointers behave exactly like a normal doubly linked list. The extra child pointer introduces another linked list that branches downward from the current node.

leetcodemediumlinked-listdepth-first-searchdoubly-linked-list
CF 19E - Fairy

We are given an undirected graph. Each edge represents a segment drawn between two points. We may erase exactly one edge, and after removing it we want the remaining graph to become bipartite.

codeforcescompetitive-programmingdfs-and-similardivide-and-conquerdsu
CF 2C - Commentator problem

We are given three circles on the plane. Each circle represents a stadium, with a center point and a radius. We need to find a point from which all three stadiums are seen under the same angle.

codeforcescompetitive-programminggeometry
LeetCode 1464 - Maximum Product of Two Elements in an Array

The problem gives an integer array nums, and asks us to choose two different indices i and j. For those two elements, we compute the expression: Our goal is to return the maximum possible value of this expression.

leetcodeeasyarraysortingheap-(priority-queue)
LeetCode 332 - Reconstruct Itinerary

The problem is asking us to reconstruct a flight itinerary given a list of tickets. Each ticket is a one-way flight represented as a pair of airport codes [from, to]. The traveler always starts at "JFK", and the itinerary must use all tickets exactly once.

leetcodehardarraystringdepth-first-searchgraph-theorysortingheap-(priority-queue)eulerian-circuit
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 19D - Points

We maintain a dynamic set of points on a 2D plane. Three operations are supported.

codeforcescompetitive-programmingdata-structures
LeetCode 846 - Hand of Straights

The problem asks us to determine whether a given collection of cards can be rearranged into groups of consecutive numbers, each of size groupSize.

leetcodemediumarrayhash-tablegreedysorting
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 32 - Longest Valid Parentheses

The problem asks us to find the length of the longest contiguous substring that forms a valid parentheses sequence. A valid parentheses sequence is one where every opening parenthesis '(' has a corresponding closing parenthesis ')', and the pairs are correctly nested.

leetcodehardstringdynamic-programmingstack
LeetCode 950 - Reveal Cards In Increasing Order

The problem gives us a deck of unique integer cards and asks us to arrange the deck so that a very specific reveal process produces the cards in increasing order. The reveal process works like this: 1. Reveal the top card and remove it from the deck. 2.

leetcodemediumarrayqueuesortingsimulation
LeetCode 2921 - Maximum Profitable Triplets With Increasing Prices II

The problem asks us to select three items from a store such that their prices are strictly increasing and their indices

leetcodehardarraybinary-indexed-treesegment-tree
LeetCode 411 - Minimum Unique Word Abbreviation

This problem asks us to generate the shortest possible abbreviation for a given target word such that the abbreviation cannot also represent any word in the dictionary. An abbreviation replaces one or more non-adjacent substrings with their lengths.

leetcodehardarraystringbacktrackingbit-manipulation
LeetCode 1221 - Split a String in Balanced Strings

This problem gives us a string s that contains only the characters 'L' and 'R'. The string is guaranteed to already be balanced overall, meaning the total number of 'L' characters equals the total number of 'R' characters.

leetcodeeasystringgreedycounting
LeetCode 962 - Maximum Width Ramp

The problem asks us to find the maximum width ramp in an array of integers. A ramp is defined as a pair of indices (i, j) such that: - i < j - nums[i] <= nums[j] The width of the ramp is simply the distance between the two indices: Our goal is to compute the largest possible…

leetcodemediumarraytwo-pointersstackmonotonic-stack
CF 62C - Inquisition

We are given up to 100 triangles on the plane. Each triangle represents a black spot on a white square. Triangles may overlap, intersect, or even completely cover one another. The task is to compute the perimeter of the union of all black regions.

codeforcescompetitive-programminggeometryimplementationsortings
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 76E - Points

We are given up to one hundred thousand points on a 2D plane. For every unordered pair of points, we must compute the squared Euclidean distance between them and add all those values together.

codeforcescompetitive-programmingimplementationmath
LeetCode 329 - Longest Increasing Path in a Matrix

The problem gives us a two-dimensional grid of integers called matrix. Each position in the grid contains a value, and we are asked to find the length of the longest strictly increasing path.

leetcodehardarraydynamic-programmingdepth-first-searchbreadth-first-searchgraph-theorytopological-sortmemoizationmatrix
LeetCode 809 - Expressive Words

The problem asks us to determine how many words in the words array can be transformed into the target string s using a very specific type of expansion operation.

leetcodemediumarraytwo-pointersstring
LeetCode 1146 - Snapshot Array

The problem asks us to implement a SnapshotArray, a data structure that behaves like an array but also allows taking snapshots of its state at any moment and retrieving the value of any element at a specific snapshot.

leetcodemediumarrayhash-tablebinary-searchdesign
LeetCode 1138 - Alphabet Board Path

The problem gives us a special alphabet board and asks us to generate the shortest sequence of moves needed to spell a target string. The board contains lowercase English letters arranged in rows: We always begin at position (0, 0), which corresponds to the character 'a'.

leetcodemediumhash-tablestring
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
CF 80B - Depression

We are given a digital time in HH:MM format and need to determine how far the analog clock hands must rotate from the initial position 12:00. The clock starts with both hands pointing at 12. We may rotate each hand independently, and only in the clockwise direction.

codeforcescompetitive-programminggeometrymath
LeetCode 1337 - The K Weakest Rows in a Matrix

Here is a comprehensive, detailed solution guide for LeetCode 1337 following your exact instructions. The problem provid

leetcodeeasyarraybinary-searchsortingheap-(priority-queue)matrix
LeetCode 128 - Longest Consecutive Sequence

The problem asks us to find the length of the longest sequence of consecutive integers in an unsorted array. A consecutive sequence means numbers that appear one after another numerically, regardless of their position in the array.

leetcodemediumarrayhash-tableunion-find
LeetCode 1124 - Longest Well-Performing Interval

Edit The problem gives us an array hours, where each element represents the number of hours an employee worked on a specific day. A day is classified as tiring if the employee worked strictly more than 8 hours. Otherwise, the day is considered non-tiring.

leetcodemediumarrayhash-tablestackmonotonic-stackprefix-sum
CF 62E - World Evil

We are asked to compute the maximum number of “tentacles” that can traverse a cylindrical grid from the leftmost column to the rightmost column, given capacities for every corridor connecting adjacent cells.

codeforcescompetitive-programmingdpflows
LeetCode 1771 - Maximize Palindrome Length From Subsequences

The problem gives us two strings, word1 and word2. We must choose a non-empty subsequence from each string, concatenate them together, and form a palindrome. Our goal is to maximize the length of that palindrome. A subsequence does not require characters to be contiguous.

leetcodehardstringdynamic-programming
CF 24D - Broken robot

The board has N rows and M columns. A robot starts at cell (i, j) and repeatedly performs one random move. From an interior cell it has four equally likely choices: stay in place, move left, move right, or move down.

codeforcescompetitive-programmingdpmathprobabilities
LeetCode 1577 - Number of Ways Where Square of Number Is Equal to Product of Two Numbers

The problem gives us two integer arrays, nums1 and nums2. We must count the number of valid triplets that satisfy one of

leetcodemediumarrayhash-tablemathtwo-pointers
LeetCode 689 - Maximum Sum of 3 Non-Overlapping Subarrays

The problem asks us to select exactly three non-overlapping subarrays from the input array nums, where each subarray has length k. Among all valid choices, we must maximize the total sum of all elements contained in those three subarrays.

leetcodehardarraydynamic-programmingsliding-windowprefix-sum
CF 124A - The number of positions

Petr is standing somewhere in a line containing n people. Positions are numbered from 1 at the front to n at the back. He knows two things about his position. At least a people are standing in front of him, and at most b people are standing behind him.

codeforcescompetitive-programmingmath
LeetCode 1241 - Number of Comments per Post

This problem asks us to analyze a database table named Submissions and determine how many unique comments belong to each post.

leetcodeeasydatabase
LeetCode 830 - Positions of Large Groups

The problem asks us to identify all large groups in a given string and return their positions as intervals. A group is a sequence of consecutive identical characters.

leetcodeeasystring
LeetCode 1842 - Next Palindrome Using Same Digits

The input is a numeric string num that is guaranteed to already be a palindrome. The task is to rearrange its digits to create another palindrome that is strictly larger than the original number, while also being the smallest such palindrome possible.

leetcodehardtwo-pointersstring
LeetCode 1292 - Maximum Side Length of a Square with Sum Less than or Equal to Threshold

That is a very large, multi-section request covering a full detailed guide for LeetCode 1292 with comprehensive explanat

leetcodemediumarraybinary-searchmatrixprefix-sum
CF 134C - Swaps

Each player initially owns cards of exactly one color, their own color. Player i starts with a[i] cards, all of color i. During a swap, two players exchange one card each. A player may only give away cards of their own color, and may never receive a color they already possess.

codeforcescompetitive-programmingconstructive-algorithmsgraphsgreedy
LeetCode 858 - Mirror Reflection

This problem describes a square room with perfectly reflective walls. The room has side length p, and there are three receptors placed at three corners of the square: - Receptor 0 is at the southeast corner - Receptor 1 is at the northeast corner - Receptor 2 is at the…

leetcodemediummathgeometrynumber-theory
LeetCode 333 - Largest BST Subtree

The problem gives us the root of an arbitrary binary tree and asks us to find the size of the largest subtree that is also a valid Binary Search Tree, abbreviated as BST. A subtree is any node together with all of its descendants. This means we cannot selectively ignore children.

leetcodemediumdynamic-programmingtreedepth-first-searchbinary-search-treebinary-tree
LeetCode 1478 - Allocate Mailboxes

Here’s a complete, detailed technical solution guide for LeetCode 1478 following your requested format and requirements.

leetcodehardarraymathdynamic-programmingsorting
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 54A - Presents

We are asked to estimate the minimum number of presents the Hedgehog will receive over the next N days. He has two rules governing present reception: every holiday he receives a gift, and he cannot go more than K days without receiving one.

codeforcescompetitive-programmingimplementation
LeetCode 455 - Assign Cookies

This problem asks us to maximize the number of children who can be satisfied with the available cookies. Each child has a greed factor, and each cookie has a size. A child becomes content only if they receive a cookie whose size is greater than or equal to their greed factor.

leetcodeeasyarraytwo-pointersgreedysorting
LeetCode 2004 - The Number of Seniors and Juniors to Join the Company

This problem requires determining how many candidates a company can hire as seniors and juniors under a fixed budget of $70000, following a strict priority: hire as many seniors as possible first, then use the remaining budget to hire juniors.

leetcodeharddatabase
CF 132A - Turing Tape

We are given the final text printed by INTERCAL's strange "Turing Tape" output procedure. Each printed character was produced from one integer of an unknown array. The encoding process depends on the previous printed character, so every step is linked to the one before it.

codeforcescompetitive-programmingimplementation
LeetCode 1183 - Maximum Number of Ones

The problem gives us a binary matrix M with dimensions height x width. Every cell in the matrix must contain either 0 or 1. There is one important restriction: Every square submatrix of size sideLength x sideLength may contain at most maxOnes cells equal to 1.

leetcodehardmathgreedysortingheap-(priority-queue)
LeetCode 1755 - Closest Subsequence Sum

The problem asks us to find a subsequence of a given integer array nums such that the sum of that subsequence is as close as possible to a given integer goal.

leetcodehardarraytwo-pointersdynamic-programmingbit-manipulationsortingbitmask
CF 47E - Cannon

We have a scenario where a cannon at the origin shoots a number of balls with the same initial speed, each at a given angle. The goal is to determine where each ball lands after either hitting a vertical wall or reaching the ground.

codeforcescompetitive-programmingdata-structuresgeometrysortings
LeetCode 657 - Robot Return to Origin

This problem asks us to determine whether a robot, starting at the origin (0, 0) on a 2D plane, returns to the origin after executing a sequence of moves. Each move is represented by a character in a string: 'R' moves right, 'L' moves left, 'U' moves up, and 'D' moves down.

leetcodeeasystringsimulation
LeetCode 1352 - Product of the Last K Numbers

This problem asks us to design a data structure that continuously processes a stream of integers and supports querying t

leetcodemediumarraymathdesigndata-streamprefix-sum
LeetCode 707 - Design Linked List

This problem asks us to implement our own linked list data structure from scratch without using any built in linked list library.

leetcodemediumlinked-listdesign
LeetCode 987 - Vertical Order Traversal of a Binary Tree

The problem asks us to compute the vertical order traversal of a binary tree. In simpler terms, we are asked to “look at the tree from the side” and collect the nodes that align in the same vertical column.

leetcodehardhash-tabletreedepth-first-searchbreadth-first-searchsortingbinary-tree
LeetCode 589 - N-ary Tree Preorder Traversal

The problem asks for a preorder traversal of an n-ary tree. In a preorder traversal, the order of visiting nodes is: first the root node, then recursively all the children from left to right.

leetcodeeasystacktreedepth-first-search
LeetCode 651 - 4 Keys Keyboard

The problem gives us a keyboard with four operations: - Press A, which inserts one character 'A' - Press Ctrl-A, which selects everything currently on the screen - Press Ctrl-C, which copies the selected text into a clipboard buffer - Press Ctrl-V, which pastes the clipboard…

leetcodemediummathdynamic-programming
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 496 - Next Greater Element I

The problem is asking us to find the next greater element for each element in nums1 within another array nums2. Formally, for each element in nums1, we need to locate its position in nums2 and then find the first element to its right in nums2 that is greater than itself.

leetcodeeasyarrayhash-tablestackmonotonic-stack
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 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
CF 97B - Superset

We start with a set of distinct lattice points on the plane. We may add more points, and the final set must satisfy a geometric condition for every pair of points. Take any two points.

codeforcescompetitive-programmingconstructive-algorithmsdivide-and-conquer
LeetCode 1258 - Synonymous Sentences

This problem asks us to generate all possible synonymous variations of a given sentence based on a list of equivalent wo

leetcodemediumarrayhash-tablestringbacktrackingsortunion-find
CF 8C - Looking for Order

We have a fixed starting point, the handbag, and up to 24 scattered objects on a 2D plane. Lena always starts at the handbag, walks around collecting at most two objects, returns to the handbag, then repeats until every object is stored back.

codeforcescompetitive-programmingbitmasksdp
LeetCode 1784 - Check if Binary String Has at Most One Segment of Ones

In this problem, we are given a binary string s that contains only the characters '0' and '1'. The string is guaranteed to begin with '1', which means there are no leading zeros. The task is to determine whether the string contains at most one contiguous segment of ones.

leetcodeeasystring
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 704 - Binary Search

This problem gives us a sorted array of integers named nums and a target integer named target. The array is sorted in ascending order, meaning every element is smaller than the elements that come after it. We must determine whether the target value exists in the array.

leetcodeeasyarraybinary-search
CF 64D - Presents

We are given three positive integers representing the prices of three presents. There are three sisters, ranked by age: eldest, middle, and youngest.

codeforcescompetitive-programming*specialgreedy
LeetCode 62 - Unique Paths

The problem describes a robot moving on a rectangular m x n grid. The robot starts at the top left corner of the grid and wants to reach the bottom right corner. At every step, the robot is only allowed to move either one cell to the right or one cell downward.

leetcodemediummathdynamic-programmingcombinatorics
LeetCode 1092 - Shortest Common Supersequence

The problem asks us to construct the shortest possible string that contains both str1 and str2 as subsequences. A subsequence does not require characters to appear contiguously. Instead, the characters only need to appear in the same relative order.

leetcodehardstringdynamic-programming
LeetCode 1496 - Path Crossing

This problem asks us to simulate movement on a 2D plane according to a string of directional instructions. Each characte

leetcodeeasyhash-tablestring
LeetCode 769 - Max Chunks To Make Sorted

This problem is asking us to determine the maximum number of contiguous chunks into which we can split an array such that sorting each chunk individually and concatenating them results in a fully sorted array.

leetcodemediumarraystackgreedysortingmonotonic-stack
LeetCode 1845 - Seat Reservation Manager

The problem requires designing a system to manage seat reservations for n seats numbered from 1 to n. You need to implement a SeatManager class with two main operations: reserve and unreserve.

leetcodemediumdesignheap-(priority-queue)
LeetCode 1459 - Rectangles Area

You included two different problems in one message, and the second prompt supersedes the first. I will provide the detai

leetcodemediumdatabase
CF 115B - Lawnmower

We are given a rectangular garden represented as an n×m grid. Each cell contains either grass, which does not require mowing, or weeds, which do. We start at the top-left corner of the garden, always on grass, and initially facing right.

codeforcescompetitive-programminggreedysortings
LeetCode 1405 - Longest Happy String

The problem asks us to construct the longest possible string using only the characters 'a', 'b', and 'c', while satisfyi

leetcodemediumstringgreedyheap-(priority-queue)
LeetCode 1811 - Find Interview Candidates

The problem is asking us to identify users who qualify as interview candidates based on their performance in LeetCode contests. We are provided two tables: Contests and Users.

leetcodemediumdatabase
LeetCode 765 - Couples Holding Hands

This problem gives us a row of seats represented by the array row, where each value is the ID of the person currently sitting in that seat. The row contains 2n people, meaning there are exactly n couples.

leetcodehardgreedydepth-first-searchbreadth-first-searchunion-findgraph-theory
LeetCode 1484 - Group Sold Products By The Date

The problem gives us a database table named Activities with two columns: | Column | Meaning | | --- | --- | | selldate |

leetcodeeasydatabase
CF 129A - Cookies

We are given several bags of cookies, where each bag contains some number of cookies. Olga wants to steal exactly one bag. After removing that bag, the total number of cookies left behind must be even so the two sisters can split them equally.

codeforcescompetitive-programmingimplementation
CF 114B - PFAST Inc.

We are given a small group of people and a list of pairs who cannot work together. We need to choose the largest possible subset such that every pair inside the chosen group is compatible. This is naturally a graph problem. Think of each volunteer as a vertex.

codeforcescompetitive-programmingbitmasksbrute-forcegraphs
LeetCode 1083 - Sales Analysis II

This problem asks us to identify all buyers who purchased the product named S8 but never purchased the product named iPhone. We are given two tables: The Product table stores information about products. Each row contains a unique productid, the product name, and its unit price.

leetcodeeasydatabase
CF 121A - Lucky Sum

We need to evaluate a sum over an interval [l, r]. For every integer x in that range, we compute next(x), where next(x) means the smallest lucky number greater than or equal to x. A lucky number is a positive integer whose decimal digits are only 4 and 7.

codeforcescompetitive-programmingimplementation
LeetCode 1792 - Maximum Average Pass Ratio

The problem gives us several classes, where each class is represented as [passi, totali]. The value passi tells us how many students currently pass the exam, while totali tells us the total number of students in that class.

leetcodemediumarraygreedyheap-(priority-queue)