brain

tamnd's digital brain — notes, problems, research

43815 notes

LeetCode 1444 - Number of Ways of Cutting a Pizza

Edit This problem asks us to count the number of valid ways to divide a rectangular pizza into exactly k pieces such tha

leetcodehardarraydynamic-programmingmemoizationmatrixprefix-sum
CF 131C - The World is a Theatre

We have a theatre club with n boys and m girls. A performance group must contain exactly t people, with two extra restrictions: at least 4 of them must be boys, and at least 1 must be a girl. The task is to count how many different valid groups can be formed.

codeforcescompetitive-programmingcombinatoricsmath
CF 67C - Sequence of Balls

We are given two sequences of balls, labeled by lowercase letters: the original sequence A and the target sequence B. We want to transform A into B using four types of operations: inserting a ball, deleting a ball, replacing a ball, or swapping two adjacent balls.

codeforcescompetitive-programmingdp
LeetCode 148 - Sort List

The problem asks us to sort a singly linked list in ascending order and return the head of the sorted list. The input is the head node of a linked list. Each node contains an integer value and a pointer to the next node.

leetcodemediumlinked-listtwo-pointersdivide-and-conquersortingmerge-sort
LeetCode 1421 - NPV Queries

The problem presents two database tables: NPV and Queries. The NPV table contains historical net present value (NPV) dat

leetcodeeasydatabase
CF 53A - Autocomplete

We are asked to implement a simplified autocomplete function. The input consists of a string s, which represents the text the user has typed so far, followed by a list of previously visited pages.

codeforcescompetitive-programmingimplementation
LeetCode 549 - Binary Tree Longest Consecutive Sequence II

This problem asks us to find the length of the longest consecutive sequence path in a binary tree. Unlike the simpler version of the problem where the sequence must move strictly downward from parent to child, this version allows the path to move in a child-parent-child…

leetcodemediumtreedepth-first-searchbinary-tree
LeetCode 844 - Backspace String Compare

This problem asks us to determine whether two strings become identical after processing backspace operations. Each string represents characters typed into a text editor, where the '' character means "delete the previous character", similar to pressing the backspace key on a…

leetcodeeasytwo-pointersstringstacksimulation
LeetCode 180 - Consecutive Numbers

This problem asks us to find numbers in a table that appear at least three times consecutively in order of their id. The table Logs consists of two columns: id and num, where id is an auto-incrementing primary key and num is a string representing a number.

leetcodemediumdatabase
LeetCode 168 - Excel Sheet Column Title

The problem asks us to convert a positive integer into the column naming format used by Microsoft Excel. Excel labels columns alphabetically instead of numerically. The sequence begins as: The input, columnNumber, represents a 1-based column index.

leetcodeeasymathstring
LeetCode 303 - Range Sum Query - Immutable

The problem asks us to design a data structure that supports efficient range sum queries on a fixed array. We are given an integer array nums, and after initialization, the array never changes.

leetcodeeasyarraydesignprefix-sum
LeetCode 1063 - Number of Valid Subarrays

The problem is asking us to count the number of valid subarrays in a given integer array nums. A subarray is valid if its leftmost element is not larger than any other element in the subarray.

leetcodehardarraystackmonotonic-stack
LeetCode 1829 - Maximum XOR for Each Query

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

leetcodemediumarraybit-manipulationprefix-sum
LeetCode 726 - Number of Atoms

This problem asks us to parse a chemical formula represented as a string and return a canonical string that counts the number of each atom in the formula. Each atom starts with an uppercase letter and may have lowercase letters following it.

leetcodehardhash-tablestringstacksorting
LeetCode 88 - Merge Sorted Array

This problem gives us two arrays, nums1 and nums2, where both arrays are already sorted in non-decreasing order. We are also given two integers, m and n, which tell us how many valid elements exist in each array. The important detail is that nums1 has extra space at the end.

leetcodeeasyarraytwo-pointerssorting
LeetCode 523 - Continuous Subarray Sum

The problem asks us to determine whether an array contains a continuous subarray whose sum is a multiple of k, while also satisfying an important constraint: the subarray must contain at least two elements.

leetcodemediumarrayhash-tablemathprefix-sum
LeetCode 623 - Add One Row to Tree

