brain

tamnd's digital brain — notes, problems, research

43815 notes

LeetCode 942 - DI String Match

In this problem, we are given a string s consisting only of the characters 'I' and 'D'. The string has length n, and we must construct a permutation of the integers from 0 to n, inclusive. A permutation means every number in the range appears exactly once.

leetcodeeasyarraytwo-pointersstringgreedy
LeetCode 498 - Diagonal Traverse

This problem asks us to traverse a matrix in a specific diagonal pattern and return all elements in the order they are visited. We are given an m x n matrix mat, where m represents the number of rows and n represents the number of columns.

leetcodemediumarraymatrixsimulation
CF 39J - Spelling Check

We are given two lowercase strings. The first string is exactly one character longer than the second. We want to find every position in the first string such that removing the character at that position makes the two strings identical.

codeforcescompetitive-programminghashingimplementationstrings
LeetCode 1264 - Page Recommendations

This problem models a small social network with two database tables. The Friendship table stores friendship relationship

leetcodemediumdatabase
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 2231 - Largest Number After Digit Swaps by Parity

The problem gives us a positive integer num and allows us to swap digits only if the two digits have the same parity. In

leetcodeeasysortingheap-(priority-queue)
LeetCode 560 - Subarray Sum Equals K

The problem asks us to count how many contiguous, non-empty subarrays in an integer array nums have a sum equal to a target value k. A subarray is different from a subsequence.

leetcodemediumarrayhash-tableprefix-sum
CF 84C - Biathlon

We are given a set of circular targets, all lying on the Ox axis, each defined by its center coordinate and radius. Valera shoots multiple times, and each shot has an (x, y) coordinate.

codeforcescompetitive-programmingbinary-searchimplementation
LeetCode 1413 - Minimum Value to Get Positive Step by Step Sum

The problem gives us an integer array nums and asks us to determine the minimum positive starting value such that when w

leetcodeeasyarrayprefix-sum
CF 73A - The Elder Trolls IV: Oblivon

We have a rectangular block made of unit cubes with dimensions x × y × z. A single cut is always made along the grid lines and must be parallel to one of the faces of the box.

codeforcescompetitive-programminggreedymath
LeetCode 911 - Online Election

The problem is asking us to design a data structure that can efficiently answer queries about the leader of an election at any given time. We are given two integer arrays, persons and times.

leetcodemediumarrayhash-tablebinary-searchdesign
CF 50D - Bombing

We are given a set of enemy objects, each at a fixed 2D coordinate, and a fixed strike point. The objective is to determine the minimum impact radius of a nuclear warhead such that the probability of failing to deactivate at least K of these objects is at most ε per mils.

codeforcescompetitive-programmingbinary-searchdpprobabilities
LeetCode 141 - Linked List Cycle

This problem asks us to determine whether a singly linked list contains a cycle. A cycle exists when following the next pointers eventually leads back to a node that has already been visited, instead of reaching None. The input is the head node of a singly linked list.

leetcodeeasyhash-tablelinked-listtwo-pointers
LeetCode 1432 - Max Difference You Can Get From Changing an Integer

The problem gives us an integer num, and we are allowed to perform a digit replacement operation twice, independently. I

leetcodemediummathgreedy
LeetCode 1657 - Determine if Two Strings Are Close

The problem asks whether two strings, word1 and word2, are "close" according to two allowed operations. Operation 1 allows swapping any two existing characters in the string, which means the relative order of characters is flexible.

leetcodemediumhash-tablestringsortingcounting
CF 35C - Fire Again

We have a rectangular grid of trees. A fire starts simultaneously from several cells, and every minute it spreads to neighboring cells that share a side. The task is to find any cell whose burning time is as large as possible, meaning it catches fire later than every other tree.

codeforcescompetitive-programmingbrute-forcedfs-and-similarshortest-paths
CF 5D - Follow Traffic Rules

We are asked to compute the minimum travel time for a car moving along a straight road from Berland to Bercouver. The road has length _l_, and at a distance _d_ from the start there is a speed sign that limits the car's instantaneous speed to _w_.

codeforcescompetitive-programmingimplementationmath
LeetCode 1830 - Minimum Number of Operations to Make String Sorted

