brain

tamnd's digital brain — notes, problems, research

43815 notes

LeetCode 701 - Insert into a Binary Search Tree

This problem asks us to insert a new value into an existing Binary Search Tree, abbreviated as BST, while preserving the BST property.

leetcodemediumtreebinary-search-treebinary-tree
LeetCode 830 - Positions of Large Groups

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

leetcodeeasystring
CF 106B - Choosing Laptop

Each laptop has four values: processor speed, RAM size, HDD size, and price. A laptop is considered outdated if there exists another laptop that is strictly better in all three technical characteristics at the same time.

codeforcescompetitive-programmingbrute-forceimplementation
LeetCode 1708 - Largest Subarray Length K

The problem asks us to find the lexicographically largest contiguous subarray of length k from a given array of distinct integers. Two arrays are compared lexicographically.

leetcodeeasyarraygreedy
LeetCode 1624 - Largest Substring Between Two Equal Characters

The problem asks us to find the length of the longest substring that lies between two identical characters in a given string s. The substring does not include the two identical characters themselves. If no character occurs at least twice, we must return -1.

leetcodeeasyhash-tablestring
LeetCode 1187 - Make Array Strictly Increasing

The problem is asking us to transform the array arr1 into a strictly increasing array using the minimum number of operations. Each operation allows replacing an element of arr1 with an element from arr2.

leetcodehardarraybinary-searchdynamic-programmingsorting
LeetCode 1191 - K-Concatenation Maximum Sum

This problem asks us to find the maximum possible sum of a contiguous subarray when we are allowed to delete at most one element from that chosen subarray. The important detail is that the resulting subarray must still contain at least one element after deletion.

leetcodemediumarraydynamic-programming
LeetCode 624 - Maximum Distance in Arrays

The problem presents a list of m arrays, each individually sorted in ascending order. You are asked to pick one element from two different arrays and compute the absolute difference between these two elements, which is defined as the distance.

leetcodemediumarraygreedy
LeetCode 1786 - Number of Restricted Paths From First to Last Node

This problem gives us an undirected weighted graph with n nodes labeled from 1 to n. Every edge connects two nodes and has a positive weight. The graph is guaranteed to be connected, meaning there is always at least one path between any pair of nodes.

leetcodemediumdynamic-programminggraph-theorytopological-sortheap-(priority-queue)shortest-path
LeetCode 356 - Line Reflection

The problem gives us a collection of points on a 2D plane, where each point is represented as [x, y]. We need to determine whether there exists a vertical line, meaning a line parallel to the y-axis, such that reflecting every point across that line produces the exact same set…

leetcodemediumarrayhash-tablemath
LeetCode 157 - Read N Characters Given Read4

This problem asks us to implement a read function using a restricted API called read4. The file itself is hidden from us, and the only way to access its contents is by repeatedly calling read4.

leetcodeeasyarraysimulationinteractive
LeetCode 538 - Convert BST to Greater Tree

This problem asks us to transform a Binary Search Tree, abbreviated as BST, into a "Greater Tree". In the transformed tree, every node's value should become: - its original value - plus the sum of all values greater than it in the original BST The structure of the tree does…

leetcodemediumtreedepth-first-searchbinary-search-treebinary-tree
LeetCode 1086 - High Five

The problem asks us to compute the top five average score for each student given a list of [ID, score] pairs. Each ID represents a unique student, and score represents a single score they received.

leetcodeeasyarrayhash-tablesortingheap-(priority-queue)
LeetCode 1103 - Distribute Candies to People

The problem describes a sequential candy distribution process across a row of people. We are given two integers, candies and numpeople. The goal is to simulate distributing candies in increasing order until all candies are exhausted.

leetcodeeasymathsimulation
LeetCode 1411 - Number of Ways to Paint N × 3 Grid

The problem asks us to determine the number of ways to paint a grid of size n × 3 using exactly three colors-Red, Yellow

leetcodeharddynamic-programming
CF 48C - The Race

We are asked to predict the next petrol station where Vanya will stop, given the stations he has already visited.

codeforcescompetitive-programmingmath
CF 87D - Beautiful Road