The problem asks us to modify a binary tree by adding a new row of nodes with a given value val at a specified depth depth. The input consists of the root of a binary tree, the integer value val to insert, and the target depth depth.

leetcodemediumtreedepth-first-searchbreadth-first-searchbinary-tree
LeetCode 1219 - Path with Maximum Gold

The problem gives us a two dimensional grid representing a gold mine. Each cell contains either a positive amount of gold or 0, which means the cell is empty. We are allowed to start from any cell that contains gold and move through the grid collecting gold along the way.

leetcodemediumarraybacktrackingmatrix
LeetCode 1565 - Unique Orders and Customers Per Month

This problem requires analyzing a table of orders to calculate monthly statistics. Specifically, for each unique month present in the Orders table, we need to determine two metrics: the number of unique orders and the number of unique customers whose orders have an invoice…

leetcodeeasydatabase
CF 72B - INI-file

We are given a text file written in INI format. Every meaningful line is either a section declaration such as [network] or a key-value assignment such as port=8080. Spaces around keys, values, and section brackets are irrelevant and must be removed in the final output.

codeforcescompetitive-programming*specialimplementation
LeetCode 293 - Flip Game

This problem is asking us to simulate a single move in a simple two-player game. The input is a string currentState consisting only of '+' and '-' characters.

leetcodeeasystring
LeetCode 786 - K-th Smallest Prime Fraction

The problem asks us to find the k-th smallest fraction that can be formed by dividing one element of a sorted array arr by another element later in the array. The array arr is strictly increasing, starts with 1, and all elements after the first are prime numbers.

leetcodemediumarraytwo-pointersbinary-searchsortingheap-(priority-queue)
LeetCode 242 - Valid Anagram

The problem asks us to determine whether two strings are anagrams of each other. Two strings are considered anagrams if they contain exactly the same characters with exactly the same frequencies, but possibly in a different order.

leetcodeeasyhash-tablestringsorting
LeetCode 1321 - Restaurant Growth

This problem asks us to compute a rolling seven day summary of restaurant revenue. The input table stores individual cus

leetcodemediumdatabase
LeetCode 1434 - Number of Ways to Wear Different Hats to Each Other

This problem asks us to count how many valid ways exist to assign hats to people under two constraints: 1. Every person

leetcodehardarraydynamic-programmingbit-manipulationbitmask
LeetCode 1558 - Minimum Numbers of Function Calls to Make Target Array

This problem asks us to transform an initial array arr of zeros into a target array nums using a minimal number of operations. There are two allowed operations: incrementing any single element of the array by 1, or doubling all elements of the array.

leetcodemediumarraygreedybit-manipulation
CF 78E - Evacuation

We are given a laboratory grid of size n × n, representing a research station where some tiles are reactors and others are laboratories. One reactor is malfunctioning and will explode, causing toxic coolant to spread to neighboring labs.

codeforcescompetitive-programmingflowsgraphsshortest-paths
LeetCode 1190 - Reverse Substrings Between Each Pair of Parentheses

The problem gives us a string s containing lowercase English letters and balanced parentheses. Our task is to repeatedly reverse the substrings enclosed inside every matching pair of parentheses, starting from the innermost pair first.

leetcodemediumstringstack
LeetCode 1362 - Closest Divisors

The problem gives us an integer num, and asks us to find two integers whose product equals either num + 1 or num + 2, su

leetcodemediummath
LeetCode 319 - Bulb Switcher

The problem describes a sequence of n bulbs, all initially turned off. We perform n rounds of operations on these bulbs. In the first round, every bulb is turned on. In the second round, every second bulb is toggled, meaning on bulbs become off and off bulbs become on.

leetcodemediummathbrainteaser
LeetCode 274 - H-Index

The problem gives an array called citations, where each element represents how many citations a research paper has received. Each index corresponds to one paper, and the value at that index is the number of times that paper has been cited.

leetcodemediumarraysortingcounting-sort
LeetCode 1498 - Number of Subsequences That Satisfy the Given Sum Condition

The problem asks us to find the number of non-empty subsequences of a given array nums such that for each subsequence, t

