brain

tamnd's digital brain — notes, problems, research

42667 notes

LeetCode 134 - Gas Station

The problem describes a circular route containing n gas stations. At each station i, you can collect gas[i] units of fuel. Traveling from station i to station (i + 1) % n consumes cost[i] units of fuel.

leetcodemediumarraygreedy
LeetCode 1047 - Remove All Adjacent Duplicates In String

The problem gives us a string s containing only lowercase English letters. We repeatedly look for two adjacent characters that are equal, remove both of them, and continue this process until no such adjacent duplicate pair exists.

leetcodeeasystringstack
LeetCode 640 - Solve the Equation

The problem is asking us to solve a linear equation containing a single variable 'x' and integer coefficients, expressed as a string. The equation may include addition '+', subtraction '-', and the equality operator '='.

leetcodemediummathstringsimulation
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
CF 79C - Beaver

We are asked to find the longest contiguous substring of a string s that avoids certain "boring" substrings. In other words, given a string s and a small list of forbidden patterns b1, b2, ...

codeforcescompetitive-programmingdata-structuresdpgreedyhashingstringstwo-pointers
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
LeetCode 1160 - Find Words That Can Be Formed by Characters

This problem asks us to determine which words from a given list can be constructed using the characters available in another string, chars. A word is considered good if every character it needs exists in chars in sufficient quantity.

leetcodeeasyarrayhash-tablestringcounting
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
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
CF 40D - Interesting Sequence

The sequence starts with two fixed values:

codeforcescompetitive-programmingmath
LeetCode 2036 - Maximum Alternating Subarray Sum

The problem asks us to compute the maximum alternating subarray sum for a given integer array. A subarray is any contiguous sequence of elements from the array.

leetcodemediumarraydynamic-programming
LeetCode 884 - Uncommon Words from Two Sentences

This problem asks us to find all words that are considered "uncommon" between two sentences. Each sentence is made up of lowercase words separated by single spaces. A word is considered uncommon if it satisfies two conditions: 1. It appears exactly once in one sentence. 2.

leetcodeeasyhash-tablestringcounting
LeetCode 790 - Domino and Tromino Tiling

The problem asks us to compute the number of ways to completely tile a 2 x n board using two types of tiles: a domino (2 x 1) and a tromino shape.

leetcodemediumdynamic-programming
LeetCode 533 - Lonely Pixel II

The problem gives us a matrix called picture, where each cell contains either 'B' for a black pixel or 'W' for a white pixel. We are also given an integer target. We need to count how many black pixels qualify as "lonely pixels" under two strict conditions.

leetcodemediumarrayhash-tablematrix
LeetCode 1741 - Find Total Time Spent by Each Employee

The problem asks us to calculate the total time each employee spends in the office per day based on a table of their in and out times.

leetcodeeasydatabase
LeetCode 506 - Relative Ranks

The problem gives us an array named score, where each element represents the score earned by an athlete in a competition. Every athlete has a unique score, which means there are no ties to worry about when determining rankings.

leetcodeeasyarraysortingheap-(priority-queue)
LeetCode 920 - Number of Music Playlists

The problem gives us n unique songs and asks us to build playlists of length goal. Songs may repeat, but two important constraints must always hold. First, every one of the n songs must appear at least once in the playlist.

leetcodehardmathdynamic-programmingcombinatorics
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
LeetCode 1301 - Number of Paths with Max Score

In this problem, we are given an n x n board where each cell contains one of four possible values: - 'E', the ending position located at the top-left corner - 'S', the starting position located at the bottom-right corner - A digit character '1' through '9', representing points…

leetcodehardarraydynamic-programmingmatrix
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
CF 59A - Word

The task is to normalize the case of a single word so that either all letters are lowercase or all are uppercase.

codeforcescompetitive-programmingimplementationstrings
LeetCode 1145 - Binary Tree Coloring Game

The problem is a two-player game played on a binary tree, where each player colors nodes starting from an initial chosen node. Player 1 picks a node x and colors it red, while Player 2 picks a different node y and colors it blue.

leetcodemediumtreedepth-first-searchbinary-tree
CF 43D - Journey

We have an n × m grid. The king starts at the top-left cell (1,1) and must end there as well. Every other cell must be visited exactly once. Normal movement is allowed only between side-adjacent cells, but we may additionally install directed teleporters.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsimplementation
LeetCode 1228 - Missing Number In Arithmetic Progression

The problem asks us to find a missing value from an array that originally formed an arithmetic progression (AP). An arithmetic progression is a sequence where the difference between consecutive terms is constant, i.e., arr[i + 1] - arr[i] is the same for every consecutive pair.

