brain

tamnd's digital brain — notes, problems, research

43815 notes

LeetCode 3316 - Find Maximum Removals From Source String

We are given three inputs: - source, the original string of length n - pattern, a string that is guaranteed to already be a subsequence of source - targetIndices, a sorted list of indices in source that are eligible for removal An operation consists of removing a character…

leetcodemediumarrayhash-tabletwo-pointersstringdynamic-programming
LeetCode 2263 - Make Array Non-decreasing or Non-increasing

The problem asks us to transform a given integer array nums into either a non-decreasing or a non-increasing array with the minimum number of operations. Each operation allows increasing or decreasing an element by exactly 1.

leetcodehardarraydynamic-programminggreedyheap-(priority-queue)
LeetCode 2591 - Distribute Money to Maximum Children

Problem Understanding

leetcodeeasymathgreedy
LeetCode 2386 - Find the K-Sum of an Array

That is a long, structured reference document with multiple sections, full prose explanations, worked examples, two complete implementations, test suites, and edge case analysis.

leetcodehardarraysortingheap-(priority-queue)
LeetCode 3271 - Hash Divided String

The problem asks us to compute a hashed string from an input string s by dividing it into equal-length substrings and then mapping each substring to a single character using a simple hashing function.

leetcodemediumstringsimulation
CF 416A - Guess a number!

We are given a sequence of statements about an unknown integer value $y$. Each statement restricts $y$ relative to some integer threshold $x$, and is either strict or non-strict. After each statement, we are also told whether that statement is true or false.

codeforcescompetitive-programminggreedyimplementationtwo-pointers
CF 194B - Square

We have a person walking around the border of a square whose side length is n. He starts at the lower-left corner and places a cross there immediately. After that, he keeps moving clockwise along the perimeter, placing another cross every n + 1 meters.

codeforcescompetitive-programmingmath
CF 166C - Median

We start with an array of integers and a target value x. We may append any number of extra integers to the array, and we want the median of the final array to become exactly x. The task is to compute the smallest number of added elements needed to make that happen.

codeforcescompetitive-programminggreedymathsortings
CF 167E - Wizards and Bets

We are given a directed acyclic graph. Some vertices are sources, meaning no edge enters them. Some vertices are sinks, meaning no edge leaves them. The number of sources and sinks is guaranteed to be equal.

codeforcescompetitive-programmingdfs-and-similargraphsmathmatrices
CF 196B - Infinite Maze

We are given a finite maze of size n × m. Some cells are walls, some are open, and one cell contains the starting position S. The maze is not used only once.

codeforcescompetitive-programmingdfs-and-similargraphs
LeetCode 3168 - Minimum Number of Chairs in a Waiting Room

The problem gives us a string s that represents events happening in a waiting room over time. Each character corresponds to one second. If the character is 'E', one person enters the room and occupies a chair. If the character is 'L', one person leaves the room and frees a chair.

leetcodeeasystringsimulation
LeetCode 3350 - Adjacent Increasing Subarrays Detection II

The problem asks us to find the largest possible length k such that there exist two adjacent subarrays of length k in a given array nums, where both subarrays are strictly increasing.

leetcodemediumarraybinary-search
LeetCode 2766 - Relocate Marbles

The problem gives us an array nums representing the positions of marbles on a number line. Multiple marbles may exist at the same position, so nums can contain duplicates. We are also given two arrays, moveFrom and moveTo, which describe a sequence of move operations.

leetcodemediumarrayhash-tablesortingsimulation
LeetCode 2637 - Promise Time Limit

This problem asks us to implement a time-limited wrapper around an asynchronous function. We are given an input function fn that returns a Promise and a time limit t in milliseconds. The task is to return a new function that executes fn but enforces a maximum execution time.

leetcodemedium
LeetCode 2943 - Maximize Area of Square Hole in Grid

