brain

tamnd's digital brain — notes, problems, research

42641 notes

LeetCode 98 - Validate Binary Search Tree

This problem asks us to determine whether a given binary tree satisfies the rules of a Binary Search Tree, commonly abbreviated as BST. A binary tree consists of nodes where each node contains a value and pointers to a left child and a right child.

leetcodemediumtreedepth-first-searchbinary-search-treebinary-tree
LeetCode 818 - Race Car

This problem asks us to control a car moving on an infinite one dimensional number line. The car starts at position 0 with speed +1.

leetcodeharddynamic-programming
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 121D - Lucky Segments

We are asked to find the maximum number of "full lucky numbers" that can appear after adjusting segments of numbers. A lucky number is any positive integer whose digits consist only of 4 and 7. Each segment is a range [li, ri] on the number line.

codeforcescompetitive-programmingbinary-searchimplementationtwo-pointers
CF 117A - Elevator

The elevator follows a completely deterministic cycle. It starts at floor 1 at time 0, climbs one floor per second until it reaches floor m, then immediately reverses direction and goes back down to floor 1, again moving one floor per second.

codeforcescompetitive-programmingimplementationmath
LeetCode 840 - Magic Squares In Grid

The problem asks us to count the number of 3 x 3 magic squares inside a larger grid. A magic square is defined as a square where all numbers are distinct integers from 1 to 9 and the sum of each row, column, and the two diagonals is the same.

leetcodemediumarrayhash-tablemathmatrix
LeetCode 411 - Minimum Unique Word Abbreviation

This problem asks us to generate the shortest possible abbreviation for a given target word such that the abbreviation cannot also represent any word in the dictionary. An abbreviation replaces one or more non-adjacent substrings with their lengths.

leetcodehardarraystringbacktrackingbit-manipulation
LeetCode 799 - Champagne Tower

The problem asks us to simulate a process of pouring champagne into a pyramid of glasses. Each glass can hold exactly one cup of champagne, and any excess from a glass flows evenly to the two glasses immediately below it.

leetcodemediumdynamic-programming
CF 93E - Lostborn

We are asked to calculate how many numbers from 1 to n are not divisible by any number in a given set of integers, called hit indicators. Each indicator is guaranteed to be coprime with the others, and there are k of them, each at most 1000.

codeforcescompetitive-programmingdpmathnumber-theory
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 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
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 125 - Valid Palindrome

This problem asks us to determine whether a given string is a palindrome after applying two transformations: 1. Convert all uppercase letters to lowercase. 2. Remove all non-alphanumeric characters. An alphanumeric character is any English letter (a-z, A-Z) or digit (0-9).

leetcodeeasytwo-pointersstring
LeetCode 1318 - Minimum Flips to Make a OR b Equal to c

The problem gives us three positive integers, a, b, and c. We are allowed to flip individual bits in either a or b. A flip means changing a bit from 0 to 1 or from 1 to 0. Our goal is to perform the minimum number of bit flips so that: The OR operation works bit by bit.

leetcodemediumbit-manipulation
LeetCode 535 - Encode and Decode TinyURL

The problem asks us to implement a URL shortening service, similar to TinyURL. Given a long URL, our system should generate a short, unique URL that maps back to the original URL. When the short URL is accessed, the system should return the original long URL.

leetcodemediumhash-tablestringdesignhash-function
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 103 - Binary Tree Zigzag Level Order Traversal

The problem asks us to perform a level order traversal of a binary tree, but with a twist. Instead of always traversing each level from left to right, we alternate the traversal direction at every level.

leetcodemediumtreebreadth-first-searchbinary-tree
LeetCode 821 - Shortest Distance to a Character

The problem gives us a string s and a target character c. For every index in the string, we must compute the distance to the nearest occurrence of c. The distance between two indices is defined as: where i is the current index and j is the index of some occurrence of c.

leetcodeeasyarraytwo-pointersstring
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 514 - Freedom Trail

The problem models a circular dial, represented by the string ring, where each character is engraved at a position around the circle. Another string, key, represents the sequence of characters we must spell.

leetcodehardstringdynamic-programmingdepth-first-searchbreadth-first-search
CF 54B - Cutting Jigsaw Puzzle