The operation described in the problem is exactly the process of generating the previous lexicographical permutation of a string. Starting from the current string, each operation transforms it into the lexicographically largest string that is still smaller than the current one.

leetcodehardhash-tablemathstringcombinatoricscounting
CF 64C - Table

We are given an $n times m$ table filled with consecutive integers starting from 1. The filling is done row by row, left to right.

codeforcescompetitive-programming*specialgreedyimplementationmath
LeetCode 973 - K Closest Points to Origin

This problem asks us to find the k points that are closest to the origin (0,0) from a list of 2D points. Each point is given as a pair [x, y], and the distance is defined using the Euclidean formula, sqrt(x^2 + y^2).

leetcodemediumarraymathdivide-and-conquergeometrysortingheap-(priority-queue)quickselect
LeetCode 1690 - Stone Game VII

This problem describes a two player game played on an array of stones. Each stone has a positive integer value, and the

leetcodemediumarraymathdynamic-programminggame-theory
CF 104A - Blackjack

We are given a simplified blackjack scenario where the first card is fixed: the queen of spades, which contributes 10 points. The player wants the sum of this card and a second card to equal a given number n, which ranges from 1 to 25.

codeforcescompetitive-programmingimplementation
LeetCode 372 - Super Pow

The problem asks us to compute: The complication is that the exponent b is extremely large. Instead of being given as a normal integer, it is provided as an array of digits.

leetcodemediummathdivide-and-conquer
CF 83A - Magical Array

We are given an integer array and need to count how many contiguous subarrays are "magical". A subarray is magical when its minimum value is equal to its maximum value. A minimum and maximum can only be equal if every element inside the subarray is the same.

codeforcescompetitive-programmingmath
LeetCode 1762 - Buildings With an Ocean View

This problem gives us an array called heights, where each element represents the height of a building. The buildings are arranged in a straight line from left to right, and the ocean is located to the right side of the last building.

leetcodemediumarraystackmonotonic-stack
LeetCode 279 - Perfect Squares

The problem asks for the minimum number of perfect square numbers whose sum equals a given integer n. A perfect square is a number that can be written as x x for some integer x. Examples include 1, 4, 9, 16, and 25.

leetcodemediummathdynamic-programmingbreadth-first-search
CF 106D - Treasure Island

We are given a grid representing an island with impassable sea cells and traversable land cells. Some of the land cells contain unique local sights labeled with uppercase letters.

codeforcescompetitive-programmingbrute-forceimplementation
LeetCode 673 - Number of Longest Increasing Subsequence

The problem asks us to determine how many longest strictly increasing subsequences exist in a given integer array. A subsequence is formed by deleting zero or more elements without changing the relative order of the remaining elements.

leetcodemediumarraydynamic-programmingbinary-indexed-treesegment-tree
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 1473 - Paint House III

This problem asks us to paint a row of houses while satisfying two constraints simultaneously: 1. Every house must end u

leetcodehardarraydynamic-programming
LeetCode 1278 - Palindrome Partitioning III

The problem gives us a string s and an integer k. We are allowed to modify characters in the string, and our goal is to

leetcodehardstringdynamic-programming
LeetCode 158 - Read N Characters Given read4 II - Call Multiple Times

This problem asks us to implement a read(buf, n) function using a restricted API called read4(buf4). The challenge is that we are not allowed to access the file directly, instead, we can only retrieve data in chunks of up to four characters at a time.

leetcodehardarraysimulationinteractive
LeetCode 915 - Partition Array into Disjoint Intervals

The problem asks us to split an array into two contiguous parts, left and right, such that every value in left is less than or equal to every value in right. Among all valid partitions, we must return the smallest possible size of left.

leetcodemediumarray
CF 35D - Animals

We are asked to simulate a farm in which animals arrive one per day over n days. Each animal has a fixed daily food requirement starting from the day it arrives. The farm starts with X tons of food.

codeforcescompetitive-programmingdpgreedy
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 65E - Harry Potter and Moving Staircases

We are given an undirected multigraph. Floors are vertices, staircases are edges. Harry starts at floor 1 and wants to visit every floor at least once. The graph is dynamic. Between Harry's walks, Ron and Hermione may modify staircases.