The grid is formed by n + 2 horizontal bars and m + 2 vertical bars. These bars divide the plane into unit squares. The bars are numbered starting from 1. Some horizontal bars listed in hBars may be removed, and some vertical bars listed in vBars may also be removed.

leetcodemediumarraysorting
LeetCode 2227 - Encrypt and Decrypt Strings

This problem asks us to implement an Encrypter class that can both encrypt and decrypt strings according to custom character mappings. The keys array provides the characters that can be encrypted, and values provides the corresponding 2-character strings that each key maps to.

leetcodehardarrayhash-tablestringdesigntrie
LeetCode 2744 - Find Maximum Number of String Pairs

This problem gives us an array words containing distinct strings. Every string has length exactly 2, and all strings consist of lowercase English letters.

leetcodeeasyarrayhash-tablestringsimulation
LeetCode 1885 - Count Pairs in Two Arrays

The problem asks us to count the number of index pairs (i, j) such that i < j and the sum of elements at these indices in nums1 is greater than the sum of elements at the same indices in nums2.

leetcodemediumarraytwo-pointersbinary-searchsorting
LeetCode 3398 - Smallest Substring With Identical Characters I

The problem gives us a binary string s consisting of only '0' and '1' characters and an integer numOps representing the maximum number of bit flips we can perform.

leetcodehardarraybinary-searchenumeration
LeetCode 2121 - Intervals Between Identical Elements

You are given a 0-indexed integer array arr. For every index i, you must compute the sum of distances between i and every other index j where arr[i] == arr[j].

leetcodemediumarrayhash-tableprefix-sum
LeetCode 2780 - Minimum Index of a Valid Split

The problem asks us to find a minimum index at which a given integer array nums can be split into two non-empty contiguous subarrays, such that both subarrays share the same dominant element as the original array.

leetcodemediumarrayhash-tablesorting
LeetCode 2955 - Number of Same-End Substrings

The problem asks us to compute the number of same-end substrings within specified subranges of a given string s. A substring is same-end if its first and last character are identical. We are given multiple queries in the form [li, ri], each representing a substring s[li..ri].

leetcodemediumarrayhash-tablestringcountingprefix-sum
LeetCode 2472 - Maximum Number of Non-overlapping Palindrome Substrings

The problem asks us to find the maximum number of non-overlapping palindrome substrings in a given string s such that each substring has a length of at least k.

leetcodehardtwo-pointersstringdynamic-programminggreedy
CF 148C - Terse princess

We need to construct an array of groom fortunes so that the princess reacts in exactly the required way. For every groom after the first one, two special situations are possible. If the current fortune is larger than every previous fortune, the princess says Oh....

codeforcescompetitive-programmingconstructive-algorithmsgreedy
LeetCode 2293 - Min Max Game

This problem asks us to repeatedly transform an array until only one number remains. At every round, we reduce the size of the array by half using alternating min and max operations on adjacent pairs.

leetcodeeasyarraysimulation
LeetCode 2022 - Convert 1D Array Into 2D Array

The problem asks us to transform a one-dimensional array, original, into a two-dimensional array with m rows and n columns.

leetcodeeasyarraymatrixsimulation
LeetCode 2691 - Immutability Helper

This problem is asking us to implement an immutability helper for JSON-like objects in JavaScript. Specifically, we need to create a class ImmutableHelper that allows users to "mutate" a proxy version of the object without affecting the original object.

leetcodehard
LeetCode 2487 - Remove Nodes From Linked List

The problem gives us the head of a singly linked list and asks us to remove every node that has a strictly greater value somewhere to its right. In other words, for each node, we must determine whether there exists another node later in the list whose value is larger.

leetcodemediumlinked-liststackrecursionmonotonic-stack
LeetCode 2782 - Number of Unique Categories

This problem asks us to determine how many distinct categories exist among n elements. The elements are labeled from 0 to n - 1, but we are not given the category values directly.