We are given a rectangular picture represented as an A × B grid of letters. The task is to determine how many ways we can cut this picture into smaller rectangular pieces such that each piece is unique up to rotations, and to identify the smallest possible piece size among…

codeforcescompetitive-programminghashingimplementation
LeetCode 291 - Word Pattern II

The problem asks us to determine whether a given string s can be formed by substituting each character in a pattern with a non-empty string, under a bijective mapping.

leetcodemediumhash-tablestringbacktracking
LeetCode 1790 - Check if One String Swap Can Make Strings Equal

The problem asks us to determine if two strings of equal length, s1 and s2, can be made identical by performing at most one string swap on exactly one of the strings. A string swap allows exchanging any two characters at different or same indices.

leetcodeeasyhash-tablestringcounting
LeetCode 1331 - Rank Transform of an Array

The problem asks us to replace every number in the input array with its rank when the array is sorted in ascending order.

leetcodeeasyarrayhash-tablesorting
LeetCode 574 - Winning Candidate

This problem provides two database tables, Candidate and Vote, and asks us to determine which candidate won the election. The Candidate table stores information about each candidate. Every candidate has a unique integer id and a corresponding name.

leetcodemediumdatabase
LeetCode 1256 - Encode Number

Sure, let's build a full, detailed technical solution guide for LeetCode 1256 following your requested structure. The problem asks us to take a non-negative integer num and encode it as a string using a secret encoding rule.

leetcodemediummathstringbit-manipulation
LeetCode 718 - Maximum Length of Repeated Subarray

The problem asks us to find the longest contiguous subarray that appears in both input arrays. A subarray is different from a subsequence because the elements must remain adjacent.

leetcodemediumarraybinary-searchdynamic-programmingsliding-windowrolling-hashhash-function
LeetCode 381 - Insert Delete GetRandom O(1) - Duplicates allowed

The problem asks us to design a data structure called RandomizedCollection that behaves like a multiset. Unlike a normal set, duplicate values are allowed.

leetcodehardarrayhash-tablemathdesignrandomized
CF 114B - PFAST Inc.

We are given a small group of people and a list of pairs who cannot work together. We need to choose the largest possible subset such that every pair inside the chosen group is compatible. This is naturally a graph problem. Think of each volunteer as a vertex.

codeforcescompetitive-programmingbitmasksbrute-forcegraphs
LeetCode 1004 - Max Consecutive Ones III

This problem asks us to find the length of the longest contiguous subarray that can contain only 1s after flipping at most k zeroes into ones.

leetcodemediumarraybinary-searchsliding-windowprefix-sum
CF 111A - Petya and Inequiations

We need to construct an array of n positive integers. The array must satisfy two conditions at the same time. The sum of squares of all elements must be at least x, while the ordinary sum of the elements must not exceed y. The task is not to optimize anything.

codeforcescompetitive-programminggreedy
LeetCode 653 - Two Sum IV - Input is a BST

This problem gives us the root of a Binary Search Tree (BST) and an integer k. We must determine whether there are two distinct nodes in the tree whose values add up to k.

leetcodeeasyhash-tabletwo-pointerstreedepth-first-searchbreadth-first-searchbinary-search-treebinary-tree
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 1475 - Final Prices With a Special Discount in a Shop

The problem presents a scenario where you are buying items in a shop, each with a given price stored in an array prices.

leetcodeeasyarraystackmonotonic-stack
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 954 - Array of Doubled Pairs

The problem asks whether it is possible to reorder an even-length array arr of integers such that every element can be paired with another element that is exactly double its value.

leetcodemediumarrayhash-tablegreedysorting
LeetCode 824 - Goat Latin

This problem asks us to transform a given sentence into a fictional language called Goat Latin, following a specific set of string manipulation rules. The input is a string called sentence, where words are separated by a single space.

leetcodeeasystring
LeetCode 777 - Swap Adjacent in LR String

The problem gives us two strings, start and result, both consisting only of the characters 'L', 'R', and 'X'. We are allowed to transform the start string using only two kinds of moves: - Replace "XL" with "LX" - Replace "RX" with "XR" The goal is to determine whether it is…

leetcodemediumtwo-pointersstring
LeetCode 1773 - Count Items Matching a Rule