We are given a weighted tree with n cities and n - 1 roads. Every ordered pair of distinct cities represents one military campaign, so there are n (n - 1) total trips. For a trip from city u to city v, the army travels along the unique path between them.

codeforcescompetitive-programmingdfs-and-similardpdsugraphsimplementationsortingstrees
LeetCode 1617 - Count Subtrees With Max Distance Between Cities

The input describes an undirected tree with n cities. Since the graph is a tree, there are exactly n - 1 edges and there is a unique simple path between every pair of cities. The problem asks us to examine every possible connected subset of cities.

leetcodeharddynamic-programmingbit-manipulationtreeenumerationbitmask
LeetCode 667 - Beautiful Arrangement II

The problem asks us to construct a permutation of the integers from 1 to n such that the sequence of absolute differences between adjacent elements contains exactly k distinct values.

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

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

leetcodeharddatabase
LeetCode 1158 - Market Analysis I

This problem asks us to analyze purchasing activity on an online shopping platform. We are given three database tables: Users, Orders, and Items.

leetcodemediumdatabase
LeetCode 870 - Advantage Shuffle

The problem asks us to maximize the advantage of one array over another. Given two arrays nums1 and nums2 of equal length, the advantage is defined as the number of positions i where nums1[i] nums2[i]. Our task is to rearrange nums1 to maximize this advantage.

leetcodemediumarraytwo-pointersgreedysorting
LeetCode 565 - Array Nesting

The problem gives us an array nums that is guaranteed to be a permutation of the integers from 0 to n - 1. A permutation means every value appears exactly once, and every value is within the valid index range of the array.

leetcodemediumarraydepth-first-search
LeetCode 1183 - Maximum Number of Ones

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

leetcodehardmathgreedysortingheap-(priority-queue)
LeetCode 635 - Design Log Storage System

The problem is asking us to design a log storage system that supports two primary operations: storing logs with unique IDs and timestamps, and retrieving logs based on a timestamp range and granularity.

leetcodemediumhash-tablestringdesignordered-set
CF 8C - Looking for Order

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

codeforcescompetitive-programmingbitmasksdp
LeetCode 1431 - Kids With the Greatest Number of Candies

This problem asks us to determine which children could potentially have the greatest number of candies if we distribute a fixed number of extra candies to any single child.

leetcodeeasyarray
LeetCode 1100 - Find K-Length Substrings With No Repeated Characters

The problem asks us to count how many substrings of length k contain only unique characters. A substring is a contiguous portion of the string. For every possible substring of length k, we must determine whether all characters inside it are distinct.

leetcodemediumhash-tablestringsliding-window
LeetCode 1639 - Number of Ways to Form a Target String Given a Dictionary

The problem gives us a list of strings called words, where every string has the same length, and another string called target. We need to count how many different ways we can build target by selecting characters from the columns of words.

leetcodehardarraystringdynamic-programming
LeetCode 292 - Nim Game

The problem describes a two-player game involving a single heap of stones. There are n stones initially on the table, and players alternate turns removing stones. On each turn, a player may remove either 1, 2, or 3 stones. The player who removes the final stone wins the game.

leetcodeeasymathbrainteasergame-theory
LeetCode 1332 - Remove Palindromic Subsequences

The problem gives us a string s that contains only the characters 'a' and 'b'. In one operation, we are allowed to remov

leetcodeeasytwo-pointersstring
CF 48E - Ivan the Fool VS Gorynych the Dragon

The game state is completely described by two numbers: how many heads and how many tails the dragon currently has. From a state (h, t) Ivan may choose one of two move types.

codeforcescompetitive-programmingdpgamesgraphs
LeetCode 1706 - Where Will the Ball Fall

This problem asks us to simulate the movement of balls dropped into a 2-D box represented by a grid. Each cell in the grid has a diagonal board that directs a ball either to the right (1) or to the left (-1).

leetcodemediumarraymatrixsimulation
CF 64E - Prime Segment

We are asked to find the closest prime numbers surrounding a given integer n. Concretely, we need two numbers, a and b, such that a ≤ n ≤ b and both a and b are prime. Among all prime intervals containing n, the one with the smallest length b - a is preferred.