leetcodemediumarraytwo-pointersbinary-searchsorting
LeetCode 767 - Reorganize String

The problem asks us to rearrange the characters of a given string s such that no two adjacent characters are the same. The input is a string of lowercase English letters with a length between 1 and 500.

leetcodemediumhash-tablestringgreedysortingheap-(priority-queue)counting
LeetCode 1575 - Count All Possible Routes

This problem gives us a set of cities positioned on a number line. The array locations stores the coordinate of each cit

leetcodehardarraydynamic-programmingmemoization
LeetCode 782 - Transform to Chessboard

This problem gives us an n x n binary matrix called board, where every cell contains either 0 or 1. In one operation, we are allowed to swap any two rows or swap any two columns.

leetcodehardarraymathbit-manipulationmatrix
LeetCode 1780 - Check if Number is a Sum of Powers of Three

The problem asks whether a given integer n can be expressed as the sum of distinct powers of three. A power of three is any number of the form: where x is a non-negative integer. That means the valid powers are: - 3^0 = 1 - 3^1 = 3 - 3^2 = 9 - 3^3 = 27 - and so on.

leetcodemediummath
LeetCode 787 - Cheapest Flights Within K Stops

Here’s a complete, detailed technical solution guide for LeetCode 787, following your formatting instructions exactly. The problem asks us to find the cheapest flight cost from a source city src to a destination city dst while taking at most k stops along the way.

leetcodemediumdynamic-programmingdepth-first-searchbreadth-first-searchgraph-theoryheap-(priority-queue)shortest-path
LeetCode 720 - Longest Word in Dictionary

This problem gives us an array of lowercase English words and asks us to find the longest word that can be constructed one character at a time using other words from the same dictionary. More specifically, suppose we have a candidate word like "world".

leetcodemediumarrayhash-tablestringtriesorting
CF 33E - Helper

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

codeforcescompetitive-programming
CF 28D - Don't fear, DravDe is kind

We have a fixed sequence of trucks. For every truck we know its value, the number of people inside it, and two fear constraints.

codeforcescompetitive-programmingbinary-searchdata-structuresdphashing
LeetCode 1548 - The Most Similar Path in a Graph

The problem gives us an undirected connected graph where each node represents a city, and each city has a three letter name. We are also given a target sequence of names called targetPath. Our goal is to construct a valid path through the graph such that: 1.

leetcodeharddynamic-programminggraph-theory
LeetCode 1034 - Coloring A Border

The problem gives us a two dimensional grid where each cell contains an integer representing a color. We are also given a starting position, (row, col), and a new color value. The cell at grid[row][col] belongs to some connected component.

leetcodemediumarraydepth-first-searchbreadth-first-searchmatrix
LeetCode 644 - Maximum Average Subarray II

The problem asks us to find the maximum possible average value among all contiguous subarrays whose length is at least k. We are given an integer array nums and an integer k. A subarray is a contiguous portion of the array, meaning the elements must appear consecutively.

leetcodehardarraybinary-searchprefix-sum
LeetCode 1090 - Largest Values From Labels

The problem gives us two arrays, values and labels, where each index represents a single item. The item at index i has a value values[i] and a category or group identifier labels[i].

leetcodemediumarrayhash-tablegreedysortingcounting
LeetCode 1305 - All Elements in Two Binary Search Trees

The problem gives us two binary search trees, root1 and root2. A binary search tree, commonly abbreviated as BST, has the important property that for every node: - All values in the left subtree are smaller than the node's value - All values in the right subtree are larger…

leetcodemediumtreedepth-first-searchbinary-search-treesortingbinary-tree
LeetCode 474 - Ones and Zeroes

This problem asks us to select the largest possible subset of binary strings while staying within two resource constraints. Each string consumes a certain number of 0 characters and a certain number of 1 characters.

leetcodemediumarraystringdynamic-programming
LeetCode 638 - Shopping Offers

This problem asks us to find the minimum cost to buy a set of items given individual prices and optional special offers.

leetcodemediumarraydynamic-programmingbacktrackingbit-manipulationmemoizationbitmask
LeetCode 929 - Unique Email Addresses

The problem gives us a list of email addresses and asks how many unique destinations actually receive emails after applying Gmail-like normalization rules.