codeforcescompetitive-programmingdfs-and-similarimplementation
LeetCode 325 - Maximum Size Subarray Sum Equals k

The problem asks us to find the longest contiguous subarray whose sum is exactly equal to a given integer k. A subarray is a continuous portion of the array. This means we cannot reorder elements or skip positions.

leetcodemediumarrayhash-tableprefix-sum
LeetCode 1463 - Cherry Pickup II

Here is a complete, detailed technical solution guide for LeetCode 1463 - Cherry Pickup II following your formatting req

leetcodehardarraydynamic-programmingmatrix
LeetCode 1133 - Largest Unique Number

The problem is asking us to identify the largest integer in an array that occurs exactly once. In other words, among all integers that are unique (appear only one time), we need to find the maximum. If no such integer exists, the output should be -1.

leetcodeeasyarrayhash-tablesorting
LeetCode 990 - Satisfiability of Equality Equations

The problem is asking us to determine if a set of equations between single-letter variables can all be satisfied simultaneously. Each equation is either of the form "xi==yi" or "xi!=yi", where xi and yi are lowercase letters from 'a' to 'z'.

leetcodemediumarraystringunion-findgraph-theory
LeetCode 1487 - Making File Names Unique

The problem asks us to simulate how a file system assigns folder names when duplicate names appear. We are given an array names, where names[i] represents the folder name requested at the i-th minute. The file system must ensure that every created folder has a unique name.

leetcodemediumarrayhash-tablestring
LeetCode 1011 - Capacity To Ship Packages Within D Days

This problem asks us to determine the minimum ship capacity required to transport all packages within a fixed number of days. We are given an array called weights, where weights[i] represents the weight of the i-th package on a conveyor belt.

leetcodemediumarraybinary-search
LeetCode 1131 - Maximum of Absolute Value Expression

The problem gives us two integer arrays, arr1 and arr2, both having the same length. We must compute the maximum possible value of the following expression across every pair of indices (i, j): The task is not asking for the indices themselves, only the largest achievable value.

leetcodemediumarraymath
LeetCode 288 - Unique Word Abbreviation

The problem asks us to design a data structure that determines whether a word's abbreviation is unique within a given dictionary.

leetcodemediumarrayhash-tablestringdesign
LeetCode 1697 - Checking Existence of Edge Length Limited Paths

This problem gives us an undirected weighted graph with n nodes. Each edge connects two nodes and has a distance value associated with it.

leetcodehardarraytwo-pointersunion-findgraph-theorysorting
LeetCode 1748 - Sum of Unique Elements

The problem gives us an integer array nums and asks us to compute the sum of all elements that appear exactly once in the array. An element is considered unique only if its frequency is exactly one.

leetcodeeasyarrayhash-tablecounting
CF 56E - Domino Principle

We have dominoes placed on a number line. Each domino stands at coordinate x[i] and has height h[i]. If a domino falls to the right, it reaches every point from x[i] + 1 up to x[i] + h[i] - 1.

codeforcescompetitive-programmingbinary-searchdata-structuressortings
CF 98D - Help Monks

We are given a Tower of Hanoi variant with three pillars and n disks stacked on the first pillar. The disks are listed from bottom to top, and unlike the classical problem, several disks may have the same diameter. A move still transfers exactly one disk between pillars.

codeforcescompetitive-programmingconstructive-algorithms
CF 46A - Ball Game

The children stand in a circle numbered from 1 to n. Child 1 starts with the ball. The first throw moves the ball forward by 1 position, the second throw moves it forward by 2 positions, the third throw by 3 positions, and so on.

codeforcescompetitive-programmingbrute-forceimplementation
LeetCode 741 - Cherry Pickup

This problem asks us to collect the maximum possible number of cherries while making two trips across a square grid. The first trip starts at the top left corner (0, 0) and moves to the bottom right corner (n - 1, n - 1) using only right or down moves.

leetcodehardarraydynamic-programmingmatrix
CF 5A - Chat Servers Outgoing Traffic

We are given a sequence of chat server events. A user can join the chat, leave the chat, or send a message. Every time someone sends a message, the server delivers that message to every user currently inside the chat, including the sender.

codeforcescompetitive-programmingimplementation
LeetCode 1512 - Number of Good Pairs