codeforcescompetitive-programming*specialbrute-forcemathnumber-theory
CF 44B - Cola

We are asked to determine how many ways the organizers of a winter school can buy exactly n liters of cola using a limited supply of bottles in three sizes: 0.5-liter, 1-liter, and 2-liter.

codeforcescompetitive-programmingimplementation
CF 57B - Martian Architecture

Each construction describes a staircase placed on a one-dimensional line of cells. A staircase starts at cell l, ends at cell r, and adds heights in an arithmetic progression.

codeforcescompetitive-programmingimplementation
LeetCode 900 - RLE Iterator

This problem asks us to design an iterator over a run-length encoded sequence instead of storing the full sequence explicitly.

leetcodemediumarraydesigncountingiterator
LeetCode 1015 - Smallest Integer Divisible by K

The problem asks us to find the length of the smallest positive integer that satisfies two conditions: 1. The integer contains only the digit 1 2. The integer is divisible by k Such numbers are commonly called repunits.

leetcodemediumhash-tablemath
LeetCode 1427 - Perform String Shifts

This problem asks us to simulate a sequence of string shift operations on a given string s. Each operation in the shift

leetcodeeasyarraymathstring
CF 10A - Power Consumption Calculation

Tom uses his laptop during several disjoint time intervals. While he is actively using it, the laptop stays in normal mode and consumes P1 watts per minute. When he stops interacting with the laptop, the machine does not immediately switch to lower-power states.

codeforcescompetitive-programmingimplementation
LeetCode 657 - Robot Return to Origin

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

leetcodeeasystringsimulation
LeetCode 1825 - Finding MK Average

The problem asks us to design a data structure that continuously receives numbers from a stream and can efficiently compute a special average called the MKAverage. For every query, we only care about the most recent m elements in the stream. From those m elements: 1.

leetcodeharddesignqueueheap-(priority-queue)data-streamordered-set
LeetCode 1616 - Split Two Strings to Make Palindrome

This problem gives us two strings, a and b, both having the same length. We are allowed to choose a split index and divi

leetcodemediumtwo-pointersstring
LeetCode 1456 - Maximum Number of Vowels in a Substring of Given Length

This problem asks us to determine the maximum number of vowels that appear in any substring of a given length k within a

leetcodemediumstringsliding-window
LeetCode 709 - To Lower Case

The problem asks us to convert every uppercase English letter in a string into its lowercase equivalent. Any character that is already lowercase, or is not an alphabetic character at all, should remain unchanged. The input is a string s containing printable ASCII characters.

leetcodeeasystring
LeetCode 794 - Valid Tic-Tac-Toe State

This problem asks us to determine whether a given Tic-Tac-Toe board configuration could occur during a real game that follows all official rules. The input is a 3 x 3 board represented as an array of three strings.

leetcodemediumarraymatrix
LeetCode 1779 - Find Nearest Point That Has the Same X or Y Coordinate

The problem gives your current position on a 2D Cartesian grid as (x, y) and a list of other points. Each point is represented as [ai, bi].

leetcodeeasyarray
LeetCode 984 - String Without AAA or BBB

The problem gives us two integers, a and b, representing how many 'a' characters and 'b' characters we must place into a string.

leetcodemediumstringgreedy
LeetCode 1615 - Maximal Network Rank

The problem asks us to compute the maximal network rank for a set of cities connected by bidirectional roads. Each city can be thought of as a node in a graph, and each road as an undirected edge.

leetcodemediumgraph-theory
LeetCode 464 - Can I Win

This problem describes a two-player turn-based game. Players take turns choosing a number from a shared pool of integers ranging from 1 to maxChoosableInteger. Once a number is chosen, it cannot be used again for the rest of the game.

leetcodemediummathdynamic-programmingbit-manipulationmemoizationgame-theorybitmask
CF 49E - Common ancestor

Each DNA string evolves by repeatedly applying rules of the form a -> bc. One character is replaced by exactly two characters, and this operation can be repeated any number of times. Starting from some ancestor string, evolution only increases the length.

codeforcescompetitive-programmingdp
LeetCode 1052 - Grumpy Bookstore Owner