leetcodeeasyarrayhash-tablestring
LeetCode 1802 - Maximum Value at a Given Index in a Bounded Array

This problem asks us to construct an array of length n where every element is a positive integer, the difference between adjacent elements is at most 1, and the total sum of the array does not exceed maxSum.

leetcodemediummathbinary-searchgreedy
LeetCode 1677 - Product's Worth Over Invoices

The problem asks us to calculate aggregate monetary information for each product based on invoices. We have two tables:

leetcodeeasydatabase
LeetCode 992 - Subarrays with K Different Integers

The problem asks us to count how many contiguous subarrays contain exactly k distinct integers. We are given: - An integer array nums - An integer k A subarray is any continuous portion of the array.

leetcodehardarrayhash-tablesliding-windowcounting
LeetCode 89 - Gray Code

The problem asks us to generate a valid Gray code sequence for a given number of bits, n. A Gray code sequence is a special ordering of numbers where every adjacent pair differs by exactly one bit in binary form.

leetcodemediummathbacktrackingbit-manipulation
LeetCode 785 - Is Graph Bipartite?

The problem asks whether a given undirected graph is bipartite. In simpler terms, we are given a graph represented as an adjacency list graph, where graph[u] lists all nodes directly connected to node u.

leetcodemediumdepth-first-searchbreadth-first-searchunion-findgraph-theory
LeetCode 1391 - Check if There is a Valid Path in a Grid

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

leetcodemediumarraydepth-first-searchbreadth-first-searchunion-findmatrix
LeetCode 907 - Sum of Subarray Minimums

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

leetcodemediumarraydynamic-programmingstackmonotonic-stack
LeetCode 452 - Minimum Number of Arrows to Burst Balloons

This problem is asking us to determine the minimum number of vertical arrows required to burst all balloons represented as intervals along the x-axis. Each balloon is defined by its start and end x-coordinates, [xstart, xend].

leetcodemediumarraygreedysorting
CF 112A - Petya and Strings

We are given two strings made of English letters. Both strings have the same length, but letters may appear in either uppercase or lowercase form. The task is to compare the two strings lexicographically while completely ignoring letter case.

codeforcescompetitive-programmingimplementationstrings
LeetCode 255 - Verify Preorder Sequence in Binary Search Tree

The problem gives an array of unique integers called preorder. This array is supposed to represent the preorder traversal of a binary search tree, and we must determine whether such a BST could actually exist. In a preorder traversal, nodes are visited in this order: 1.

leetcodemediumarraystacktreebinary-search-treerecursionmonotonic-stackbinary-tree
CF 87E - Mogohu-Rea Idol

We have three convex polygons on the plane. From each polygon we must choose one point, and the average of these three chosen points must equal the position of the idol.

codeforcescompetitive-programminggeometry
LeetCode 1777 - Product's Price for Each Store

The problem provides a table named Products, where each row represents the price of a specific product in a specific store.

leetcodeeasydatabase
LeetCode 2001 - Number of Pairs of Interchangeable Rectangles

This problem asks us to count how many pairs of rectangles are interchangeable. Each rectangle is represented by two integers, width and height. Two rectangles are considered interchangeable if their width-to-height ratios are exactly the same.

leetcodemediumarrayhash-tablemathcountingnumber-theory
LeetCode 145 - Binary Tree Postorder Traversal

The problem asks us to return the postorder traversal of a binary tree. A binary tree is made of nodes, where each node contains: - A value - A pointer to a left child - A pointer to a right child In postorder traversal, we must visit nodes in this exact order: 1.

leetcodeeasystacktreedepth-first-searchbinary-tree
CF 23A - You're Given a String...

We are given a string of lowercase letters, and the task is to find the length of the longest substring that occurs at least twice in the string. The repeated occurrences may overlap. The input is a single string of at most 100 characters.

codeforcescompetitive-programmingbrute-forcegreedy
LeetCode 1769 - Minimum Number of Operations to Move All Balls to Each Box

This problem asks us to compute the minimum number of moves required to gather all balls in a string of boxes into each individual box. Each box can either be empty ('0') or contain one ball ('1'). A single operation consists of moving a ball from one box to an adjacent box.