The problem asks us to determine how many items in a list satisfy a given rule. Each item is represented as a list of three strings: its type, color, and name. The rule is given as two strings: ruleKey and ruleValue.

leetcodeeasyarraystring
LeetCode 754 - Reach a Number

The problem asks us to find the minimum number of moves required to reach a specific position on an infinite number line starting from position 0. Each move i allows you to move exactly i steps, either to the left or the right.

leetcodemediummathbinary-search
LeetCode 1534 - Count Good Triplets

The problem asks us to count the number of good triplets in an integer array arr based on three difference constraints a, b, and c.

leetcodeeasyarrayenumeration
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 1840 - Maximum Building Height

This problem asks us to construct heights for n buildings arranged in a straight line while satisfying several constraints. Each building has a non-negative integer height. Building 1 must always have height 0.

leetcodehardarraymathsorting
LeetCode 245 - Shortest Word Distance III

The problem gives us an array of strings, wordsDict, and two target words, word1 and word2. We must find the minimum distance between any occurrence of these two words in the array.

leetcodemediumarraystring
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
CF 38B - Chess

We are given the positions of two chess pieces on a standard 8 × 8 board, one rook and one knight. Their starting positions are guaranteed to be safe, meaning the rook does not attack the knight and the knight does not attack the rook.

codeforcescompetitive-programmingbrute-forceimplementationmath
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 896 - Monotonic Array

This problem asks us to determine whether a given array of integers is monotonic. An array is considered monotonic if it is entirely non-decreasing (monotone increasing) or entirely non-increasing (monotone decreasing).

leetcodeeasyarray
LeetCode 488 - Zuma Game

The problem models a recursive elimination game played on a row of colored balls. The board is represented as a string where each character corresponds to a colored ball. The available colors are 'R', 'Y', 'B', 'G', and 'W'.

leetcodehardstringdynamic-programmingstackbreadth-first-searchmemoization
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 351 - Android Unlock Patterns

The problem models the Android lock screen as a 3 x 3 grid containing digits 1 through 9. A valid unlock pattern is a sequence of distinct dots that follows a special movement rule. The first rule is straightforward: each dot can only be used once in a pattern.

leetcodemediumdynamic-programmingbacktrackingbit-manipulationbitmask
CF 88A - Chord

We are given three musical notes, and the task is to classify the chord they form as either major, minor, or "strange". Notes are represented in the twelve-tone chromatic scale: C, C, D, D, E, F, F, G, G, A, B, H, and the scale is cyclic, so after H comes C again.

codeforcescompetitive-programmingbrute-forceimplementation
CF 15C - Industrial Nim

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

codeforcescompetitive-programminggames
CF 37B - Computer Game

The boss starts with max health and regenerates reg health every second. We own several scrolls. Each scroll can only be activated when the boss health is at most some percentage of the original health.

codeforcescompetitive-programminggreedyimplementation
CF 30D - King's Problem?

We have n + 1 cities. The first n cities lie on the x-axis at positions (x1, 0), (x2, 0), ..., (xn, 0). One additional city is somewhere off the axis at (x_{n+1}, y_{n+1}).

codeforcescompetitive-programminggeometrygreedy
LeetCode 1319 - Number of Operations to Make Network Connected

This problem models a computer network as an undirected graph. Each computer is a node, and each ethernet cable is an ed

leetcodemediumdepth-first-searchbreadth-first-searchunion-findgraph-theory
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 2143 - Choose Numbers From Two Arrays in Range

In this problem, we are given two arrays, nums1 and nums2, both of length n. For every index i, we must choose exactly o

leetcodehardarraydynamic-programming
LeetCode 302 - Smallest Rectangle Enclosing Black Pixels

This problem gives us a binary matrix where each cell contains either '0' or '1'. A '1' represents a black pixel, while a '0' represents a white pixel.

leetcodehardarraybinary-searchdepth-first-searchbreadth-first-searchmatrix
LeetCode 363 - Max Sum of Rectangle No Larger Than K

The problem asks us to find the rectangular submatrix whose sum is as large as possible while still being less than or equal to a given integer k. A rectangle in a matrix is any contiguous block of cells formed by choosing a range of rows and a range of columns.

leetcodehardarraybinary-searchmatrixprefix-sumordered-set
LeetCode 552 - Student Attendance Record II