This problem asks us to maximize the number of satisfied customers in a bookstore over n minutes. We are given two arrays: customers, which indicates how many customers arrive each minute, and grumpy, which indicates whether the bookstore owner is grumpy (1) or not grumpy (0)…

leetcodemediumarraysliding-window
LeetCode 1304 - Find N Unique Integers Sum up to Zero

The problem asks us to construct an array containing exactly n unique integers whose total sum is equal to 0. The keywor

leetcodeeasyarraymath
CF 127A - Wasted Time

Scrooge signs papers by moving a pen along a polyline. The signature starts at the first point, then draws straight segments between consecutive points until the last point is reached.

codeforcescompetitive-programminggeometry
LeetCode 1452 - People Whose List of Favorite Companies Is Not a Subset of Another List

The problem requires identifying all people in a group whose list of favorite companies is not a subset of any other per

leetcodemediumarrayhash-tablestring
LeetCode 916 - Word Subsets

The problem asks us to determine which strings in words1 satisfy all character requirements imposed by every string in words2. A string b is considered a subset of another string a if every character in b appears in a at least as many times as it appears in b.

leetcodemediumarrayhash-tablestring
LeetCode 1347 - Minimum Number of Steps to Make Two Strings Anagram

This problem asks us to determine the minimum number of character replacements needed to transform string t into an anagram of string s. Two strings are anagrams if they contain exactly the same characters with the same frequencies, regardless of order.

leetcodemediumhash-tablestringcounting
LeetCode 1330 - Reverse Subarray To Maximize Array Value

The problem gives us an integer array nums and defines the "value" of the array as the sum of the absolute differences b

leetcodehardarraymathgreedy
LeetCode 1146 - Snapshot Array

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

leetcodemediumarrayhash-tablebinary-searchdesign
LeetCode 903 - Valid Permutations for DI Sequence

The problem gives us a string s of length n, where each character describes the relationship between two adjacent elements in a permutation. The permutation must contain every integer from 0 to n exactly once, so the permutation length is always n + 1.

leetcodehardstringdynamic-programmingprefix-sum
LeetCode 1746 - Maximum Subarray Sum After One Operation

The problem gives us an integer array nums, and we must perform exactly one operation on the array. The operation allows us to choose a single index i and replace the value nums[i] with its square, nums[i] nums[i].

leetcodemediumarraydynamic-programming
LeetCode 391 - Perfect Rectangle

This problem asks whether a collection of smaller axis-aligned rectangles perfectly forms one larger rectangle, with no gaps and no overlaps.

leetcodehardarrayhash-tablemathgeometrysweep-line
LeetCode 172 - Factorial Trailing Zeroes

The problem asks us to determine how many trailing zeroes appear at the end of n!, where n! represents the factorial of n. A factorial is defined as: For example: - 5!

leetcodemediummath
LeetCode 1363 - Largest Multiple of Three

I can do that, but the guide will be very long and may get truncated in a single message because of the required depth a

leetcodehardarraymathdynamic-programminggreedysorting
LeetCode 1826 - Faulty Sensor

The problem gives us two arrays, sensor1 and sensor2, representing readings collected simultaneously by two sensors. Under normal circumstances, both sensors should produce the same sequence of values. However, one sensor may be defective.

leetcodeeasyarraytwo-pointers
CF 84A - Toy Army

We have two armies, each containing n soldiers. The value of n is always even. The game lasts exactly three turns: 1. Valera attacks Arcady. 2. Arcady attacks Valera. 3. Valera attacks Arcady again.

codeforcescompetitive-programmingmathnumber-theory
CF 71C - Round Table Knights

The knights sit on a circle, equally spaced. Each position is marked either 1 for a knight in a good mood or 0 for a knight in a bad mood.

codeforcescompetitive-programmingdpmathnumber-theory
CF 97D - Robot in Basement

We have a grid representing a basement. Some cells are walls, some are walkable, and exactly one walkable cell is the exit. A robot starts in an unknown walkable cell. We are given a fixed sequence of movement commands such as L, R, U, D.