leetcodeeasyarraymath
LeetCode 393 - UTF-8 Validation

The problem asks us to determine whether a sequence of integers represents a valid UTF-8 encoded byte stream. Each integer in the input array represents one byte, meaning only its lowest 8 bits matter.

leetcodemediumarraybit-manipulation
LeetCode 424 - Longest Repeating Character Replacement

The problem gives us a string s consisting only of uppercase English letters and an integer k. We are allowed to perform at most k replacement operations. In one operation, we can change any character in the string into any other uppercase English character.

leetcodemediumhash-tablestringsliding-window
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 953 - Verifying an Alien Dictionary

This problem asks us to verify whether a list of words is sorted according to a custom alphabet order, instead of the normal English alphabetical order. In normal lexicographical ordering, characters are compared from left to right using the standard alphabet.

leetcodeeasyarrayhash-tablestring
CF 58C - Trees

We are given a row of n trees, each with a certain height, and our task is to adjust some of their heights so that the row forms a “beautiful” sequence.

codeforcescompetitive-programmingbrute-force
CF 45H - Road Problem

We are given a connected undirected graph representing a road network. Every junction is a vertex, every road is an edge, and there is at most one edge between any pair of vertices.

codeforcescompetitive-programminggraphs
LeetCode 78 - Subsets

This problem asks us to generate every possible subset of a given array of unique integers. A subset is any selection of elements from the array, including the empty subset and the subset containing every element.

leetcodemediumarraybacktrackingbit-manipulation
LeetCode 1184 - Distance Between Bus Stops

In this problem, we are given a circular bus route with n stops numbered from 0 to n - 1. The array distance describes the distance between neighboring stops. Specifically, distance[i] represents the distance from stop i to stop (i + 1) % n.

leetcodeeasyarray
CF 11B - Jumping Jack

Jack starts at position 0 on a number line. His jumps have fixed lengths: the first jump must have length 1, the second jump length 2, the third jump length 3, and so on. For every jump he may choose either direction.

codeforcescompetitive-programmingmath
CF 43B - Letter

We are given two strings. The first string is the newspaper headline, and the second string is the anonymous letter Vasya wants to build from it.

codeforcescompetitive-programmingimplementationstrings
LeetCode 939 - Minimum Area Rectangle

The problem gives us a collection of distinct points on a 2D plane. Each point is represented as [x, y], where x is the horizontal coordinate and y is the vertical coordinate.

leetcodemediumarrayhash-tablemathgeometrysorting
CF 97E - Leaders

We are given an undirected graph where vertices represent people and edges represent relationships. For every query (u, v), we must decide whether there exists a simple path from u to v whose length is odd. The keyword here is "simple". We are not allowed to revisit vertices.

codeforcescompetitive-programmingdfs-and-similardsugraphstrees
LeetCode 1412 - Find the Quiet Students in All Exams

This problem asks us to identify students who are "quiet" across all exams they participated in. A student is considered

leetcodeharddatabase
CF 47A - Triangular numbers

We are asked to determine if a given positive integer can be represented as a triangular number. Triangular numbers are formed by arranging dots into an equilateral triangle, so the _n_-th triangular number is the sum of the first _n_ positive integers.

codeforcescompetitive-programmingbrute-forcemath
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 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 147 - Insertion Sort List

The problem asks us to sort a singly linked list using the insertion sort algorithm. Unlike array sorting problems where elements can be accessed directly by index, linked lists require sequential traversal, so insertion operations behave differently and require careful…

leetcodemediumlinked-listsorting
LeetCode 1380 - Lucky Numbers in a Matrix

This problem asks us to identify all lucky numbers in a given matrix. A lucky number is defined as a value that satisfie

leetcodeeasyarraymatrix
LeetCode 995 - Minimum Number of K Consecutive Bit Flips

The problem gives us a binary array nums consisting of 0s and 1s and an integer k. The task is to transform the array so that all elements are 1s using the minimum number of operations called k-bit flips.

leetcodehardarraybit-manipulationqueuesliding-windowprefix-sum
LeetCode 1642 - Furthest Building You Can Reach

The problem gives us an array heights, where each value represents the height of a building. You start at building 0 and

leetcodemediumarraygreedyheap-(priority-queue)
LeetCode 1044 - Longest Duplicate Substring

Here is the complete, detailed technical solution guide for LeetCode 1044 - Longest Duplicate Substring, following your formatting rules exactly. The problem asks us to find the longest duplicated substring in a given string s.

leetcodehardstringbinary-searchsliding-windowrolling-hashsuffix-arrayhash-function
LeetCode 871 - Minimum Number of Refueling Stops

