brain

tamnd's digital brain — notes, problems, research

43815 notes

LeetCode 1024 - Video Stitching

The problem asks us to cover a sporting event that lasts time seconds using a set of video clips. Each clip is defined by its start and end times, [starti, endi], and clips can overlap or extend beyond each other.

leetcodemediumarraydynamic-programminggreedy
LeetCode 1949 - Strong Friendship

The problem gives us a table named Friendship, where every row represents a friendship relationship between two users. E

leetcodemediumdatabase
CF 92A - Chips

We have n walruses arranged in a circle. The presenter starts with m chips and distributes them in order. Walrus 1 receives 1 chip, walrus 2 receives 2 chips, and so on up to walrus n, after which the cycle repeats again from walrus 1.

codeforcescompetitive-programmingimplementationmath
LeetCode 1607 - Sellers With No Sales

This problem asks us to identify all sellers who did not make any sales during the year 2020. We are given three databas

leetcodeeasydatabase
LeetCode 814 - Binary Tree Pruning

This problem asks us to modify a binary tree by removing every subtree that does not contain at least one node with value 1. A subtree consists of a node and all of its descendants. If an entire subtree contains only 0 values, then that subtree should be deleted from the tree.

leetcodemediumtreedepth-first-searchbinary-tree
LeetCode 67 - Add Binary

You are given two strings, a and b, where each string represents a binary number. A binary number contains only the characters '0' and '1'. The task is to add these two binary numbers together and return the result as another binary string.

leetcodeeasymathstringbit-manipulationsimulation
LeetCode 489 - Robot Room Cleaner

This problem is an interactive backtracking problem where we must control a robot without directly seeing the room layout. Unlike traditional grid traversal problems, we are not given access to the actual room matrix during execution.

leetcodehardbacktrackinginteractive
LeetCode 1827 - Minimum Operations to Make the Array Increasing

The problem asks us to transform a given integer array nums into a strictly increasing array using the minimum number of operations. An operation consists of incrementing any element of the array by 1.

leetcodeeasyarraygreedy
LeetCode 1299 - Replace Elements with Greatest Element on Right Side

The problem gives us an integer array arr and asks us to replace every element with the greatest value that appears some

leetcodeeasyarray
LeetCode 1735 - Count Ways to Make Array With Product

The problem asks us to count the number of ways to fill an array of size ni with positive integers such that the product of all elements equals ki. Each query in the input array queries is independent, meaning we compute the answer for each (ni, ki) pair separately.

leetcodehardarraymathdynamic-programmingcombinatoricsnumber-theory
CF 34A - Reconnaissance 2

We are given the heights of soldiers standing in a circle. Two soldiers can form a reconnaissance unit if they stand next to each other and their height difference is as small as possible among all neighboring pairs.

codeforcescompetitive-programmingimplementation
LeetCode 1785 - Minimum Elements to Add to Form a Given Sum

The problem gives us an integer array nums, a maximum allowed absolute value limit, and a target sum called goal.

leetcodemediumarraygreedy
CF 135E - Weak Subsequence

We are looking at finite strings over an alphabet of size k. For every such string, define a special value: Take all substrings of the string. Among them, some substrings can also appear as a subsequence in a non-contiguous way.

codeforcescompetitive-programmingcombinatorics
LeetCode 237 - Delete Node in a Linked List

This problem asks us to delete a node from a singly linked list, but with an unusual restriction: we are not given access to the head of the list. Instead, we are only given a reference to the node that should be deleted.

leetcodemediumlinked-list
LeetCode 1587 - Bank Account Summary II

This problem asks us to analyze banking transaction data and determine which users currently have a balance greater than 10000. We are given two database tables: The Users table stores account information.

leetcodeeasydatabase
LeetCode 1555 - Bank Account Summary

The problem gives us two database tables, Users and Transactions, and asks us to compute the final account balance for every user after applying all recorded transactions. The Users table contains the starting credit balance for each user.