codeforcescompetitive-programmingbitmasksbrute-forceimplementation
LeetCode 1077 - Project Employees III

The problem asks us to find the most experienced employees in each project from two database tables, Project and Employee. The Project table contains a mapping of employeeids to projectids, indicating which employees work on which projects.

leetcodemediumdatabase
LeetCode 1774 - Closest Dessert Cost

The problem asks us to create a dessert using one ice cream base and zero or more toppings, with the additional restriction that each topping type can be used at most twice.

leetcodemediumarraydynamic-programmingbacktracking
LeetCode 1460 - Make Two Arrays Equal by Reversing Subarrays

This problem asks whether one integer array, arr, can be transformed into another array, target, by repeatedly reversing

leetcodeeasyarrayhash-tablesorting
LeetCode 1324 - Print Words Vertically

The problem requires us to take a string s containing multiple words separated by single spaces and return a list of strings representing the words written vertically.

leetcodemediumarraystringsimulation
LeetCode 1235 - Maximum Profit in Job Scheduling

The problem gives us three arrays of equal length: - startTime[i] represents when the i-th job starts - endTime[i] represents when the i-th job finishes - profit[i] represents the money earned if we complete that job Our goal is to select a subset of jobs that do not overlap…

leetcodehardarraybinary-searchdynamic-programmingsorting
CF 91B - Queue

We are given a queue of walruses, where index order goes from the tail toward the head. For every walrus at position i, we want to find the furthest position j i such that the walrus ahead is strictly younger, meaning a[j] < a[i]. If no such walrus exists, the answer is -1.

codeforcescompetitive-programmingbinary-searchdata-structures
LeetCode 1485 - Clone Binary Tree With Random Pointer

That’s a detailed reference guide with multiple required sections and full implementations. Before I start, please confi

leetcodemediumhash-tabletreedepth-first-searchbreadth-first-searchbinary-tree
LeetCode 490 - The Maze

This problem asks us to determine whether a rolling ball can stop exactly at a destination cell inside a maze. The maze is represented as a two-dimensional grid where: - 0 represents an empty space the ball can roll through - 1 represents a wall The important detail is that…

leetcodemediumarraydepth-first-searchbreadth-first-searchmatrix
CF 10E - Greedy Change

We are asked to investigate whether the greedy algorithm for making change can fail with a given set of coin denominations.

codeforcescompetitive-programmingconstructive-algorithms
LeetCode 1701 - Average Waiting Time

This problem is asking us to simulate the operation of a single-chef restaurant, where customers arrive at certain times and each customer has a specific preparation time for their order. The goal is to calculate the average waiting time for all customers.

leetcodemediumarraysimulation
LeetCode 1110 - Delete Nodes And Return Forest

This problem gives us the root of a binary tree and a list of node values that must be deleted from the tree. Every node value in the tree is unique, which is important because it means we can identify nodes directly by value without ambiguity.

leetcodemediumarrayhash-tabletreedepth-first-searchbinary-tree
LeetCode 801 - Minimum Swaps To Make Sequences Increasing

The problem gives us two arrays, nums1 and nums2, both of the same length. At every index i, we are allowed to either keep the values as they are, or swap nums1[i] with nums2[i]. Our goal is to make both arrays strictly increasing while performing the minimum number of swaps.

leetcodehardarraydynamic-programming
LeetCode 843 - Guess the Word

This is an interactive problem where we must identify a hidden six-letter word from a given list of candidate words. We are not allowed to directly inspect the secret word. Instead, we can interact with the provided Master API by calling master.guess(word).

leetcodehardarraymathstringinteractivegame-theory
LeetCode 62 - Unique Paths

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

leetcodemediummathdynamic-programmingcombinatorics
LeetCode 739 - Daily Temperatures

The problem gives an array called temperatures, where each element represents the temperature recorded on a specific day. For every day, we must determine how many days in the future we need to wait until a warmer temperature appears.

leetcodemediumarraystackmonotonic-stack
LeetCode 1455 - Check If a Word Occurs As a Prefix of Any Word in a Sentence

The problem asks us to determine whether a given searchWord occurs as a prefix of any word within a sentence. A sentence is defined as a string of lowercase English letters separated by single spaces, and a prefix is any contiguous leading substring of a word.