The problem describes a car traveling from position 0 to a destination located target miles away. The car starts with startFuel liters of fuel, and every mile driven consumes exactly one liter of fuel.

leetcodehardarraydynamic-programminggreedyheap-(priority-queue)
LeetCode 352 - Data Stream as Disjoint Intervals

This problem asks us to process a stream of non-negative integers and continuously maintain a compact representation of all numbers seen so far. Instead of storing every individual number separately, we want to group consecutive numbers into disjoint intervals.

leetcodehardhash-tablebinary-searchunion-finddesigndata-streamordered-set
LeetCode 1198 - Find Smallest Common Element in All Rows

The problem asks us to find the smallest element that appears in every row of a given m x n matrix mat, where each row is sorted in strictly increasing order. In other words, we need an element that is common to all rows and is the minimum among all such elements.

leetcodemediumarrayhash-tablebinary-searchmatrixcounting
CF 87A - Trains

Vasya is at the central station of a subway branch with two endpoints. Each endpoint corresponds to one of his girlfriends: Dasha or Masha. Trains to Dasha’s station arrive every a minutes and trains to Masha’s station arrive every b minutes.

codeforcescompetitive-programmingimplementationmath
LeetCode 1095 - Find in Mountain Array

This problem gives us a special type of array called a mountain array. A mountain array strictly increases until it reaches a single peak element, then strictly decreases afterward. For example: increases up to 5, then decreases.

leetcodehardarraybinary-searchinteractive
LeetCode 268 - Missing Number

The problem gives an array nums containing n distinct integers. Every number is supposed to come from the range [0, n], which means there are actually n + 1 possible values in total. Since the array only contains n numbers, exactly one value from that range is missing.

leetcodeeasyarrayhash-tablemathbinary-searchbit-manipulationsorting
LeetCode 546 - Remove Boxes

The problem gives us an array called boxes, where each integer represents the color of a box. We may repeatedly remove groups of adjacent boxes that share the same color. If we remove a group containing k boxes, we earn k k points.

leetcodehardarraydynamic-programmingmemoization
LeetCode 632 - Smallest Range Covering Elements from K Lists

The problem gives us k sorted integer lists, and we must find the smallest inclusive range [a, b] such that the range contains at least one element from every list. Each list is already sorted in non-decreasing order, which is a very important property.

leetcodehardarrayhash-tablegreedysliding-windowsortingheap-(priority-queue)
LeetCode 637 - Average of Levels in Binary Tree

In this problem, we are given the root node of a binary tree, and we need to compute the average value of all nodes at each depth level of the tree. A binary tree is organized into levels.

leetcodeeasytreedepth-first-searchbreadth-first-searchbinary-tree
LeetCode 401 - Binary Watch

The problem describes a binary watch that uses LEDs to represent time. The watch has two sections. The top section contains 4 LEDs for the hour, and the bottom section contains 6 LEDs for the minutes. Each LED represents a binary digit.

leetcodeeasybacktrackingbit-manipulation
LeetCode 1797 - Design Authentication Manager

The problem asks us to design an authentication system that manages tokens with expiration times. Each token is valid for a fixed timeToLive seconds starting from the moment it is generated or renewed.

leetcodemediumhash-tablelinked-listdesigndoubly-linked-list
LeetCode 1592 - Rearrange Spaces Between Words

The problem requires rearranging spaces in a given string text so that all words are separated by the maximum possible e

leetcodeeasystring
LeetCode 1244 - Design A Leaderboard

This problem asks us to design a leaderboard system that supports three operations efficiently. Each player has a unique playerId and an associated score. The leaderboard begins empty, and players can be added dynamically as operations are performed.

leetcodemediumhash-tabledesignsorting
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
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 1504 - Count Submatrices With All Ones

The problem gives us an m x n binary matrix where each cell contains either 0 or 1. We must count how many rectangular submatrices consist entirely of ones. A submatrix is any contiguous rectangular region inside the matrix.

leetcodemediumarraydynamic-programmingstackmatrixmonotonic-stack
LeetCode 525 - Contiguous Array

This problem asks us to find the maximum length of a contiguous subarray in a binary array where the number of 0s and 1s are equal. A contiguous subarray means the elements must appear consecutively in the original array. We are not allowed to rearrange elements or skip indices.

leetcodemediumarrayhash-tableprefix-sum
CF 72H - Reverse It!

The task is to reverse a number given as a string, taking care of signs and leading zeros. The input can be a very large integer, up to 10,000 digits, possibly with leading zeros.

codeforcescompetitive-programming*specialimplementation
LeetCode 1525 - Number of Good Ways to Split a String