The problem gives us an integer array nums and asks us to count how many pairs of indices (i, j) satisfy two conditions: 1. nums[i] == nums[j] 2. i < j Such pairs are called "good pairs".

leetcodeeasyarrayhash-tablemathcounting
LeetCode 888 - Fair Candy Swap

The problem gives us two arrays, aliceSizes and bobSizes, representing the candy boxes owned by Alice and Bob. Each element in the arrays is the number of candies in a particular box.

leetcodeeasyarrayhash-tablebinary-searchsorting
LeetCode 599 - Minimum Index Sum of Two Lists

This problem is asking us to find the common elements between two lists of strings, but not just any common elements. We want the ones where the sum of their indices in both lists is the smallest.

leetcodeeasyarrayhash-tablestring
LeetCode 115 - Distinct Subsequences

This problem asks us to count how many distinct subsequences of a string s are equal to another string t. A subsequence is formed by deleting zero or more characters from a string without changing the relative order of the remaining characters.

leetcodehardstringdynamic-programming
CF 39F - Pacifist frogs

Thumbelina wants to cross a swamp by riding a single frog. The swamp contains hills numbered from 1 to n, where hill i is exactly i meters away from the island. A frog with jump length d lands on hills d, 2d, 3d, ...

codeforcescompetitive-programmingimplementation
LeetCode 33 - Search in Rotated Sorted Array

The problem gives us an array that was originally sorted in ascending order, but may have been rotated at some pivot point. A rotation means that some prefix of the sorted array was moved to the end while preserving the relative order of elements.

leetcodemediumarraybinary-search
LeetCode 875 - Koko Eating Bananas

The problem asks us to determine the minimum eating speed k for Koko such that she can finish all piles of bananas within a given number of hours h.

leetcodemediumarraybinary-search
LeetCode 1724 - Checking Existence of Edge Length Limited Paths II

This problem gives us an undirected weighted graph with n nodes and a list of edges. Each edge connects two nodes and has an associated distance value. The graph may contain multiple edges between the same pair of nodes, and it may also be disconnected.

leetcodeharddepth-first-searchunion-findgraph-theorydesignsortingheap-(priority-queue)minimum-spanning-tree
CF 79E - Security System

We are asked to help Ciel move from the bottom-left corner of a castle grid, coordinate (1,1), to the top-right corner (n,n), while avoiding being caught by a system of sensors. The castle grid allows only two types of moves: right (R) or upward (U).

codeforcescompetitive-programmingmath
LeetCode 74 - Search a 2D Matrix

This problem gives us a two dimensional matrix with two very important ordering properties: 1. Each row is sorted from left to right in non-decreasing order. 2. The first element of every row is greater than the last element of the previous row.

leetcodemediumarraybinary-searchmatrix
CF 25C - Roads in Berland

We are given a map of _n_ cities in Berland, where the shortest distances between all pairs are already known. Conceptually, this means the country is fully connected via some unknown set of roads, and the distance matrix is already the all-pairs shortest path result.

codeforcescompetitive-programminggraphsshortest-paths
LeetCode 507 - Perfect Number

This problem asks us to determine whether a given positive integer num is a perfect number. A perfect number is defined as a number whose sum of positive divisors, excluding the number itself, equals the number.

leetcodeeasymath
LeetCode 524 - Longest Word in Dictionary through Deleting

The problem gives us a source string s and a list of candidate words called dictionary. We must determine which dictionary word can be formed by deleting characters from s without changing the relative order of the remaining characters.

leetcodemediumarraytwo-pointersstringsorting
CF 76B - Mice

We are given a row of mice located along a horizontal line at coordinate y = Y0 and a row of cheese pieces along another horizontal line at y = Y1. Each mouse can run directly towards any piece of cheese, and all mice run at the same speed.

codeforcescompetitive-programminggreedytwo-pointers
LeetCode 1563 - Stone Game V

In this game, we are given an array stoneValue where each element represents the value of a stone. The stones are arranged in a row, and Alice repeatedly splits the current row into two non-empty contiguous parts.

leetcodehardarraymathdynamic-programminggame-theory
LeetCode 1763 - Longest Nice Substring