leetcodeeasytwo-pointersstringstring-matching
LeetCode 1290 - Convert Binary Number in a Linked List to Integer

The problem gives us the head of a singly linked list where every node contains either 0 or 1. These values together rep

leetcodeeasylinked-listmath
LeetCode 639 - Decode Ways II

The problem asks us to determine the number of ways an encoded string can be decoded into letters, where 'A' maps to "1", 'B' maps to "2", up to 'Z' mapping to "26".

leetcodehardstringdynamic-programming
LeetCode 1469 - Find All The Lonely Nodes

This problem asks us to traverse a binary tree and identify every node that is considered "lonely". A node is lonely if

leetcodeeasytreedepth-first-searchbreadth-first-searchbinary-tree
LeetCode 1274 - Number of Ships in a Rectangle

The problem presents an interactive scenario where ships are placed at integer coordinates on a Cartesian plane. You do

leetcodehardarraydivide-and-conquerinteractive
CF 53C - Little Frog

We have n mounds placed on a straight line at positions 1, 2, ..., n. The frog wants to visit every mound exactly once, so we must output a permutation of these positions.

codeforcescompetitive-programmingconstructive-algorithms
CF 28A - Bender Problem

We are given a sequence of nails in the plane, each with integer coordinates, and a collection of straight rods. The nails define the vertices of a closed polyline that only moves along horizontal or vertical segments.

codeforcescompetitive-programmingimplementation
LeetCode 1357 - Apply Discount Every n Orders

The problem describes a supermarket that sells products identified by unique integer IDs. Each product has a corresponding price. Customers purchase products in certain amounts, generating a bill that is the sum of the prices multiplied by the amounts purchased.

leetcodemediumarrayhash-tabledesign
LeetCode 526 - Beautiful Arrangement

The problem asks us to count how many permutations of the integers from 1 to n satisfy a special divisibility condition. A permutation is an arrangement of all numbers from 1 to n where every number appears exactly once.

leetcodemediumarraydynamic-programmingbacktrackingbit-manipulationbitmask
LeetCode 1521 - Find a Value of a Mysterious Function Closest to Target

The problem defines a mysterious function func(arr, l, r) that computes the bitwise AND of all elements in the subarray

leetcodehardarraybinary-searchbit-manipulationsegment-tree
LeetCode 1065 - Index Pairs of a String

The problem gives us a string called text and a list of dictionary words called words. We must find every substring inside text that exactly matches one of the words in the dictionary.

leetcodeeasyarraystringtriesorting
LeetCode 762 - Prime Number of Set Bits in Binary Representation

The problem requires counting the numbers within a given inclusive range [left, right] that have a prime number of set bits in their binary representation. The set bits of a number refer to the number of 1s in its binary representation.

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

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

leetcodemediumarraybinary-searchmatrixprefix-sum
CF 119B - Before Exam

We have n theorems, and each theorem has a proficiency value assigned to it. The exam contains exactly k different cards. Every card contains exactly floor(n / k) distinct theorems, and no theorem appears in more than one card.

codeforcescompetitive-programmingconstructive-algorithmsimplementationsortings
LeetCode 220 - Contains Duplicate III

The problem asks whether there exists a pair of different indices (i, j) in the array such that two conditions are satisfied at the same time. The first condition is about index distance: This means the two elements must be relatively close together in the array.

leetcodehardarraysliding-windowsortingbucket-sortordered-set
LeetCode 223 - Rectangle Area

The problem gives the coordinates of two axis-aligned rectangles on a 2D plane. Each rectangle is represented using two corner points: - Bottom-left corner (x1, y1) - Top-right corner (x2, y2) For the first rectangle, the coordinates are: - (ax1, ay1) for the bottom-left -…

leetcodemediummathgeometry
LeetCode 24 - Swap Nodes in Pairs

The problem gives us the head of a singly linked list and asks us to swap every pair of adjacent nodes. The important detail is that we are not allowed to modify the values stored inside the nodes. We must physically rearrange the node connections by changing pointers.

leetcodemediumlinked-listrecursion