leetcodemediumunion-findinteractivecounting
LeetCode 2437 - Number of Valid Clock Times

The problem asks us to determine the number of valid times that can be formed from a partially known digital clock string of the format "hh:mm", where unknown digits are represented by '?'. Each '?

leetcodeeasystringenumeration
CF 352B - Jeff and Periods

We are given a sequence of integers, and for each distinct value we want to understand how its occurrences are spaced across the array. For any value $x$, we look at all indices where $x$ appears.

codeforcescompetitive-programmingimplementationsortings
LeetCode 1901 - Find a Peak Element II

The problem requires finding a peak element in a 2D matrix. A peak element is defined as an element that is strictly greater than its adjacent neighbors to the top, bottom, left, and right.

leetcodemediumarraybinary-searchmatrix
LeetCode 2052 - Minimum Cost to Separate Sentence Into Rows

This problem asks us to format a sentence into multiple rows such that each row has length at most k. The sentence consists of words separated by spaces, and words cannot be split across rows. We may only insert line breaks between words.

leetcodemediumstringdynamic-programming
LeetCode 2283 - Check if Number Has Equal Digit Count and Digit Value

This problem asks us to verify a self-descriptive property of a string of digits. You are given a string num of length n, where each character is a digit between '0' and '9'.

leetcodeeasyhash-tablestringcounting
LeetCode 2235 - Add Two Integers

The problem is asking for the sum of two integers num1 and num2. In simpler terms, you are given two numbers, and you need to calculate their total. The input integers can be negative, zero, or positive, and the output should be a single integer representing the sum.

leetcodeeasymath
LeetCode 2344 - Minimum Deletions to Make Array Divisible

The problem gives us two arrays of positive integers, nums and numsDivide. We are allowed to delete any number of elements from nums, and our goal is to make the smallest remaining element in nums divide every number in numsDivide.

leetcodehardarraymathsortingheap-(priority-queue)number-theory
LeetCode 3126 - Server Utilization Time

This problem provides a table named Servers that records status changes for multiple servers over time. Each row contains three values: - serverid, which identifies the server - statustime, which indicates when the status change occurred - sessionstatus, which is either…

leetcodemediumdatabase
CF 231C - To Add or Not to Add

We are given an array of integers and a limited number of increment operations. Each operation increases a single element by one, and the same element can be increased multiple times.

codeforcescompetitive-programmingbinary-searchsortingstwo-pointers
LeetCode 2902 - Count of Sub-Multisets With Bounded Sum

The problem asks us to count all possible sub-multisets of an array nums such that the sum of elements in each sub-multiset is within a given inclusive range [l, r]. A sub-multiset is like a subset, but it accounts for repeated elements in the original array.

leetcodehardarrayhash-tabledynamic-programmingsliding-window
LeetCode 1863 - Sum of All Subset XOR Totals

This problem asks us to compute the sum of the XOR values of every possible subset of a given array. A subset is formed by choosing any combination of elements from the array, including the empty subset and the full array itself.

leetcodeeasyarraymathbacktrackingbit-manipulationcombinatoricsenumeration
LeetCode 2425 - Bitwise XOR of All Pairings

The problem gives us two arrays, nums1 and nums2, and asks us to compute the XOR of every possible pair formed between the two arrays. For every element in nums1, we pair it with every element in nums2 exactly once.

leetcodemediumarraybit-manipulationbrainteaser
CF 214A - System of Equations

We need to count how many non-negative integer pairs (a, b) satisfy two equations at the same time: - a² + b = n - a + b² = m The input gives the two target values n and m.

codeforcescompetitive-programmingbrute-force
LeetCode 2614 - Prime In Diagonal

The problem gives us a square matrix nums of size n x n. We need to examine the values that appear on the two diagonals of the matrix and return the largest value among them that is prime.

leetcodeeasyarraymathmatrixnumber-theory
LeetCode 3178 - Find the Child Who Has the Ball After K Seconds