The problem asks us to count how many attendance records of length n satisfy two award eligibility rules. Each attendance record is a string made up of three possible characters: - 'P' means the student was present. - 'A' means the student was absent.

leetcodeharddynamic-programming
LeetCode 366 - Find Leaves of Binary Tree

The problem asks us to repeatedly remove all leaf nodes from a binary tree and record the values removed during each round. A leaf node is a node with no left or right child.

leetcodemediumtreedepth-first-searchbinary-tree
LeetCode 476 - Number Complement

The problem asks us to compute the complement of a positive integer by flipping every bit in its binary representation. A binary complement means changing every 1 bit into 0, and every 0 bit into 1. For example, the integer 5 is represented in binary as 101.

leetcodeeasybit-manipulation
LeetCode 1197 - Minimum Knight Moves

This problem asks us to compute the minimum number of moves a knight needs to travel from the origin [0, 0] to a target position [x, y] on an infinite chessboard.

leetcodemediumbreadth-first-search
CF 5B - Center Alignment

We are given several lines of text. Every line may contain letters, digits, and spaces inside the line, but never at the beginning or end. The task is to print all lines inside a rectangular frame made of * characters.

codeforcescompetitive-programmingimplementationstrings
LeetCode 1594 - Maximum Non Negative Product in a Matrix