The problem asks us to count how many ways we can split a string into two non-empty parts such that both parts contain the same number of distinct characters. A split occurs between two adjacent characters.

leetcodemediumhash-tablestringdynamic-programmingbit-manipulation
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 820 - Short Encoding of Words

The problem asks us to find the length of the shortest reference string that can encode a list of words. A reference string is formed by concatenating some of the words with a '' character at the end of each word.

leetcodemediumarrayhash-tablestringtrie
LeetCode 812 - Largest Triangle Area

The problem gives us a list of unique points on a 2D X-Y plane. Each point is represented as a pair of integers [x, y]. Our task is to choose any three distinct points and compute the area of the triangle formed by those points.

leetcodeeasyarraymathgeometry
CF 120C - Winnie-the-Pooh and honey

We have several jars of honey, and each jar starts with some amount of honey. Winnie repeatedly chooses the jar that currently contains the most honey. When Winnie picks a jar, two things may happen.

codeforcescompetitive-programmingimplementationmath
LeetCode 1601 - Maximum Number of Achievable Transfer Requests

The problem asks us to maximize the number of employee transfer requests that can be fulfilled under the constraint that

leetcodehardarraybacktrackingbit-manipulationenumeration
LeetCode 137 - Single Number II

This problem asks us to find a unique number in an array where every other number appears exactly three times. In simpler terms, if you imagine counting all the numbers in the array, every number except one will show up three times, and our task is to identify the number that…

leetcodemediumarraybit-manipulation
LeetCode 470 - Implement Rand10() Using Rand7()

The problem provides access to a single API, rand7(), which returns a uniformly random integer from 1 to 7. The task is to implement another function, rand10(), which must return a uniformly random integer from 1 to 10.

leetcodemediummathrejection-samplingrandomizedprobability-and-statistics
LeetCode 1683 - Invalid Tweets

This problem gives us a database table named Tweets with two columns: | Column | Description | | --- | --- | | tweetid |

leetcodeeasydatabase
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 1351 - Count Negative Numbers in a Sorted Matrix

The problem asks us to count all the negative numbers in a 2D matrix grid where each row and column is sorted in non-inc

leetcodeeasyarraybinary-searchmatrix
CF 67E - Save the City!

We are given a simple polygon listed in clockwise order. The first two vertices form a horizontal edge AB, and every other vertex lies strictly on the same side of that edge. Along the segment AB, every integer-coordinate point is a possible location for a watchtower.

codeforcescompetitive-programminggeometry
CF 113B - Petr#

We are asked to count how many distinct substrings of a given string t start with a string sbegin and end with another string send. The key detail is that substrings are considered different only by their content, not by their position in t.

codeforcescompetitive-programmingbrute-forcedata-structureshashingstrings
LeetCode 721 - Accounts Merge

This problem asks us to merge user accounts based on shared email addresses. Each account is represented as a list of strings. The first string is the user's name, and every remaining string is an email address associated with that account.

leetcodemediumarrayhash-tablestringdepth-first-searchbreadth-first-searchunion-findsorting
LeetCode 961 - N-Repeated Element in Size 2N Array

The problem gives us an integer array nums whose length is exactly 2 n. Among all the numbers in the array, there are n + 1 distinct values. One special value appears exactly n times, while every other value appears only once.

leetcodeeasyarrayhash-table
LeetCode 126 - Word Ladder II

This problem asks us to find all shortest transformation sequences from beginWord to endWord, where each transformation changes exactly one character and every intermediate word must exist in wordList. We can think of the problem as navigating through a graph.

leetcodehardhash-tablestringbacktrackingbreadth-first-search
CF 74C - Chessboard Billiard

We have an n × m chessboard. A billiard ball moves diagonally like a bishop, but unlike a bishop it reflects off the borders of the board. When it hits a vertical wall, the horizontal component of the direction flips. When it hits a horizontal wall, the vertical component flips.

codeforcescompetitive-programmingdfs-and-similardsugraphsnumber-theory
LeetCode 1673 - Find the Most Competitive Subsequence

Here is a complete, detailed technical solution guide for LeetCode 1673 - Find the Most Competitive Subsequence followin

leetcodemediumarraystackgreedymonotonic-stack
LeetCode 1634 - Add Two Polynomials Represented as Linked Lists

This problem asks us to add two polynomials represented as singly linked lists. Each node in the linked list represents a single term of a polynomial, with a coefficient and a power.

leetcodemediumlinked-listmathtwo-pointers
LeetCode 28 - Find the Index of the First Occurrence in a String