The problem asks us to simulate a game in which n children, numbered from 0 to n - 1, stand in a straight line. Child 0 starts with a ball, and every second the child holding the ball passes it to the next child in the current direction.

leetcodeeasymathsimulation
LeetCode 2321 - Maximum Score Of Spliced Array

The problem presents two integer arrays, nums1 and nums2, of equal length n. You are allowed to select a contiguous subarray from both arrays and swap them exactly once, or choose not to swap at all.

leetcodehardarraydynamic-programming
CF 431D - Random Task

We need to find a positive integer n such that inside the interval (n, 2n], exactly m numbers have exactly k ones in their binary representation.

codeforcescompetitive-programmingbinary-searchbitmaskscombinatoricsdpmath
LeetCode 2459 - Sort Array by Moving Items to Empty Space

The array contains every integer from 0 to n - 1 exactly once. The value 0 represents the empty space, while every other number represents an item that should eventually appear in sorted order. The operation is unusual compared to normal array sorting problems.

leetcodehardarrayhash-tablesorting
CF 429A - Xor-tree

We are given a rooted tree with n nodes, each node labeled with a 0 or 1. We are also given a target configuration of 0s and 1s for each node. The only operation allowed is to "pick" a node, which flips its value and every second-level descendant down the tree.

codeforcescompetitive-programmingdfs-and-similartrees
LeetCode 2889 - Reshape Data: Pivot

This problem gives us a Pandas DataFrame named weather with three columns: - city, the name of a city - month, the name of a month - temperature, the recorded temperature for that city during that month The task is to reshape the table using a pivot operation.

leetcodeeasy
LeetCode 2523 - Closest Prime Numbers in Range

The problem asks us to find two prime numbers inside a given inclusive range [left, right] such that the difference between them is as small as possible.

leetcodemediummathnumber-theory
CF 444A - DZY Loves Physics

We are given an undirected graph where each vertex carries a positive weight and each edge also carries a positive weight.

codeforcescompetitive-programminggreedymath
LeetCode 2713 - Maximum Strictly Increasing Cells in a Matrix

The problem gives us an m x n matrix where each cell contains an integer value. We may start from any cell, and from the current cell we are allowed to move only within the same row or the same column.

leetcodehardarrayhash-tablebinary-searchdynamic-programmingmemoizationsortingmatrixordered-set
CF 421D - Bug in Code

We are given a network of coders, and each coder makes a claim during a meeting: they point to two other coders and assert that the culprit is one of those two people. We then have to choose exactly two coders to bring in as suspects.

codeforcescompetitive-programmingbinary-searchdata-structuressortings
LeetCode 2484 - Count Palindromic Subsequences

The problem asks us to count all palindromic subsequences of length 5 within a given string of digits s. A palindromic subsequence is a sequence that reads the same forward and backward, and a subsequence can be formed by deleting zero or more characters without changing the…

leetcodehardstringdynamic-programming
LeetCode 2423 - Remove Letter To Equalize Frequency

The problem asks us to determine if we can remove exactly one character from a string word such that all remaining characters in the string have the same frequency. The input string consists of lowercase English letters and has a length between 2 and 100.

leetcodeeasyhash-tablestringcounting
CF 152A - Marks

We are asked to find the number of students in a class who are the best in at least one subject. Each student has grades for multiple subjects, with each grade being a single-digit number between 1 and 9.

codeforcescompetitive-programmingimplementation
LeetCode 2470 - Number of Subarrays With LCM Equal to K

The problem gives us an integer array nums and an integer k. We must count how many contiguous subarrays have a least common multiple, LCM, exactly equal to k. A subarray is any continuous segment of the array. For every possible subarray, we compute the LCM of all its elements.

leetcodemediumarraymathnumber-theory
LeetCode 1865 - Finding Pairs With a Certain Sum