leetcodemediumdatabase
LeetCode 622 - Design Circular Queue

The problem asks us to implement a circular queue, a fixed-size queue where the end wraps back to the start to efficiently reuse empty space.

leetcodemediumarraylinked-listdesignqueue
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
CF 82B - Sets

We are given all pairwise unions of some hidden disjoint sets. The original sets themselves are not shown. Suppose the hidden sets are $S1, S2, dots, Sn$. For every pair $i neq j$, we are given the set $Si cup Sj$.

codeforcescompetitive-programmingconstructive-algorithmshashingimplementation
CF 105C - Item World

We have a collection of items, and every item belongs to exactly one of three equipment classes: weapon, armor, or orb. Each item has three base stats, attack, defense, and resistance, plus a capacity telling us how many residents it can hold. Residents also come in three types.

codeforcescompetitive-programmingbrute-forceimplementationsortings
LeetCode 1094 - Car Pooling

This problem asks us to determine whether a car can successfully complete a series of passenger trips without ever exceeding its seating capacity.

leetcodemediumarraysortingheap-(priority-queue)simulationprefix-sum
LeetCode 1552 - Magnetic Force Between Two Balls

The problem asks us to distribute m balls into n baskets located at given positions along a line in such a way that the minimum distance between any two balls is maximized. The magnetic force between two balls is defined as the absolute difference of their positions.

leetcodemediumarraybinary-searchsorting
CF 83D - Numbers

We need to count integers inside the interval $[a,b]$ whose smallest divisor greater than $1$ is exactly $k$. For a number $x$, saying that its smallest divisor is $k$ means two things happen simultaneously: 1. $x$ is divisible by $k$. 2.

codeforcescompetitive-programmingdpmathnumber-theory
LeetCode 601 - Human Traffic of Stadium

The problem asks us to extract all consecutive records from a Stadium table where the people count is at least 100, and the consecutive streak has a length of three or more. Each row has a unique id and a corresponding visitdate.

leetcodeharddatabase
LeetCode 1366 - Rank Teams by Votes

The problem describes a voting based ranking system where every voter ranks all teams from best to worst. Each vote is r

leetcodemediumarrayhash-tablestringsortingcounting
CF 66C - Petya and File System

Each input line describes the full path of one file inside a file system. A path looks like: The disk name is the root and is not considered a folder. Every component between the disk and the file is a folder. The last component is always a file.

codeforcescompetitive-programmingdata-structuresimplementation
LeetCode 687 - Longest Univalue Path

This problem asks us to find the longest path in a binary tree where every node along the path has the same value. The key detail is that the path length is measured in edges, not nodes.

leetcodemediumtreedepth-first-searchbinary-tree
LeetCode 1714 - Sum Of Special Evenly-Spaced Elements In Array