The problem asks us to find the longest "nice" substring within a given string s. A substring is considered nice if for every letter it contains, both its lowercase and uppercase forms appear. For example, "aAa" is nice because it contains 'a' and 'A'.

leetcodeeasyhash-tablestringdivide-and-conquerbit-manipulationsliding-window
LeetCode 551 - Student Attendance Record I

The problem gives us a string s where each character represents a student's attendance record for one day. There are only three possible characters: - 'A' means the student was absent. - 'L' means the student was late. - 'P' means the student was present.

leetcodeeasystring
LeetCode 722 - Remove Comments

The problem asks us to remove comments from a C++ program represented as an array of strings. Each string represents a line of the program, split by newline characters.

leetcodemediumarraystring
LeetCode 1279 - Traffic Light Controlled Intersection

This problem asks us to design a thread-safe traffic light system for a road intersection where cars arrive concurrently

leetcodeeasyconcurrency
LeetCode 1155 - Number of Dice Rolls With Target Sum

The problem gives us n identical dice, where each die has faces numbered from 1 to k. We roll all n dice and want to count how many different sequences of rolls produce a total sum equal to target. The important detail is that order matters.

leetcodemediumdynamic-programming
LeetCode 473 - Matchsticks to Square

The problem gives us an array called matchsticks, where each element represents the length of a matchstick. The goal is to determine whether all of the matchsticks can be arranged to form exactly one square.

leetcodemediumarraydynamic-programmingbacktrackingbit-manipulationbitmask
LeetCode 594 - Longest Harmonious Subsequence

The problem asks us to find the length of the longest harmonious subsequence in an integer array. A harmonious array is defined as one where the difference between the maximum and minimum values is exactly 1.

leetcodeeasyarrayhash-tablesliding-windowsortingcounting
LeetCode 1647 - Minimum Deletions to Make Character Frequencies Unique

The problem asks us to make a string good, which means no two distinct characters in the string have the same frequency.

leetcodemediumhash-tablestringgreedysorting
LeetCode 444 - Sequence Reconstruction

This problem asks us to determine whether the given array nums is both: 1. A valid shortest supersequence of all arrays in sequences 2. The only possible shortest supersequence A supersequence is a sequence that contains every sequence in sequences as a subsequence.

leetcodemediumarraygraph-theorytopological-sort
LeetCode 1713 - Minimum Operations to Make a Subsequence

The problem gives us two arrays, target and arr. The target array contains distinct integers, which is extremely important. The arr array may contain duplicates. We are allowed to perform insert operations on arr.

leetcodehardarrayhash-tablebinary-searchgreedy
LeetCode 1311 - Get Watched Videos by Your Friends

This problem models a social network as an undirected graph. Each person is represented by an integer ID from 0 to n - 1

leetcodemediumarrayhash-tablebreadth-first-searchgraph-theorysorting
CF 7D - Palindrome Degree

We are given a string consisting of letters and digits, and we are asked to compute a special measure for every prefix called the _palindrome degree_.

codeforcescompetitive-programminghashingstrings
CF 68C - Synchrophasotron

We have a directed acyclic graph on vertices 1...n. For every pair i < j, there is exactly one directed edge from i to j. Each pipe has three parameters. It must carry between l and h units of flow inclusive, even if we do not want to use that pipe.

codeforcescompetitive-programmingbrute-force
LeetCode 921 - Minimum Add to Make Parentheses Valid

The problem asks us to determine the minimum number of parentheses insertions required to make a given string of parentheses valid.

leetcodemediumstringstackgreedy
LeetCode 152 - Maximum Product Subarray

The problem asks us to find the contiguous subarray within an integer array nums that produces the largest possible product. Unlike the classic maximum subarray sum problem, multiplication introduces additional complexity because negative numbers can completely change the result.

leetcodemediumarraydynamic-programming
LeetCode 1042 - Flower Planting With No Adjacent

The problem presents n gardens, labeled from 1 to n, and a list of bidirectional paths connecting pairs of gardens. Each garden must be planted with one of four types of flowers (1 through 4).

leetcodemediumdepth-first-searchbreadth-first-searchgraph-theory
LeetCode 69 - Sqrt(x)