This problem asks us to design a mutable data structure that supports two operations efficiently over two arrays, nums1 and nums2. The first array, nums1, is fixed after initialization and never changes.

leetcodemediumarrayhash-tabledesign
LeetCode 2690 - Infinite Method Object

This problem asks us to implement a function that returns an infinite-method object. The defining property of this object is that any method name can be accessed and called, and when invoked, it should return the exact name of the method.

leetcodeeasy
LeetCode 2014 - Longest Subsequence Repeated k Times

The problem asks us to find the longest subsequence of a string s that can be repeated k times while still being a subsequence of s. A subsequence is derived by deleting zero or more characters from a string without changing the order of the remaining characters.

leetcodehardhash-tabletwo-pointersstringbacktrackingcountingenumeration
LeetCode 2498 - Frog Jump II

The problem gives us a sorted array stones, where each value represents the position of a stone in a river. The frog starts on the first stone, which is always at position 0, and must travel to the last stone and then eventually return to the first stone.

leetcodemediumarraybinary-searchgreedy
LeetCode 3163 - String Compression III

The problem asks us to implement a specialized string compression algorithm. Given an input string word, we are required to build a compressed version by repeatedly taking prefixes consisting of consecutive repeating characters, limited to a maximum length of 9, and appending…

leetcodemediumstring
LeetCode 2215 - Find the Difference of Two Arrays

This problem asks us to compare two integer arrays and identify the unique values that appear in one array but not the other. We are given two 0-indexed integer arrays, nums1 and nums2.

leetcodeeasyarrayhash-table
LeetCode 2320 - Count Number of Ways to Place Houses

The problem presents a street with n plots on each side, for a total of 2 n plots. The goal is to count the number of ways to place houses on these plots such that no two houses are adjacent on the same side of the street.

leetcodemediumdynamic-programming
LeetCode 2858 - Minimum Edge Reversals So Every Node Is Reachable

This problem gives us a directed graph with n nodes and exactly n - 1 edges. The important guarantee is that if we ignore the direction of every edge, the graph becomes a tree. That means the underlying structure is connected and acyclic. Each edge is currently directed one way.

leetcodeharddynamic-programmingdepth-first-searchbreadth-first-searchgraph-theory
CF 182D - Common Divisors

We are given two lowercase strings. A string d is called a divisor of another string s if s can be formed by concatenating d several times in a row. For example, "ab" divides "ababab" because repeating "ab" three times gives the full string.

codeforcescompetitive-programmingbrute-forcehashingimplementationmathstrings
CF 254E - Dormitory

Vasya receives food every morning. The food from day i can only be eaten on day i or day i + 1. Every day Vasya himself must consume exactly v kilograms.

codeforcescompetitive-programmingdpimplementation
LeetCode 3087 - Find Trending Hashtags

The problem asks us to find the top 3 trending hashtags from a table of tweets for a specific month, February 2024. Each tweet contains exactly one hashtag. The input is represented by a Tweets table with columns userid, tweetid, tweet, and tweetdate.

leetcodemediumdatabase
LeetCode 3033 - Modify the Matrix

The problem is asking us to take a given m x n matrix, potentially containing -1 values, and produce a modified matrix in which each -1 is replaced by the maximum value in its respective column.

leetcodeeasyarraymatrix
LeetCode 3172 - Second Day Verification

The problem requires identifying users who verified their signup exactly on the second day after registering. We have two tables: emails and texts. The emails table contains the emailid, the userid, and the signupdate.

leetcodeeasydatabase
CF 172D - Calendar Reform

Each year in Berland has a certain number of days. The first year has a days, the next has a + 1, and so on for n consecutive years. For a year with x days, the government chooses a month length that satisfies two conditions. First, the month length must be a perfect square.

codeforcescompetitive-programming*specialnumber-theory
LeetCode 3015 - Count the Number of Houses at a Certain Distance I