This problem asks us to locate the first occurrence of one string inside another string. The string we are searching for is called needle, and the larger string we search inside is called haystack.

leetcodeeasytwo-pointersstringstring-matching
LeetCode 86 - Partition List

It looks like you want the full detailed solution guide, but the specific LeetCode problem number and statement are missing from your latest request template. You included the formatting instructions and structure, but not which problem to solve beyond prior context.

leetcodemediumlinked-listtwo-pointers
LeetCode 932 - Beautiful Array

The problem asks us to construct a permutation of the integers from 1 to n such that the array satisfies a special condition.

leetcodemediumarraymathdivide-and-conquer
CF 86D - Powerful array

We are given an array of positive integers and many interval queries. For each query [l, r], we look only at the subarray between those indices and compute a value called its power. If a number x appears k times inside the subarray, then x contributes k² x to the answer.

codeforcescompetitive-programmingdata-structuresimplementationmathtwo-pointers
LeetCode 1230 - Toss Strange Coins

This problem is asking us to calculate the probability that, when tossing a set of coins, exactly a specific number of them come up heads. Each coin has its own individual probability of landing heads, which is given in the input array prob.

leetcodemediumarraymathdynamic-programmingprobability-and-statistics
LeetCode 1725 - Number Of Rectangles That Can Form The Largest Square

The problem gives us a list of rectangles, where each rectangle is represented as [li, wi]. Here, li is the rectangle's length and wi is its width. From each rectangle, we want to determine the largest square that can be cut from it.

leetcodeeasyarray
LeetCode 1483 - Kth Ancestor of a Tree Node

The problem gives us a rooted tree with n nodes labeled from 0 to n - 1. Instead of providing the tree as adjacency lists or edges, the input is represented using a parent array. For every node i, parent[i] tells us which node is its direct parent.

leetcodehardbinary-searchdynamic-programmingbit-manipulationtreedepth-first-searchbreadth-first-searchdesign
CF 47C - Crossword

We are given six words and must arrange them into a very specific crossword shape. The shape looks like a rectangular infinity symbol. There are three horizontal words and three vertical words, and they intersect at fixed positions.

codeforcescompetitive-programmingimplementation
LeetCode 1062 - Longest Repeating Substring

The problem asks us to find the length of the longest substring that appears at least twice in a given string s. A substring is a contiguous sequence of characters inside a string. The repeated substrings may overlap with each other, which is an important detail.

leetcodemediumstringbinary-searchdynamic-programmingrolling-hashsuffix-arrayhash-function
LeetCode 492 - Construct the Rectangle

The problem gives us a single integer, area, which represents the area of a rectangle. Our task is to find two integers: - L, the length - W, the width such that: 1. L W == area 2. L = W 3.

leetcodeeasymath
CF 77C - Beavermuncher-0xFF

We have a tree where each vertex initially contains some number of beavers. The robot starts at a fixed vertex s. Every time it traverses an edge from u to v, it immediately eats exactly one beaver at v. If v already has zero beavers left, the move is impossible.

codeforcescompetitive-programmingdfs-and-similardpdsugreedytrees
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 77 - Combinations

This problem asks us to generate all possible combinations of size k from the numbers in the inclusive range [1, n].

leetcodemediumbacktracking
LeetCode 1420 - Build Array Where You Can Find The Maximum Exactly K Comparisons

This problem asks us to count the number of arrays of length n where each element is between 1 and m inclusive, and the

leetcodeharddynamic-programmingprefix-sum
LeetCode 889 - Construct Binary Tree from Preorder and Postorder Traversal

The problem gives us two traversal orders of the same binary tree: - preorder, which visits nodes in the order: root → left subtree → right subtree - postorder, which visits nodes in the order: left subtree → right subtree → root Our task is to reconstruct and return the…

leetcodemediumarrayhash-tabledivide-and-conquertreebinary-tree
LeetCode 1628 - Design an Expression Tree With Evaluate Function

The problem requires constructing a binary expression tree from a postfix arithmetic expression and implementing a metho

leetcodemediumarraymathstacktreedesignbinary-tree
LeetCode 73 - Set Matrix Zeroes

The problem gives us a two dimensional matrix of integers with m rows and n columns. We must modify the matrix in place so that whenever a cell contains 0, every element in that cell's entire row and entire column also becomes 0.

leetcodemediumarrayhash-tablematrix
LeetCode 1181 - Before and After Puzzle

The problem gives us an array of phrases, where each phrase is a string made of lowercase English letters and spaces. Every phrase is well-formed, meaning there are no leading or trailing spaces and no consecutive spaces.

leetcodemediumarrayhash-tablestringsorting