leetcodemediumarraystringprefix-sum
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
LeetCode 99 - Recover Binary Search Tree

The problem gives us the root of a binary search tree, but exactly two nodes in the tree have had their values swapped accidentally. Our task is to restore the tree so that it once again satisfies the binary search tree property, without modifying the tree structure itself.

leetcodemediumtreedepth-first-searchbinary-search-treebinary-tree
CF 74D - Hanger

We have a single row of hooks, numbered from 1 to n, which initially are all empty. Employees arrive and leave at specified times, and each arrival or departure is encoded by an employee ID: the first occurrence is an arrival, the second is the departure, and so on.

codeforcescompetitive-programmingdata-structures
LeetCode 1175 - Prime Arrangements

The problem asks us to count how many permutations of numbers from 1 to n satisfy a specific condition: all prime numbers must appear at prime-numbered indices (1-indexed).

leetcodeeasymath
CF 39I - Tram

We are given a directed graph where nodes represent crossroads and edges represent one-way tramlines. The engine house is at node 1. Every node has at least one outgoing edge, so the tram is never trapped.

codeforcescompetitive-programming
LeetCode 240 - Search a 2D Matrix II

The problem asks us to determine whether a given integer target exists inside an m x n matrix. Unlike a completely unsorted matrix, this matrix has two important ordering guarantees: 1. Each row is sorted in ascending order from left to right. 2.

leetcodemediumarraybinary-searchdivide-and-conquermatrix
LeetCode 475 - Heaters

The problem gives two arrays, houses and heaters, where each value represents a position on a one dimensional horizontal line.

leetcodemediumarraytwo-pointersbinary-searchsorting
LeetCode 819 - Most Common Word

The problem asks us to process a paragraph of text and determine which word appears most frequently, while ignoring a given list of banned words. The final answer must be returned in lowercase.

leetcodeeasyarrayhash-tablestringcounting
LeetCode 607 - Sales Person

This problem asks us to find the names of all salespeople who have never handled an order for the company named "RED". We are given three database tables: - SalesPerson contains information about each salesperson, including their unique salesid and name.

leetcodeeasydatabase
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 51F - Caterpillar

We start with an undirected graph that may be disconnected and may contain cycles. We are allowed to repeatedly merge two vertices into one. Merging decreases the number of vertices by one, while the number of edges stays unchanged.

codeforcescompetitive-programmingdfs-and-similardpgraphstrees
LeetCode 376 - Wiggle Subsequence

The problem asks us to find the length of the longest subsequence in an array such that the differences between consecutive elements alternate between positive and negative.

leetcodemediumarraydynamic-programminggreedy
LeetCode 1818 - Minimum Absolute Sum Difference

The problem gives two arrays of positive integers, nums1 and nums2, both of equal length n. The goal is to calculate the absolute sum difference between these arrays, which is the sum of the absolute differences at each index: |nums1[i] - nums2[i]|.

leetcodemediumarraybinary-searchsortingordered-set
CF 6A - Triangle

We are given four stick lengths, and we must choose exactly three of them. Depending on the relationship between those three lengths, there are three possible outcomes.

codeforcescompetitive-programmingbrute-forcegeometry
LeetCode 244 - Shortest Word Distance II

This problem asks us to design a reusable data structure that can efficiently answer repeated shortest-distance queries between words in a fixed list of strings. We are given an array of words, wordsDict, during initialization.

leetcodemediumarrayhash-tabletwo-pointersstringdesign
LeetCode 1775 - Equal Sum Arrays With Minimum Number of Operations

The problem gives us two integer arrays, nums1 and nums2, where every element is between 1 and 6. In one operation, we may choose any element from either array and change it to any value from 1 to 6.

leetcodemediumarrayhash-tablegreedycounting
LeetCode 1608 - Special Array With X Elements Greater Than or Equal X

The problem gives us an array nums containing non-negative integers. We need to determine whether there exists an intege

leetcodeeasyarraybinary-searchsorting
LeetCode 87 - Scramble String

This problem asks us to determine whether one string can be transformed into another using a specific recursive scrambling process. We are given two strings, s1 and s2, and they are guaranteed to have the same length. The scrambling process works recursively.