Here is a complete technical solution guide for LeetCode 3015 - Count the Number of Houses at a Certain Distance I, formatted according to your specifications. The problem describes a simple linear city with n houses numbered from 1 to n.

leetcodemediumbreadth-first-searchgraph-theoryprefix-sum
LeetCode 2820 - Election Results

The Votes table records every voter-candidate selection. A voter may vote for multiple candidates, vote for exactly one candidate, or choose not to vote at all. The important detail is that every voter contributes a total voting weight of exactly 1.

leetcodemedium
LeetCode 2626 - Array Reduce Transformation

The problem is asking us to simulate a "reduce" operation on an array of integers without using the built-in Array.reduce method. The input consists of three elements: an array nums, a function fn, and an initial value init.

leetcodeeasy
LeetCode 2198 - Number of Single Divisor Triplets

The problem asks us to count how many ordered triplets of distinct indices (i, j, k) satisfy a very specific divisibility condition.

leetcodemediumarraycountingenumeration
CF 263B - Squares

Codeforces 263B: Squares

codeforcescompetitive-programminggreedyimplementationsortings
LeetCode 2252 - Dynamic Pivoting of a Table

This problem requires implementing a SQL-style pivot operation programmatically. The input is a table named Products with columns productid, store, and price, where each row represents the price of a product in a specific store.

leetcodeharddatabase
CF 254D - Rats

The problem presents a rectangular basement of a store as an n × m grid, where some cells are walls, some are empty, and some contain sleeping rats.

codeforcescompetitive-programmingbrute-forcedfs-and-similargraphsimplementationshortest-paths
CF 424D - Biathlon Track

We are given a rectangular grid where each cell has a height. A biathlon track must be the boundary of a sub-rectangle, and athletes run clockwise along this boundary.

codeforcescompetitive-programmingbinary-searchbrute-forceconstructive-algorithmsdata-structuresdp
LeetCode 3169 - Count Days Without Meetings

The problem gives us a total number of working days, numbered from 1 to days, along with a list of meeting intervals. Each interval [start, end] represents a meeting that occupies every day from start through end, inclusive.

leetcodemediumarraysorting
LeetCode 2480 - Form a Chemical Bond

The problem asks us to identify all valid chemical bonds that can form between elements in a given table. The Elements table contains three columns: symbol, type, and electrons. The type column is an enumeration of 'Metal', 'Nonmetal', and 'Noble'.

leetcodeeasydatabase
LeetCode 1888 - Minimum Number of Flips to Make the Binary String Alternating

The problem asks us to transform a binary string s into an alternating string using the minimum number of flip operations (Type-2), while optionally performing any number of rotations (Type-1).

leetcodemediumstringdynamic-programmingsliding-window
LeetCode 3258 - Count Substrings That Satisfy K-Constraint I

The problem gives us a binary string s, meaning the string contains only the characters '0' and '1', along with an integer k. A substring is considered valid if it satisfies the k-constraint.

leetcodeeasystringsliding-window
CF 241D - Numbers

We are given a sequence of distinct integers. We may keep any subsequence, preserving the original order, and remove the rest. The remaining sequence must satisfy two conditions simultaneously. First, the xor of all remaining numbers must be zero.

codeforcescompetitive-programming
CF 253E - Printer

We are simulating a single-threaded printer that receives tasks over time. Each task arrives at a given time, has a known number of pages, and a priority that determines the order in which it is served when multiple tasks are waiting.

codeforcescompetitive-programmingbinary-searchdata-structuresimplementationsortings
LeetCode 3100 - Water Bottles II

This problem models a bottle exchange process where the exchange rate increases after every successful trade. You start with numBottles full water bottles. Every time you drink a full bottle, it becomes an empty bottle.

leetcodemediummathsimulation
CF 216E - Martian Luck

We are given a sequence of digits written in base k. Every digit is between 0 and k - 1, and one special digit b is called lucky. For every substring of the digit sequence, we interpret that substring as a base-k number, allowing leading zeroes.