The problem requires calculating sums of specific subsets of an integer array nums based on queries. Each query [xi, yi] specifies a starting index xi and a step yi. The sum for this query includes all elements nums[j] such that j starts at xi and increases in steps of yi (i.e.

leetcodehardarraydynamic-programming
LeetCode 1633 - Percentage of Users Attended a Contest

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

leetcodeeasydatabase
LeetCode 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 446 - Arithmetic Slices II - Subsequence

The problem asks us to count how many arithmetic subsequences exist inside a given integer array nums. An arithmetic sequence is a sequence where the difference between consecutive elements is constant. The sequence must contain at least three elements.

leetcodehardarraydynamic-programming
LeetCode 1588 - Sum of All Odd Length Subarrays

The problem asks us to calculate the sum of all odd-length subarrays of a given array of positive integers. A subarray is any contiguous sequence of elements from the original array.

leetcodeeasyarraymathprefix-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 748 - Shortest Completing Word

The problem gives us a string called licensePlate and an array of candidate words called words. We must find the shortest word that satisfies all the letter requirements contained in licensePlate. The key detail is that only alphabetic characters matter.

leetcodeeasyarrayhash-tablestring
LeetCode 1153 - String Transforms Into Another String

The problem gives us two strings, str1 and str2, which are guaranteed to have the same length. We want to determine whether it is possible to transform str1 into str2 using a sequence of character conversion operations.

leetcodehardhash-tablestringgraph-theory
LeetCode 1128 - Number of Equivalent Domino Pairs

The problem is asking us to count all pairs of dominoes in a list that are equivalent, where two dominoes [a, b] and [c, d] are considered equivalent if one is a rotation of the other, meaning either (a == c and b == d) or (a == d and b == c).

leetcodeeasyarrayhash-tablecounting
LeetCode 857 - Minimum Cost to Hire K Workers

In this problem, we are given two arrays, quality and wage, where each index represents a worker. The value quality[i] describes how much work or contribution the i-th worker provides, while wage[i] describes the minimum amount that worker is willing to accept.

leetcodehardarraygreedysortingheap-(priority-queue)
LeetCode 587 - Erect the Fence

This problem is asking us to find the convex hull of a set of points on a 2D plane. The input trees is a list of coordinates where each coordinate [xi, yi] represents the location of a tree in the garden.

leetcodehardarraymathgeometry
LeetCode 1269 - Number of Ways to Stay in the Same Place After Some Steps

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

leetcodeharddynamic-programming
LeetCode 233 - Number of Digit One

Given a non-negative integer n, we must count how many times the digit 1 appears in every number from 0 through n, inclusive. The important detail is that we are not counting how many numbers contain the digit 1.

leetcodehardmathdynamic-programmingrecursion
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
LeetCode 579 - Find Cumulative Salary of an Employee

This problem asks us to compute a cumulative salary summary for each employee based on their monthly salaries over the year 2020. The input is a table Employee where each row contains an employee id, the month (1 through 12), and the salary for that month.

leetcodeharddatabase
LeetCode 1716 - Calculate Money in Leetcode Bank

The problem describes a repeating weekly saving pattern. Hercy deposits money into the LeetCode bank every day, and the amount increases in a structured way. On the very first Monday, he deposits 1 dollar. Each following day in the same week increases by 1.

leetcodeeasymath
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
CF 137A - Postcards and photos

We are given a string made of two characters, C and P. Each character represents one object hanging on the wall. C means postcard, P means photo. Polycarpus removes objects from left to right. He cannot skip positions, and at any moment he may carry only one type of object.

codeforcescompetitive-programmingimplementation
LeetCode 677 - Map Sum Pairs

The problem asks us to design a custom data structure that behaves like a map from strings to integers, while also supporting efficient prefix-based sum queries. There are two operations: 1. insert(key, val) This operation stores a string key with an integer value.

leetcodemediumhash-tablestringdesigntrie
CF 69A - Young Physicist

We are given several force vectors acting on a body in three-dimensional space. Each vector has three components: its effect along the x-axis, y-axis, and z-axis. A body is in equilibrium only if the total force acting on it is zero in every direction.

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

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

leetcodemediumarraybinary-indexed-treesegment-tree
LeetCode 83 - Remove Duplicates from Sorted List

This problem asks us to remove duplicate values from a sorted singly linked list so that every distinct value appears exactly once.

leetcodeeasylinked-list
LeetCode 1494 - Parallel Courses II

The problem asks us to determine the minimum number of semesters required to complete n courses when there are prerequis

leetcodeharddynamic-programmingbit-manipulationgraph-theorybitmask
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
CF 2A - Winner

The game records a sequence of rounds. In each round, one player either gains or loses some number of points. At the end, the player with the highest total score should win.

codeforcescompetitive-programminghashingimplementation
LeetCode 847 - Shortest Path Visiting All Nodes

The problem gives us an undirected and connected graph with n nodes labeled from 0 to n - 1. The graph is represented as an adjacency list, where graph[i] contains all nodes directly connected to node i.

leetcodeharddynamic-programmingbit-manipulationbreadth-first-searchgraph-theorybitmask
CF 40B - Repaintings

We start with an n × m chessboard. The top-left cell is black, so the coloring alternates exactly like a normal chessboard. Only the initially black cells participate in the repainting process.

codeforcescompetitive-programmingmath
LeetCode 1019 - Next Greater Node In Linked List

The problem asks us to process a singly-linked list and, for each node, determine the value of the next node that has a strictly larger value.

leetcodemediumarraylinked-liststackmonotonic-stack
LeetCode 1114 - Print in Order

This problem asks us to coordinate three independent threads so that they execute in a strict order, regardless of how the operating system schedules them. We are given a class with three methods, first(), second(), and third().

leetcodeeasyconcurrency
LeetCode 1614 - Maximum Nesting Depth of the Parentheses

This problem asks us to compute the maximum nesting depth of parentheses in a valid parentheses string. A valid parentheses string, often abbreviated as VPS, is a string where every opening parenthesis '(' has a matching closing parenthesis ')', and the parentheses are…

leetcodeeasystringstack
LeetCode 260 - Single Number III

The problem gives an integer array nums where every value appears exactly twice, except for two numbers that appear only once. The task is to find those two unique numbers and return them in any order.

leetcodemediumarraybit-manipulation
CF 42A - Guilty --- to the kitchen!

We want to cook soup using several ingredients that must appear in a fixed ratio. If the recipe says the proportions are a1, a2, ..., an, then the final soup must contain:

codeforcescompetitive-programminggreedyimplementation
LeetCode 90 - Subsets II

The problem asks us to generate every possible subset of a given integer array. A subset is any selection of elements from the array, including the empty subset and the subset containing all elements.

leetcodemediumarraybacktrackingbit-manipulation
LeetCode 1306 - Jump Game III

The problem gives us an array of non-negative integers and a starting index. From any position i, we are allowed to jump

leetcodemediumarraydepth-first-searchbreadth-first-search
LeetCode 753 - Cracking the Safe

This problem asks us to generate the shortest possible string that guarantees a safe will unlock at some point while typing it. The safe password has exactly n digits, and each digit can be any value from 0 to k - 1. The safe does not validate the entire entered sequence at once.

leetcodehardstringdepth-first-searchgraph-theoryeulerian-circuit
CF 38D - Vasya the Architect

We stack cubes one by one. Every cube is axis-aligned, and its projection on the ground is a square. Since the cubes are actual cubes, the side length is determined by the square base.

codeforcescompetitive-programmingimplementation
LeetCode 949 - Largest Time for Given Digits

The problem provides an array of exactly four digits. Using each digit exactly once, we must construct the latest possible valid 24-hour time in the format "HH:MM".

leetcodemediumarraystringbacktrackingenumeration
LeetCode 1781 - Sum of Beauty of All Substrings

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

leetcodemediumhash-tablestringcounting
CF 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 1531 - String Compression II

The problem asks us to minimize the length of a run-length encoded string after deleting at most k characters from the o

leetcodehardstringdynamic-programming
LeetCode 931 - Minimum Falling Path Sum

The problem asks for the minimum sum of any falling path through an n x n integer matrix. A falling path is defined as a sequence of elements starting from any element in the first row and moving row by row to the last row.

leetcodemediumarraydynamic-programmingmatrix
LeetCode 540 - Single Element in a Sorted Array

The problem gives us a sorted integer array where every value appears exactly twice, except for one value that appears only once. Our task is to find that unique value. The important detail is that the array is already sorted.

leetcodemediumarraybinary-search
LeetCode 724 - Find Pivot Index

The problem asks us to find an index in the array such that the sum of all elements strictly to the left of that index is equal to the sum of all elements strictly to the right of that index. More formally, for an index i: - Left sum = nums[0] + nums[1] + ...

leetcodeeasyarrayprefix-sum
LeetCode 779 - K-th Symbol in Grammar

The problem defines a special binary grammar sequence that grows row by row. The first row contains only a single value: Every later row is generated from the previous one using these rules: - Replace every 0 with 01 - Replace every 1 with 10 This means the rows evolve like…

leetcodemediummathbit-manipulationrecursion
LeetCode 883 - Projection Area of 3D Shapes

The problem gives us an n x n matrix called grid. Each cell grid[i][j] represents how many 1 x 1 x 1 cubes are stacked vertically at position (i, j) on a flat surface.

leetcodeeasyarraymathgeometrymatrix
LeetCode 482 - License Key Formatting

The problem gives us a string s that represents a license key. The string contains uppercase letters, lowercase letters, digits, and dashes. The existing dashes are only separators and do not necessarily represent the correct final grouping.

leetcodeeasystring
LeetCode 1583 - Count Unhappy Friends

In this problem, we are given n friends, where n is always even. Every friend ranks all other friends in order of preference. The earlier someone appears in a person's preference list, the more that person is preferred. We are also given a final pairing arrangement.

leetcodemediumarraysimulation
CF 91A - Newspaper Headline

We have a source string s1, which represents the headline of one newspaper. We may take as many copies of this headline as we want and concatenate them together.

codeforcescompetitive-programminggreedystrings
LeetCode 1659 - Maximize Grid Happiness

This problem asks us to place introverts and extroverts inside an m x n grid in a way that maximizes the total happiness score. Every grid cell can either remain empty, contain one introvert, or contain one extrovert.

leetcodeharddynamic-programmingbit-manipulationmemoizationbitmask
CF 68B - Energy exchange

We have several accumulators, each storing some amount of energy. We are allowed to move energy between them, but every transfer wastes a fixed percentage. If we send x units from one accumulator, the sender loses all x, while the receiver only gains x (100 - k) / 100.

codeforcescompetitive-programmingbinary-search
LeetCode 1313 - Decompress Run-Length Encoded List

This problem asks us to reconstruct an array that was compressed using a simple run-length encoding format. The input array nums always contains an even number of elements.

leetcodeeasyarray
LeetCode 1650 - Lowest Common Ancestor of a Binary Tree III

This problem asks us to find the lowest common ancestor, usually abbreviated as LCA, of two nodes in a binary tree. Unli

leetcodemediumhash-tabletwo-pointerstreebinary-tree
CF 15C - Industrial Nim

Each quarry contributes a consecutive range of heap sizes to a standard Nim game.

codeforcescompetitive-programminggames
CF 21C - Stripe 2

We are given a stripe consisting of n squares, each containing an integer. The task is to cut this stripe into three contiguous, non-empty segments such that the sum of numbers in each segment is identical. The output is the number of valid ways to perform these cuts.

codeforcescompetitive-programmingbinary-searchdpsortings
LeetCode 1238 - Circular Permutation in Binary Representation

This problem asks us to construct a special ordering of all integers from 0 to 2^n - 1. The ordering must satisfy the properties of a circular Gray code sequence.

leetcodemediummathbacktrackingbit-manipulation
LeetCode 593 - Valid Square

The problem gives four points in a 2D coordinate system and asks whether those four points form a valid square. The points are not provided in any guaranteed order, which means we cannot assume adjacent points or diagonally opposite points are already grouped correctly.

leetcodemediummathgeometry
LeetCode 1266 - Minimum Time Visiting All Points

The problem gives a sequence of points on a 2D coordinate plane. Each point is represented as [x, y], where x and y are

leetcodeeasyarraymathgeometry
CF 77A - Heroes

We have exactly seven heroes and three bosses. Each boss gives some amount of experience, and every hero assigned to that boss receives an equal share rounded down. If a boss gives x experience and its team has k heroes, then every hero in that team receives x // k.

codeforcescompetitive-programmingbrute-forceimplementation
LeetCode 349 - Intersection of Two Arrays

The problem gives us two integer arrays, nums1 and nums2, and asks us to return their intersection. The intersection consists of all values that appear in both arrays. However, the result must contain only unique elements, even if a number appears many times in either array.

leetcodeeasyarrayhash-tabletwo-pointersbinary-searchsorting
LeetCode 1501 - Countries You Can Safely Invest In

This is a SQL database problem where we need to identify countries whose average call duration is strictly greater than

leetcodemediumdatabase
LeetCode 166 - Fraction to Recurring Decimal

This problem asks us to convert a fraction, represented by an integer numerator and an integer denominator, into its decimal string representation. If the decimal expansion contains a repeating fractional sequence, we must enclose the repeating part in parentheses.

leetcodemediumhash-tablemathstring
CF 97A - Domino

We are given a grid of size n × m, representing a board where Gennady has placed 28 domino chips. Each domino occupies exactly two adjacent squares, and the squares of the same domino are marked with the same letter, while different dominoes have different letters.

codeforcescompetitive-programmingbrute-forceimplementation
CF 81E - Pairs

Each student points to exactly one other student, the person they consider their best friend. We may create a pair (a, b) only if either a chose b or b chose a. Every student can belong to at most one pair.

codeforcescompetitive-programmingdfs-and-similardpdsugraphsimplementationtrees
LeetCode 1798 - Maximum Number of Consecutive Values You Can Make

The problem gives us an array of coin values, where each coin can be used at most once. We are asked to determine the maximum number of consecutive integer values that can be formed starting from 0.

leetcodemediumarraygreedysorting
LeetCode 893 - Groups of Special-Equivalent Strings

The problem asks us to group strings based on a special equivalence property. Specifically, two strings are special-equivalent if you can swap characters at even indices among themselves and characters at odd indices among themselves any number of times to make the two strings…

leetcodemediumarrayhash-tablestringsorting
CF 31A - Worms Evolution

We are given an array of worm lengths. Each position represents a different worm form, and we need to find three distinct indices such that the length at one index equals the sum of the lengths at the other two indices.

codeforcescompetitive-programmingimplementation
LeetCode 427 - Construct Quad Tree

The problem asks us to convert a binary matrix into a Quad-Tree representation. A Quad-Tree is a recursive tree structure where every internal node has exactly four children, each representing one quadrant of the current square region.

leetcodemediumarraydivide-and-conquertreematrix
LeetCode 1610 - Maximum Number of Visible Points

In this problem, we are standing at a fixed position on a 2D plane, represented by location = [posx, posy]. Around us, there are multiple points, each with integer coordinates. We are allowed to rotate in place, but we cannot move.

leetcodehardarraymathgeometrysliding-windowsorting
CF 23C - Oranges and Apples

We have 2N - 1 boxes. Every box contains two numbers, the number of apples and the number of oranges inside it. We must choose exactly N boxes such that the chosen set contains at least half of all apples and at least half of all oranges across every box.

codeforcescompetitive-programmingconstructive-algorithmssortings
LeetCode 63 - Unique Paths II

This problem asks us to count how many different valid paths exist for a robot moving through a grid while avoiding obstacles. The robot starts in the top-left corner of the grid at position (0, 0) and wants to reach the bottom-right corner at position (m - 1, n - 1).

leetcodemediumarraydynamic-programmingmatrix
LeetCode 732 - My Calendar III

This problem asks us to design a calendar system that supports adding time intervals and reporting the highest number of overlapping events seen so far. Each booking is represented as a half open interval [startTime, endTime).

leetcodehardbinary-searchdesignsegment-treeprefix-sumordered-set
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 518 - Coin Change II

This problem asks us to compute the number of distinct combinations of coins that can sum to a target amount. We are given an array coins, where each value represents a coin denomination, and an integer amount, which represents the target sum we want to form.

leetcodemediumarraydynamic-programming