leetcodehardstringdynamic-programming
LeetCode 1192 - Critical Connections in a Network

This problem gives us an undirected graph representing a network of servers. Each server is identified by an integer from 0 to n - 1, and each pair [a, b] in connections represents a bidirectional edge between server a and server b.

leetcodeharddepth-first-searchgraph-theorybiconnected-component
CF 1941E - Rudolf and k Bridges

Each row of the river can be treated independently. Along a chosen row, we want to place supports in some columns so that the first and last columns always contain supports, and the number of cells skipped between two neighboring supports is at most d.

codeforcescompetitive-programmingbinary-searchdata-structuresdptwo-pointers
LeetCode 53 - Maximum Subarray

The problem gives an integer array nums and asks us to find a contiguous subarray that has the largest possible sum. A subarray means the elements must appear next to each other in the original array. We are not allowed to rearrange elements or skip positions arbitrarily.

leetcodemediumarraydivide-and-conquerdynamic-programming
LeetCode 183 - Customers Who Never Order

This problem is asking us to identify all customers from a Customers table who have never placed an order according to the Orders table. In other words, we are looking for entries in Customers that do not have a corresponding customerId in the Orders table.

leetcodeeasydatabase
LeetCode 70 - Climbing Stairs

The problem describes a staircase with n total steps. You start at the bottom and want to reach the top. At every move, you are allowed to climb either 1 step or 2 steps. The goal is to determine how many distinct sequences of moves can take you from the bottom to the top.

leetcodeeasymathdynamic-programmingmemoization
LeetCode 1667 - Fix Names in a Table

This problem provides a database table named Users with two columns: userid and name. The userid column uniquely identifies each user, while the name column stores a person's name using a mixture of uppercase and lowercase English letters.

leetcodeeasydatabase
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 1333 - Filter Restaurants by Vegan-Friendly, Price and Distance

The problem is asking us to filter and sort a list of restaurants based on multiple criteria. Each restaurant is represe

leetcodemediumarraysorting
LeetCode 264 - Ugly Number II

The problem asks us to generate the sequence of ugly numbers and return the nth value in that sequence. An ugly number is defined as a positive integer whose only prime factors are 2, 3, and 5.

leetcodemediumhash-tablemathdynamic-programmingheap-(priority-queue)
LeetCode 763 - Partition Labels

The problem is asking us to partition a string s into as many contiguous parts as possible such that no letter appears in more than one part. In other words, each character in the string should be confined to a single segment.

leetcodemediumhash-tabletwo-pointersstringgreedy
LeetCode 478 - Generate Random Point in a Circle

This problem asks us to generate random points uniformly inside a circle. The circle is defined by its radius and the coordinates of its center. Every call to randPoint() must return a point [x, y] such that the point lies either inside the circle or exactly on its boundary.

leetcodemediummathgeometryrejection-samplingrandomized
LeetCode 1410 - HTML Entity Parser

Here is a complete, detailed technical guide for LeetCode 1410 following your formatting and style requirements. The pro

leetcodemediumhash-tablestring
LeetCode 1611 - Minimum One Bit Operations to Make Integers Zero

This problem asks us to transform a given integer n into 0 using a specialized set of bit-flipping operations. Each oper

leetcodehardmathdynamic-programmingbit-manipulationrecursionmemoization
CF 75A - Life Without Zeros

We are given two positive integers, a and b. First we compute their normal sum c = a + b. Then we apply the same transformation to all three numbers: remove every digit 0 from their decimal representation. The question is whether the transformed equation still holds.

codeforcescompetitive-programmingimplementation
LeetCode 1035 - Uncrossed Lines

The problem gives us two integer arrays, nums1 and nums2. We are allowed to draw lines between matching values in the two arrays, but with an important restriction: the lines cannot cross each other. A line can only connect nums1[i] with nums2[j] when the values are equal.

leetcodemediumarraydynamic-programming
LeetCode 417 - Pacific Atlantic Water Flow

The problem gives us a rectangular grid called heights, where each cell represents the elevation of a piece of land. Water can flow from one cell to another if the neighboring cell has a height less than or equal to the current cell.

leetcodemediumarraydepth-first-searchbreadth-first-searchmatrix
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
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