The problem asks us to navigate a m x n integer matrix grid from the top-left corner (0, 0) to the bottom-right corner (

leetcodemediumarraydynamic-programmingmatrix
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 1055 - Shortest Way to Form String

The problem asks us to construct the string target using the fewest possible subsequences of the string source. A subsequence preserves relative order, but characters do not need to be contiguous.

leetcodemediumtwo-pointersstringbinary-searchgreedy
LeetCode 554 - Brick Wall

The problem gives us a wall made of multiple rows of bricks. Each row is represented as an array of integers, where each integer describes the width of a brick. Every brick has height 1, and all rows together form a rectangle with the same total width.

leetcodemediumarrayhash-table
LeetCode 1284 - Minimum Number of Flips to Convert Binary Matrix to Zero Matrix

The problem asks us to transform a given binary matrix mat into a zero matrix, where all elements are 0. Each operation

leetcodehardarrayhash-tablebit-manipulationbreadth-first-searchmatrix
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 1354 - Construct Target Array With Multiple Sums

The problem asks whether it is possible to construct a given target array from an initial array arr of the same length,

leetcodehardarrayheap-(priority-queue)
CF 119C - Education Reform

We have up to 50 subjects. Each subject has three properties. The interval $[ai, bi]$ describes how many homework exercises this subject may assign. We are free to choose any value inside that interval. The value $ci$ is the subject complexity.

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

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

leetcodemediumarraybinary-indexed-treesegment-tree
LeetCode 1668 - Maximum Repeating Substring

This problem asks us to determine how many times a given string word can be repeated consecutively while still appearing

leetcodeeasystringdynamic-programmingstring-matching
CF 47E - Cannon

We have a scenario where a cannon at the origin shoots a number of balls with the same initial speed, each at a given angle. The goal is to determine where each ball lands after either hitting a vertical wall or reaching the ground.

codeforcescompetitive-programmingdata-structuresgeometrysortings
CF 135C - Zero-One

We are given a string consisting of 0, 1, and ?. Each character represents a card in a row. During the game, players alternately remove one card until only two cards remain.

codeforcescompetitive-programmingconstructive-algorithmsgamesgreedy
LeetCode 918 - Maximum Sum Circular Subarray

The problem asks for the maximum sum of a subarray in a circular array. In simpler terms, we are given a list of integers nums where the end of the list wraps around to the start.

leetcodemediumarraydivide-and-conquerdynamic-programmingqueuemonotonic-queue
CF 71B - Progress Bar

We are asked to construct a graphical progress bar as an array of squares, where each square has a saturation value. The bar has a total of n squares, and the maximum saturation is k.

codeforcescompetitive-programmingimplementationmath
LeetCode 254 - Factor Combinations

The problem asks us to generate every unique way to express a number n as a product of integers greater than 1 and less than n. A factor combination is a list of integers whose product equals n. The order inside a combination does not matter.

leetcodemediumbacktracking
LeetCode 1322 - Ads Performance

This problem asks us to calculate the Click-Through Rate, abbreviated as CTR, for every advertisement stored in the Ads

leetcodeeasydatabase
LeetCode 836 - Rectangle Overlap

The problem gives us two axis-aligned rectangles, meaning their sides are parallel to the X-axis and Y-axis. Each rectangle is represented as: Where: - (x1, y1) is the bottom-left corner - (x2, y2) is the top-right corner The task is to determine whether these two rectangles…

leetcodeeasymathgeometry
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
CF 2A - Winner

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

codeforcescompetitive-programminghashingimplementation
LeetCode 2981 - Find Longest Special Substring That Occurs Thrice I

The problem asks us to find the longest special substring that appears at least three times in the given string s. A sub

leetcodemediumhash-tablestringbinary-searchsliding-windowcounting
LeetCode 713 - Subarray Product Less Than K

The problem asks us to count how many contiguous subarrays of a given array have a product strictly smaller than a target value k. A subarray is a continuous portion of the array.

leetcodemediumarraybinary-searchsliding-windowprefix-sum
LeetCode 52 - N-Queens II

The n-queens puzzle asks us to place n queens on an n x n chessboard so that no two queens can attack each other. In chess, a queen can move horizontally, vertically, and diagonally.

leetcodehardbacktracking
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 662 - Maximum Width of Binary Tree

The problem asks us to compute the maximum width among all levels of a binary tree. The important detail is that the width is not simply the number of non-null nodes at a level.

leetcodemediumtreedepth-first-searchbreadth-first-searchbinary-tree
LeetCode 1520 - Maximum Number of Non-Overlapping Substrings

This problem asks us to select as many non-overlapping substrings as possible from a given lowercase string s, while sat

leetcodehardhash-tablestringgreedysorting
LeetCode 165 - Compare Version Numbers

This problem asks us to compare two software version numbers represented as strings. Each version consists of one or more numeric revisions separated by dots (.). For example, "1.2.10" contains three revisions: 1, 2, and 10.

leetcodemediumtwo-pointersstring
LeetCode 1638 - Count Substrings That Differ by One Character

The problem asks us to count how many pairs of substrings, one taken from s and one taken from t, differ by exactly one

leetcodemediumhash-tablestringdynamic-programmingenumeration
LeetCode 1439 - Find the Kth Smallest Sum of a Matrix With Sorted Rows

The problem requires finding the kth smallest sum obtainable by selecting exactly one element from each row of a matrix mat with sorted rows. Each row is sorted in non-decreasing order, and we must explore combinations of elements across rows to form sums.

leetcodehardarraybinary-searchheap-(priority-queue)matrix
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
CF 82A - Double Cola

Five people stand in a queue in a fixed order: Sheldon, Leonard, Penny, Rajesh, Howard. Whenever the person at the front buys a cola, that person immediately creates a copy of themselves, and both copies go to the back of the queue. The queue keeps growing forever.

codeforcescompetitive-programmingimplementationmath
CF 116B - Little Pigs and Wolves

We have a small rectangular grid where each cell is either empty, contains a pig, or contains a wolf. A wolf may eat one pig that is directly adjacent to it in one of the four cardinal directions. Once a pig is eaten, it disappears and cannot be eaten again.

codeforcescompetitive-programminggreedyimplementation
LeetCode 1393 - Capital Gain/Loss

The Stocks table records stock trading activity. Each row represents either a Buy or Sell operation for a specific stock

leetcodemediumdatabase
LeetCode 1570 - Dot Product of Two Sparse Vectors

This problem asks us to efficiently compute the dot product between two sparse vectors. A normal vector is simply an array of numbers. The dot product of two vectors is computed by multiplying corresponding elements and summing the results.

leetcodemediumarrayhash-tabletwo-pointersdesign
LeetCode 1089 - Duplicate Zeros

The problem asks us to modify a fixed-length integer array in-place by duplicating each zero and shifting the subsequent elements to the right.

leetcodeeasyarraytwo-pointers
LeetCode 1619 - Mean of Array After Removing Some Elements

The problem gives us an integer array arr and asks us to compute the average value after removing the smallest 5% and th

leetcodeeasyarraysorting