The problem asks us to compute the integer square root of a non negative integer x. More specifically, we need to return the largest integer k such that: This means we are not looking for the exact decimal square root. Instead, we must round down to the nearest integer.

leetcodeeasymathbinary-search
LeetCode 600 - Non-negative Integers without Consecutive Ones

That is a long-form technical guide request with multiple required sections and complete code. Before I write it, I want to confirm one formatting detail because your template is very specific: Do you want the solution to focus on the standard Digit DP + Fibonacci-style DP on…

leetcodeharddynamic-programming
LeetCode 1450 - Number of Students Doing Homework at a Given Time

This problem asks us to determine how many students are doing homework at a specific point in time, given arrays represe

leetcodeeasyarray
LeetCode 1843 - Suspicious Bank Accounts

This problem asks us to identify bank accounts whose monthly income exceeds a predefined limit for at least two consecutive months. We are given two tables: The Accounts table stores the maximum allowed monthly income for each account.

leetcodemediumdatabase
LeetCode 1694 - Reformat Phone Number

The problem requires reformatting a phone number string in a specific structured way. The input is a string number conta

leetcodeeasystring
LeetCode 952 - Largest Component Size by Common Factor

The problem asks us to find the largest connected component in a graph derived from an array of unique positive integers nums.

leetcodehardarrayhash-tablemathunion-findnumber-theory
LeetCode 1039 - Minimum Score Triangulation of Polygon

This problem asks us to triangulate a convex polygon in such a way that the total triangulation score is minimized. We are given an array values, where each element represents the value assigned to a vertex of the polygon.

leetcodemediumarraydynamic-programming
LeetCode 310 - Minimum Height Trees

This problem gives us an undirected tree with n nodes labeled from 0 to n - 1. The input edges describes the connections between nodes, and because the graph is guaranteed to be a tree, several important properties immediately hold true.

leetcodemediumdepth-first-searchbreadth-first-searchgraph-theorytopological-sort
LeetCode 1157 - Online Majority Element In Subarray

The problem asks us to design a data structure that can efficiently answer majority element queries on subarrays of a given array.

leetcodehardarraybinary-searchdesignbinary-indexed-treesegment-tree
LeetCode 25 - Reverse Nodes in k-Group

This problem asks us to reverse a singly linked list in groups of size k. Instead of reversing the entire list at once, we only reverse consecutive chunks containing exactly k nodes.

leetcodehardlinked-listrecursion
CF 77B - Falling Anvils

We are given two real parameters chosen uniformly at random. The victim height p lies in the interval [0, a], and the wind parameter q lies in [-b, b]. For every pair (p, q), the anvil hits successfully if a certain quadratic equation has at least one real root.

codeforcescompetitive-programmingmathprobabilities
LeetCode 1658 - Minimum Operations to Reduce X to Zero

The problem gives us an integer array nums and a target integer x. In one operation, we are allowed to remove either the leftmost element or the rightmost element from the array. Whenever we remove a value, we subtract it from x.

leetcodemediumarrayhash-tablebinary-searchsliding-windowprefix-sum
LeetCode 890 - Find and Replace Pattern

The problem gives us a list of words and a target pattern string. We need to determine which words follow the exact same structural character relationship as the pattern.

leetcodemediumarrayhash-tablestring
LeetCode 442 - Find All Duplicates in an Array

The problem gives us an integer array nums of length n, where every value is guaranteed to be in the range [1, n]. Each number appears either once or twice. Our task is to return all numbers that appear exactly twice.

leetcodemediumarrayhash-tablesorting
LeetCode 414 - Third Maximum Number

The problem asks us to find the third distinct maximum number in an integer array. The key word is distinct. Duplicate values should only be counted once when determining rankings. For example, in the array [2,2,3,1], the distinct values are {3,2,1}.

leetcodeeasyarraysorting
CF 39K - Testing

We are given an rectangular grid representing a field, and within this field there are non-overlapping rectangles representing objects. Each rectangle occupies contiguous cells marked by '*', and all other cells are '.'.

codeforcescompetitive-programming
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 377 - Combination Sum IV

The problem gives us an array of distinct positive integers called nums and a target integer called target. We must determine how many different ordered sequences of numbers from nums sum exactly to target. The key detail is that order matters.

leetcodemediumarraydynamic-programming