codeforcescompetitive-programmingmathnumber-theory
LeetCode 1898 - Maximum Number of Removable Characters

The problem gives us two strings, s and p, and a list of indices removable. The string p is guaranteed to be a subsequence of s, meaning all characters in p appear in s in the same order, though not necessarily consecutively.

leetcodemediumarraytwo-pointersstringbinary-search
CF 303C - Minimum Modular

We are given a set of distinct integers. We may delete at most k of them, where k ≤ 4. After deleting, we want all remaining numbers to produce different remainders modulo some positive integer m. Two numbers collide modulo m exactly when their difference is divisible by m.

codeforcescompetitive-programmingbrute-forcegraphsmathnumber-theory
LeetCode 2368 - Reachable Nodes With Restrictions

That is a large, highly structured guide. To make sure I target the exact problem and keep the response complete in a single message, can you confirm you want the full solution guide for LeetCode 2368 - Reachable Nodes With Restrictions?

leetcodemediumarrayhash-tabletreedepth-first-searchbreadth-first-searchunion-findgraph-theory
LeetCode 2455 - Average Value of Even Numbers That Are Divisible by Three

The problem asks us to calculate the average of all integers in an array nums that satisfy two conditions simultaneously: they must be even and divisible by 3.

leetcodeeasyarraymath
LeetCode 2458 - Height of Binary Tree After Subtree Removal Queries

This problem asks us to answer multiple independent queries on a binary tree. For each query, we temporarily remove an entire subtree rooted at a specific node, then compute the height of the remaining tree.

leetcodehardarraytreedepth-first-searchbreadth-first-searchbinary-tree
LeetCode 3115 - Maximum Prime Difference

The problem gives us an integer array nums, and we need to find the maximum distance between the indices of any two prime numbers in the array. More specifically, we are interested in indices i and j such that both nums[i] and nums[j] are prime numbers.

leetcodemediumarraymathnumber-theory
LeetCode 3386 - Button with Longest Push Time

The problem gives us a sequence of keyboard button press events. Each event is represented as: Here: - index is the identifier of the button that was pressed. - time is the moment when the press happened.

leetcodeeasyarray
LeetCode 2385 - Amount of Time for Binary Tree to Be Infected

This problem asks us to model the spread of an infection across a binary tree. Each node in the tree has a unique integer value, and the infection starts from a specific node, identified by start.

leetcodemediumhash-tabletreedepth-first-searchbreadth-first-searchbinary-tree
LeetCode 1899 - Merge Triplets to Form Target Triplet

The problem asks whether it is possible to create a specific target triplet [x, y, z] as an element of a given list of triplets by repeatedly merging pairs of triplets using a component-wise maximum operation.

leetcodemediumarraygreedy
LeetCode 3192 - Minimum Operations to Make Binary Array Elements Equal to One II

This problem asks us to take a binary array nums, which contains only 0s and 1s, and transform it so that all elements become 1 using the minimum number of allowed operations.

leetcodemediumarraydynamic-programminggreedy
CF 183B - Zoo

We are asked to maximize the total number of flamingos that can be observed from a row of binoculars on the x-axis. Each binocular sits at position (i,0) and can be aimed in any direction.

codeforcescompetitive-programmingbrute-forcegeometry
LeetCode 1881 - Maximum Value after Insertion

This problem asks us to insert a single digit x into a very large integer n, represented as a string, in a position that maximizes the resulting numerical value. The integer n can be either positive or negative.

leetcodemediumstringgreedy
LeetCode 2910 - Minimum Number of Groups to Create a Valid Assignment

This problem gives us an array of integers representing balls. Balls with the same value are indistinguishable for grouping purposes, and every group must contain balls of only one value. The challenge comes from the balancing constraint.

leetcodemediumarrayhash-tablegreedy