id int64 1 2k | content stringlengths 272 88.9k | title stringlengths 3 77 | title_slug stringlengths 3 79 | question_content stringlengths 230 5k | question_hints stringclasses 695
values | tag stringclasses 618
values | level stringclasses 3
values | similar_question_ids stringclasses 822
values |
|---|---|---|---|---|---|---|---|---|
1,046 | hello everyone welcome back today I'm going to be changing it up a little bit and doing the problem of the day on lead code so if you're struggling with that at all hopefully this video's solution will help this one is a Lee code easy it's probably a harderly code easy in my estimation uh let's just jump right into it ... | Last Stone Weight | max-consecutive-ones-iii | You are given an array of integers `stones` where `stones[i]` is the weight of the `ith` stone.
We are playing a game with the stones. On each turn, we choose the **heaviest two stones** and smash them together. Suppose the heaviest two stones have weights `x` and `y` with `x <= y`. The result of this smash is:
* I... | One thing's for sure, we will only flip a zero if it extends an existing window of 1s. Otherwise, there's no point in doing it, right? Think Sliding Window! Since we know this problem can be solved using the sliding window construct, we might as well focus in that direction for hints. Basically, in a given window, we c... | Array,Binary Search,Sliding Window,Prefix Sum | Medium | 340,424,485,487,2134 |
1,937 | everybody this is larry this is me going with q3 of the weekly contest 250 maximum number of points of course hit the like button to subscribe and join me in discord especially if you're doing these contests um a lot of smart people go over the contest right afterwards in my discord so you know you're into that kind of... | Maximum Number of Points with Cost | maximize-the-beauty-of-the-garden | You are given an `m x n` integer matrix `points` (**0-indexed**). Starting with `0` points, you want to **maximize** the number of points you can get from the matrix.
To gain points, you must pick one cell in **each row**. Picking the cell at coordinates `(r, c)` will **add** `points[r][c]` to your score.
However, yo... | Consider every possible beauty and its first and last index in flowers. Remove all flowers with negative beauties within those indices. | Array,Greedy,Prefix Sum | Hard | null |
441 | Jhaal Hello everyone welcome to new video in this video by going to discuss and the problems from its core key problem this problem and for 2nd problem statement problem share and subscribe this problem what problem where did it go and we know that we With the help of this number, we will be able to subscribe in this m... | Arranging Coins | arranging-coins | You have `n` coins and you want to build a staircase with these coins. The staircase consists of `k` rows where the `ith` row has exactly `i` coins. The last row of the staircase **may be** incomplete.
Given the integer `n`, return _the number of **complete rows** of the staircase you will build_.
**Example 1:**
**I... | null | Math,Binary Search | Easy | null |
1,859 | foreign problem and the problem's name is sorting the sentence in this question we are given a string array called sentence which contains a list of words separated by a single space and each word consists of lowercase and uppercase English letters and at the end of the word there is a digit appended which is part of t... | Sorting the Sentence | change-minimum-characters-to-satisfy-one-of-three-conditions | A **sentence** is a list of words that are separated by a single space with no leading or trailing spaces. Each word consists of lowercase and uppercase English letters.
A sentence can be **shuffled** by appending the **1-indexed word position** to each word then rearranging the words in the sentence.
* For example... | Iterate on each letter in the alphabet, and check the smallest number of operations needed to make it one of the following: the largest letter in a and smaller than the smallest one in b, vice versa, or let a and b consist only of this letter. For the first 2 conditions, take care that you can only change characters to... | Hash Table,String,Counting,Prefix Sum | Medium | null |
220 | Hello Everybody Welcome To My Channel Let's All The Problem Contents Duplicate 300 Pages For Your Problem Of Content 1112 Problem Of The Tourist Places Near A Difference Between Us And Subscribe Difference Between Enjoy Decide Most K Example 1231 Spent Show The Difference Between The Like 1230 possible to 10000 possibl... | Contains Duplicate III | contains-duplicate-iii | You are given an integer array `nums` and two integers `indexDiff` and `valueDiff`.
Find a pair of indices `(i, j)` such that:
* `i != j`,
* `abs(i - j) <= indexDiff`.
* `abs(nums[i] - nums[j]) <= valueDiff`, and
Return `true` _if such pair exists or_ `false` _otherwise_.
**Example 1:**
**Input:** nums = \[1... | Time complexity O(n logk) - This will give an indication that sorting is involved for k elements. Use already existing state to evaluate next state - Like, a set of k sorted numbers are only needed to be tracked. When we are processing the next number in array, then we can utilize the existing sorted state and it is... | Array,Sliding Window,Sorting,Bucket Sort,Ordered Set | Medium | 217,219 |
152 | welcome back today the problem we'll be looking at is maximum product sub array given in integer array nums find a contiguous non-empty subarray find a contiguous non-empty subarray find a contiguous non-empty subarray within the array has the largest product and return that the test cases will fit into a 32-bit the te... | Maximum Product Subarray | maximum-product-subarray | Given an integer array `nums`, find a subarray that has the largest product, and return _the product_.
The test cases are generated so that the answer will fit in a **32-bit** integer.
**Example 1:**
**Input:** nums = \[2,3,-2,4\]
**Output:** 6
**Explanation:** \[2,3\] has the largest product 6.
**Example 2:**
**I... | null | Array,Dynamic Programming | Medium | 53,198,238,628,713 |
1,750 | hello and welcome to another video in this video we're going to be working on minimum length of a string after deleting similar ends and in the problem you have a string consisting of a b and c you're asked to apply the following operations any number of times pick a non-empty prefix from s where all the non-empty pref... | Minimum Length of String After Deleting Similar Ends | check-if-two-expression-trees-are-equivalent | Given a string `s` consisting only of characters `'a'`, `'b'`, and `'c'`. You are asked to apply the following algorithm on the string any number of times:
1. Pick a **non-empty** prefix from the string `s` where all the characters in the prefix are equal.
2. Pick a **non-empty** suffix from the string `s` where all... | Count for each variable how many times it appeared in the first tree. Do the same for the second tree and check if the count is the same for both tree. | Tree,Depth-First Search,Binary Tree | Medium | 1736 |
452 | hello so there's talk about a minimum number of Arrow to purse balloon so this is definitely straightforward description what you have to do is return the minimum number of error that must be shot to burst all so all those of balloon there must be the case so have to be the minimum so the idea is actually pretty straig... | Minimum Number of Arrows to Burst Balloons | minimum-number-of-arrows-to-burst-balloons | There are some spherical balloons taped onto a flat wall that represents the XY-plane. The balloons are represented as a 2D integer array `points` where `points[i] = [xstart, xend]` denotes a balloon whose **horizontal diameter** stretches between `xstart` and `xend`. You do not know the exact y-coordinates of the ball... | null | Array,Greedy,Sorting | Medium | 253,435 |
89 | Hello everyone welcome back to my channel I am going to list myself for medical, show problem in July challenge, gang rape court, what is this problem, what to do, this problem, we have to read the end with great code sequence, if we want to do an admit card then in this Total tourists will go up and anti okay how like... | Gray Code | gray-code | An **n-bit gray code sequence** is a sequence of `2n` integers where:
* Every integer is in the **inclusive** range `[0, 2n - 1]`,
* The first integer is `0`,
* An integer appears **no more than once** in the sequence,
* The binary representation of every pair of **adjacent** integers differs by **exactly one ... | null | Math,Backtracking,Bit Manipulation | Medium | 717 |
292 | all right so let's talk about nip game so is a game that you play in the childhood right so basically like you either remove one or three stone and then you can win basically easily so imagine l equal to one so if you take another one stone and you win so angle two is gonna win three and then you still win but how abou... | Nim Game | nim-game | You are playing the following Nim Game with your friend:
* Initially, there is a heap of stones on the table.
* You and your friend will alternate taking turns, and **you go first**.
* On each turn, the person whose turn it is will remove 1 to 3 stones from the heap.
* The one who removes the last stone is the... | If there are 5 stones in the heap, could you figure out a way to remove the stones such that you will always be the winner? | Math,Brainteaser,Game Theory | Easy | 294 |
1,838 | hello everyone this is official zendo today i'm going to talk lead code 1838 frequency of the most frequent element if you like my videos please subscribe to my channel and you can find the complete performance leads in video description below which includes all the purpose categories and its rebounding videos let's lo... | Frequency of the Most Frequent Element | number-of-distinct-substrings-in-a-string | The **frequency** of an element is the number of times it occurs in an array.
You are given an integer array `nums` and an integer `k`. In one operation, you can choose an index of `nums` and increment the element at that index by `1`.
Return _the **maximum possible frequency** of an element after performing **at mos... | Calculate the prefix hashing array for s. Use the prefix hashing array to calculate the hashing value of each substring. Compare the hashing values to determine the unique substrings. There could be collisions if you use hashing, what about double hashing. | String,Trie,Rolling Hash,Suffix Array,Hash Function | Medium | null |
442 | hello today i will do a lead code problem find all duplicates in an array this problem can be a little tricky but i will go through all the steps you could take to arrive at the solution the problem statement is as follows given an array of integers with values greater or equal to 1 and less than or equal to n with n b... | Find All Duplicates in an Array | find-all-duplicates-in-an-array | Given an integer array `nums` of length `n` where all the integers of `nums` are in the range `[1, n]` and each integer appears **once** or **twice**, return _an array of all the integers that appears **twice**_.
You must write an algorithm that runs in `O(n)` time and uses only constant extra space.
**Example 1:**
... | null | Array,Hash Table | Medium | 448 |
993 | hello everyone welcome to quartus camp we are at 18th day of october elite code challenge and the problem we are going to cover in this video is cousins or in a binary tree so before getting into today's problem i did not post the previous day's problem because we have them covered in our channel already so if you're l... | Cousins in Binary Tree | tallest-billboard | Given the `root` of a binary tree with unique values and the values of two different nodes of the tree `x` and `y`, return `true` _if the nodes corresponding to the values_ `x` _and_ `y` _in the tree are **cousins**, or_ `false` _otherwise._
Two nodes of a binary tree are **cousins** if they have the same depth with d... | null | Array,Dynamic Programming | Hard | 2162 |
52 | hey everybody in this video we want to solve problem 52 on daily code challenge and queens 2. so in this problem uh we are supposed to place n queens in an n by n chessboard table such that no two queens that have each other so this is this problem is a more general version of an eighth uh queen problem uh but such tha... | N-Queens II | n-queens-ii | The **n-queens** puzzle is the problem of placing `n` queens on an `n x n` chessboard such that no two queens attack each other.
Given an integer `n`, return _the number of distinct solutions to the **n-queens puzzle**_.
**Example 1:**
**Input:** n = 4
**Output:** 2
**Explanation:** There are two distinct solutions ... | null | Backtracking | Hard | 51 |
116 | all right guys welcome back to 14 days sunday plus 2 o'clock i'll go asian day the last problem for today is medium difficulty it's the first medium difficulty question for bfs or devs so population next to rise pointers in each node we are given a perfect spinal degree where all leaves are on the same level and every ... | Populating Next Right Pointers in Each Node | populating-next-right-pointers-in-each-node | You are given a **perfect binary tree** where all leaves are on the same level, and every parent has two children. The binary tree has the following definition:
struct Node {
int val;
Node \*left;
Node \*right;
Node \*next;
}
Populate each next pointer to point to its next right node. If there is no next righ... | null | Linked List,Tree,Depth-First Search,Breadth-First Search,Binary Tree | Medium | 117,199 |
91 | hey everyone welcome back today we are going to solve problem number 91 decode way first we will see the explanation of the problem statement then the logic on the code now let's diab into the solution so in this problem we are given a string which has digits right so we need to decode this string to alphabets right so... | Decode Ways | decode-ways | A message containing letters from `A-Z` can be **encoded** into numbers using the following mapping:
'A' -> "1 "
'B' -> "2 "
...
'Z' -> "26 "
To **decode** an encoded message, all the digits must be grouped then mapped back into letters using the reverse of the mapping above (there may be multiple ways). For examp... | null | String,Dynamic Programming | Medium | 639,2091 |
70 | hey guys welcome back to the channel today we're going to be solving these code 70 which is climbing stairs and this box is an easy problem to be honest i want to say it's that easy however i'll say this is one of my favorite problems only code okay so feel free to pause the video just to read through what the problem ... | Climbing Stairs | climbing-stairs | You are climbing a staircase. It takes `n` steps to reach the top.
Each time you can either climb `1` or `2` steps. In how many distinct ways can you climb to the top?
**Example 1:**
**Input:** n = 2
**Output:** 2
**Explanation:** There are two ways to climb to the top.
1. 1 step + 1 step
2. 2 steps
**Example 2:**
... | To reach nth step, what could have been your previous steps? (Think about the step sizes) | Math,Dynamic Programming,Memoization | Easy | 747,1013,1236 |
1,704 | hello guys welcome back to my Channel today we're going to solve this leate code question which is uh determine if a string halves are alike uh okay let's solve this question in this question we are given a string s of even length split the string into two halves of equal lengths and let a be the first half and B be th... | Determine if String Halves Are Alike | special-positions-in-a-binary-matrix | You are given a string `s` of even length. Split this string into two halves of equal lengths, and let `a` be the first half and `b` be the second half.
Two strings are **alike** if they have the same number of vowels (`'a'`, `'e'`, `'i'`, `'o'`, `'u'`, `'A'`, `'E'`, `'I'`, `'O'`, `'U'`). Notice that `s` contains uppe... | Keep track of 1s in each row and in each column. Then while iterating over matrix, if the current position is 1 and current row as well as current column contains exactly one occurrence of 1. | Array,Matrix | Easy | null |
70 | hello everyone in this video i'll be explaining the climax test problem so this is a lead code easy problem and it's asked in interviews of big companies like google and microsoft so let me explain the question to you so you are climbing a staircase it takes n steps to reach the top each time you can either climb one s... | Climbing Stairs | climbing-stairs | You are climbing a staircase. It takes `n` steps to reach the top.
Each time you can either climb `1` or `2` steps. In how many distinct ways can you climb to the top?
**Example 1:**
**Input:** n = 2
**Output:** 2
**Explanation:** There are two ways to climb to the top.
1. 1 step + 1 step
2. 2 steps
**Example 2:**
... | To reach nth step, what could have been your previous steps? (Think about the step sizes) | Math,Dynamic Programming,Memoization | Easy | 747,1013,1236 |
799 | hey everybody this is larry this is day fourth oh i'm after midnight until march leco daily challenge hit the like button it's a subscriber and driving discord let me know what you think about this prom um yeah there's a lot of things going on in the world right now hope everything's okay i hope everyone's just you kno... | Champagne Tower | minimum-distance-between-bst-nodes | We stack glasses in a pyramid, where the **first** row has `1` glass, the **second** row has `2` glasses, and so on until the 100th row. Each glass holds one cup of champagne.
Then, some champagne is poured into the first glass at the top. When the topmost glass is full, any excess liquid poured will fall equally to t... | null | Tree,Depth-First Search,Breadth-First Search,Binary Search Tree,Binary Tree | Easy | 94 |
343 | Hi Everyone Welcome Back to Today's Video So our question today is integer break and in this question we are told that we will be given an n value which we have to break into positive integers of the case and that is k. That minimum should be two, okay and we have to choose the values of them in such a way that our c... | Integer Break | integer-break | Given an integer `n`, break it into the sum of `k` **positive integers**, where `k >= 2`, and maximize the product of those integers.
Return _the maximum product you can get_.
**Example 1:**
**Input:** n = 2
**Output:** 1
**Explanation:** 2 = 1 + 1, 1 \* 1 = 1.
**Example 2:**
**Input:** n = 10
**Output:** 36
**Exp... | There is a simple O(n) solution to this problem. You may check the breaking results of n ranging from 7 to 10 to discover the regularities. | Math,Dynamic Programming | Medium | 1936 |
166 | are you stuck on a coding challenge don't worry we've got your back let's dive in and solve the fraction to recurring decimal problem together this problem statement is asking to take in two integers as input which represent the numerator and denominator of a fraction the goal is to return the fraction in string format... | Fraction to Recurring Decimal | fraction-to-recurring-decimal | Given two integers representing the `numerator` and `denominator` of a fraction, return _the fraction in string format_.
If the fractional part is repeating, enclose the repeating part in parentheses.
If multiple answers are possible, return **any of them**.
It is **guaranteed** that the length of the answer string ... | No scary math, just apply elementary math knowledge. Still remember how to perform a long division? Try a long division on 4/9, the repeating part is obvious. Now try 4/333. Do you see a pattern? Notice that once the remainder starts repeating, so does the divided result. Be wary of edge cases! List out as many test ca... | Hash Table,Math,String | Medium | null |
792 | hey everybody this is larry this is day 20 of the july legal day challenge oh no free points today coins hit the like button hit the subscribe button join me on discord let me know what you think about today's problem number of matching subsequences hopefully today's implementation will be a little bit better than yest... | Number of Matching Subsequences | binary-search | Given a string `s` and an array of strings `words`, return _the number of_ `words[i]` _that is a subsequence of_ `s`.
A **subsequence** of a string is a new string generated from the original string with some characters (can be none) deleted without changing the relative order of the remaining characters.
* For exa... | null | Array,Binary Search | Easy | 786 |
1,696 | hello fairweather friends it is the season christmas coming up on us let's not be naughty let's be good boys and girls and solve some algorithmical problems proceeding with this going to our favorite website favorite website favorite website and opening problem 1696 jump game 6 96 is here you are given zero indexed int... | Jump Game VI | strange-printer-ii | You are given a **0-indexed** integer array `nums` and an integer `k`.
You are initially standing at index `0`. In one move, you can jump at most `k` steps forward without going outside the boundaries of the array. That is, you can jump from index `i` to any index in the range `[i + 1, min(n - 1, i + k)]` **inclusive*... | Try thinking in reverse. Given the grid, how can you tell if a colour was painted last? | Array,Graph,Topological Sort,Matrix | Hard | 664 |
363 | hey what's up guys this is sean here so today i want to talk about this 363 max um off rectangle no larger than k i think this is a great problem it's a hard one and yeah so you're given like a non-empty 2d matrix 2d non-empty 2d matrix 2d non-empty 2d matrix and an integer k and you need to find the max sum of a recta... | Max Sum of Rectangle No Larger Than K | max-sum-of-rectangle-no-larger-than-k | Given an `m x n` matrix `matrix` and an integer `k`, return _the max sum of a rectangle in the matrix such that its sum is no larger than_ `k`.
It is **guaranteed** that there will be a rectangle with a sum no larger than `k`.
**Example 1:**
**Input:** matrix = \[\[1,0,1\],\[0,-2,3\]\], k = 2
**Output:** 2
**Explana... | null | Array,Binary Search,Dynamic Programming,Matrix,Ordered Set | Hard | null |
399 | Hello gas welcome to me YouTube channel so today we are going to talk about the problem of leadcoat so this is the problem evaluate division okay this is a medium level problem so let us see how to solve it so I will show a little screen here dear and Variable pairs equation okay this is our equation real number values... | Evaluate Division | evaluate-division | You are given an array of variable pairs `equations` and an array of real numbers `values`, where `equations[i] = [Ai, Bi]` and `values[i]` represent the equation `Ai / Bi = values[i]`. Each `Ai` or `Bi` is a string that represents a single variable.
You are also given some `queries`, where `queries[j] = [Cj, Dj]` rep... | Do you recognize this as a graph problem? | Array,Depth-First Search,Breadth-First Search,Union Find,Graph,Shortest Path | Medium | null |
945 | hey what's up guys uh this is sean here so today uh let's take a look at number uh lead code number 945 minimum increment to make already unique right so the description is pretty short basically you're given like array of integers and so a move means that you need to basically choose any number and increase increment ... | Minimum Increment to Make Array Unique | snakes-and-ladders | You are given an integer array `nums`. In one move, you can pick an index `i` where `0 <= i < nums.length` and increment `nums[i]` by `1`.
Return _the minimum number of moves to make every value in_ `nums` _**unique**_.
The test cases are generated so that the answer fits in a 32-bit integer.
**Example 1:**
**Input... | null | Array,Breadth-First Search,Matrix | Medium | null |
68 | hello guys let's discuss a heart problem from google it's known as text justification so we are given an array of string words and the width max width format text such that each line has exactly max width characters and is fully left and right justified so we are given a list of the words for example this is an example... | Text Justification | text-justification | Given an array of strings `words` and a width `maxWidth`, format the text such that each line has exactly `maxWidth` characters and is fully (left and right) justified.
You should pack your words in a greedy approach; that is, pack as many words as you can in each line. Pad extra spaces `' '` when necessary so that ea... | null | Array,String,Simulation | Hard | 1714,2260 |
733 | welcome ladies and gentlemen boys and girls today i'm going to solve another coolest question this is one of the coolest question which is floodplain basically what's the third place now the first question arise in your mind okay so let me explain what it's flat with so basically flood fill is also called seed field ok... | Flood Fill | flood-fill | An image is represented by an `m x n` integer grid `image` where `image[i][j]` represents the pixel value of the image.
You are also given three integers `sr`, `sc`, and `color`. You should perform a **flood fill** on the image starting from the pixel `image[sr][sc]`.
To perform a **flood fill**, consider the startin... | Write a recursive function that paints the pixel if it's the correct color, then recurses on neighboring pixels. | Array,Depth-First Search,Breadth-First Search,Matrix | Easy | 463 |
3 | hello Dean hey Granada is a toleration lake called Asante longest a substring with other repeating characters theologically got the food try ginger root search on the Papa huntin full character dad's truck nah man you know the focaccia you know two pointers like a sliding window Gahanna oh no Aayla your job to go to Sh... | Longest Substring Without Repeating Characters | longest-substring-without-repeating-characters | Given a string `s`, find the length of the **longest** **substring** without repeating characters.
**Example 1:**
**Input:** s = "abcabcbb "
**Output:** 3
**Explanation:** The answer is "abc ", with the length of 3.
**Example 2:**
**Input:** s = "bbbbb "
**Output:** 1
**Explanation:** The answer is "b ", with t... | null | Hash Table,String,Sliding Window | Medium | 159,340,1034,1813,2209 |
383 | Hello Guys Welcome Back To Tech To Join This Video Will See The Answer Note Problem Wishes From List To Day Three Of Them A Challenge So Let's Look At The Problems The Amazing Notes And Letters From All The Writer Of The Truth Can Be Constructed From The President Can Only Be Used Once Saw You Majumdar String Contents ... | Ransom Note | ransom-note | Given two strings `ransomNote` and `magazine`, return `true` _if_ `ransomNote` _can be constructed by using the letters from_ `magazine` _and_ `false` _otherwise_.
Each letter in `magazine` can only be used once in `ransomNote`.
**Example 1:**
**Input:** ransomNote = "a", magazine = "b"
**Output:** false
**Example ... | null | Hash Table,String,Counting | Easy | 691 |
203 | hi today I will talk about problem number 203 remove linked list elements at each code so the question says remove all elements from a linked list of integers that have value Val so the input example given is 1 2 6 3 4 5 6 and the value is 6 so the question is basically asking to remove the number 6 from this list such... | Remove Linked List Elements | remove-linked-list-elements | Given the `head` of a linked list and an integer `val`, remove all the nodes of the linked list that has `Node.val == val`, and return _the new head_.
**Example 1:**
**Input:** head = \[1,2,6,3,4,5,6\], val = 6
**Output:** \[1,2,3,4,5\]
**Example 2:**
**Input:** head = \[\], val = 1
**Output:** \[\]
**Example 3:**... | null | Linked List,Recursion | Easy | 27,237,2216 |
1,909 | hey YouTube hey tube welcome back today I have this problem it's called remove one element to make the array strictly increasing that we have given a zero indexed integral array nums called nums return true if it can be made strictly increasing after removing exactly one element or false otherwise in the array is uh if... | Remove One Element to Make the Array Strictly Increasing | buildings-with-an-ocean-view | Given a **0-indexed** integer array `nums`, return `true` _if it can be made **strictly increasing** after removing **exactly one** element, or_ `false` _otherwise. If the array is already strictly increasing, return_ `true`.
The array `nums` is **strictly increasing** if `nums[i - 1] < nums[i]` for each index `(1 <= ... | You can traverse the buildings from the nearest to the ocean to the furthest. Keep with you the maximum to the right while traversing to determine if you can see the ocean or not. | Array,Stack,Monotonic Stack | Medium | 1305 |
1,460 | hey everybody this is Larry I'm doing this problem as part of a contest so you're gonna watch me live as I go through my daughter's I'm coding they've been explanation near the end and for more context they'll be a link below on this actual screen cats of the contest how did you do let me know you do hit the like butto... | Make Two Arrays Equal by Reversing Subarrays | number-of-substrings-containing-all-three-characters | You are given two integer arrays of equal length `target` and `arr`. In one step, you can select any **non-empty subarray** of `arr` and reverse it. You are allowed to make any number of steps.
Return `true` _if you can make_ `arr` _equal to_ `target` _or_ `false` _otherwise_.
**Example 1:**
**Input:** target = \[1,... | For each position we simply need to find the first occurrence of a/b/c on or after this position. So we can pre-compute three link-list of indices of each a, b, and c. | Hash Table,String,Sliding Window | Medium | 2187 |
858 | hey everybody this is larry i'm today i'm going to do a little bit differently because um i've already done this problem before i'm going to try to explain the solution really quickly really shortly and then you can watch me try to explain the explanation much slower and doing it live more so if the solution is too fas... | Mirror Reflection | masking-personal-information | There is a special square room with mirrors on each of the four walls. Except for the southwest corner, there are receptors on each of the remaining corners, numbered `0`, `1`, and `2`.
The square room has walls of length `p` and a laser ray from the southwest corner first meets the east wall at a distance `q` from th... | null | String | Medium | null |
709 | in both language has this I think okay well maybe it's a good practice but that's why this is the easy way today did something change did they actually tell you whether the things are the same that's new it haven't done this in like a week and a half so because they used to just feel like now it's completed wherever no... | To Lower Case | to-lower-case | Given a string `s`, return _the string after replacing every uppercase letter with the same lowercase letter_.
**Example 1:**
**Input:** s = "Hello "
**Output:** "hello "
**Example 2:**
**Input:** s = "here "
**Output:** "here "
**Example 3:**
**Input:** s = "LOVELY "
**Output:** "lovely "
**Constraints:**... | null | null | Easy | null |
1,171 | Hello everyone I am Ri Sharma and today's our TD is remove zero sum cute note is a medium level problem so first let's see our problem statement then see its problem statement is given the head or you have a question and I have given its head that's it The essence of the song is to repeatedly delete the cut sequence of... | Remove Zero Sum Consecutive Nodes from Linked List | shortest-path-in-binary-matrix | Given the `head` of a linked list, we repeatedly delete consecutive sequences of nodes that sum to `0` until there are no such sequences.
After doing so, return the head of the final linked list. You may return any such answer.
(Note that in the examples below, all sequences are serializations of `ListNode` objects.)... | Do a breadth first search to find the shortest path. | Array,Breadth-First Search,Matrix | Medium | null |
16 | hello everyone let's look at three sum closest the problem statement is we are giving an array of n integers and the target integer and then we need to find three integers in the array such that the sum is closest to target then we return the sum of three integers an example here is the input array is negative one two ... | 3Sum Closest | 3sum-closest | Given an integer array `nums` of length `n` and an integer `target`, find three integers in `nums` such that the sum is closest to `target`.
Return _the sum of the three integers_.
You may assume that each input would have exactly one solution.
**Example 1:**
**Input:** nums = \[-1,2,1,-4\], target = 1
**Output:** ... | null | Array,Two Pointers,Sorting | Medium | 15,259 |
333 | Hello friends welcome to my channel let's have a look at problem 333 largest binary search tree surgery in this video we are going to share two treatments for this problem the first one is more robust and with some redundancy and the second one is more succinct first I'll read through the statement to digest the proble... | Largest BST Subtree | largest-bst-subtree | Given the root of a binary tree, find the largest subtree, which is also a Binary Search Tree (BST), where the largest means subtree has the largest number of nodes.
A **Binary Search Tree (BST)** is a tree in which all the nodes follow the below-mentioned properties:
* The left subtree values are less than the val... | You can recursively use algorithm similar to 98. Validate Binary Search Tree at each node of the tree, which will result in O(nlogn) time complexity. | Dynamic Programming,Tree,Depth-First Search,Binary Search Tree,Binary Tree | Medium | null |
554 | welcome to april's leco challenge today's problem is brick wall there is a brick wall in front of you the wall is rectangular and has several rows of bricks the bricks have the same height but different widths you want to draw a vertical line from the top to the bottom and cross the least bricks now the list of the bri... | Brick Wall | brick-wall | There is a rectangular brick wall in front of you with `n` rows of bricks. The `ith` row has some number of bricks each of the same height (i.e., one unit) but they can be of different widths. The total width of each row is the same.
Draw a vertical line from the top to the bottom and cross the least bricks. If your l... | null | Array,Hash Table | Medium | 2322 |
1,203 | hey what's up guys chung here so today let's take a look at this hard lead called problem number one thousand two hundred and three stored items by groups respecting dependencies okay i think the name of the problem is a little bit confusing right so let's take a look what's this problem it's about so they're like n it... | Sort Items by Groups Respecting Dependencies | print-in-order | There are `n` items each belonging to zero or one of `m` groups where `group[i]` is the group that the `i`\-th item belongs to and it's equal to `-1` if the `i`\-th item belongs to no group. The items and the groups are zero indexed. A group can have no item belonging to it.
Return a sorted list of the items such that... | null | Concurrency | Easy | 1187 |
746 | hello everyone welcome to quartus camp we are at 7th day of june lead code challenge and the problem we are going to cover in this video is minimum cost climbing stairs so the input given here is an integer array cost which represents the cost to take each steps and we have to return the minimum cost to reach the top o... | Min Cost Climbing Stairs | prefix-and-suffix-search | You are given an integer array `cost` where `cost[i]` is the cost of `ith` step on a staircase. Once you pay the cost, you can either climb one or two steps.
You can either start from the step with index `0`, or the step with index `1`.
Return _the minimum cost to reach the top of the floor_.
**Example 1:**
**Input... | For a word like "test", consider "#test", "t#test", "st#test", "est#test", "test#test". Then if we have a query like prefix = "te", suffix = "t", we can find it by searching for something we've inserted starting with "t#te". | String,Design,Trie | Hard | 211 |
1,870 | hello everyone here is when Amazon welcome back uh today we have an exciting coding challenge to solve it's all about figuring out the minimum speed you need to reach your office on time given some constraints uh so uh sounds interesting so let's dive in here's the problem statement you have a floating Point number hou... | Minimum Speed to Arrive on Time | minimum-speed-to-arrive-on-time | You are given a floating-point number `hour`, representing the amount of time you have to reach the office. To commute to the office, you must take `n` trains in sequential order. You are also given an integer array `dist` of length `n`, where `dist[i]` describes the distance (in kilometers) of the `ith` train ride.
E... | null | null | Medium | null |
560 | Hello guys welcome back to years and this video will see 10 years 12 time course problem wishes from list to day 2250 discarding challenge solve this problem can also be name discount number of marriage religious educational his so let's look at the problem statement latest Cigarette Wear Gravity Elements and Where Req... | Subarray Sum Equals K | subarray-sum-equals-k | Given an array of integers `nums` and an integer `k`, return _the total number of subarrays whose sum equals to_ `k`.
A subarray is a contiguous **non-empty** sequence of elements within an array.
**Example 1:**
**Input:** nums = \[1,1,1\], k = 2
**Output:** 2
**Example 2:**
**Input:** nums = \[1,2,3\], k = 3
**Ou... | Will Brute force work here? Try to optimize it. Can we optimize it by using some extra space? What about storing sum frequencies in a hash table? Will it be useful? sum(i,j)=sum(0,j)-sum(0,i), where sum(i,j) represents the sum of all the elements from index i to j-1.
Can we use this property to optimize it. | Array,Hash Table,Prefix Sum | Medium | 1,523,713,724,1016,1776,2211,2369 |
1,679 | hey everybody this is larry this is day 18 of the leeco daily challenge hit the like button hit the subscribe button join me on discord let me know what you think about today's prom max number of k-sum pairs uh max number of k-sum pairs uh max number of k-sum pairs uh yeah so i usually uh read and try to solve these pr... | Max Number of K-Sum Pairs | shortest-subarray-to-be-removed-to-make-array-sorted | You are given an integer array `nums` and an integer `k`.
In one operation, you can pick two numbers from the array whose sum equals `k` and remove them from the array.
Return _the maximum number of operations you can perform on the array_.
**Example 1:**
**Input:** nums = \[1,2,3,4\], k = 5
**Output:** 2
**Explana... | The key is to find the longest non-decreasing subarray starting with the first element or ending with the last element, respectively. After removing some subarray, the result is the concatenation of a sorted prefix and a sorted suffix, where the last element of the prefix is smaller than the first element of the suffix... | Array,Two Pointers,Binary Search,Stack,Monotonic Stack | Medium | null |
491 | Peace be upon you, my dear friend. How are you? Today, God willing, we will solve the problem together. If you have not tried the problem, then you must first go and try to solve it yourself before you see the solution. Give yourself a chance to think about the problem and try it, and then keep returning to the video. ... | Non-decreasing Subsequences | increasing-subsequences | Given an integer array `nums`, return _all the different possible non-decreasing subsequences of the given array with at least two elements_. You may return the answer in **any order**.
**Example 1:**
**Input:** nums = \[4,6,7,7\]
**Output:** \[\[4,6\],\[4,6,7\],\[4,6,7,7\],\[4,7\],\[4,7,7\],\[6,7\],\[6,7,7\],\[7,7\]... | null | Array,Hash Table,Backtracking,Bit Manipulation | Medium | 646 |
766 | hey yo what's up my little coders let me show you in this tutorial how to solve the little question number 766 dopplex matrix basically we are given an m by n matrix and we need to return if this matrix is stoplets or not and the matrix is stoplets if every diagonal from top left to bottom right has the same elements h... | Toeplitz Matrix | flatten-a-multilevel-doubly-linked-list | Given an `m x n` `matrix`, return _`true` if the matrix is Toeplitz. Otherwise, return `false`._
A matrix is **Toeplitz** if every diagonal from top-left to bottom-right has the same elements.
**Example 1:**
**Input:** matrix = \[\[1,2,3,4\],\[5,1,2,3\],\[9,5,1,2\]\]
**Output:** true
**Explanation:**
In the above gr... | null | Linked List,Depth-First Search,Doubly-Linked List | Medium | 114,1796 |
35 | binary search is a concept that has a lot of applications one such problem on lead code search insert position explores some of this domain you are given a array of sorted integers and a target element if you can find this target element in the array you need to return its index otherwise you need to return the index w... | Search Insert Position | search-insert-position | Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.
You must write an algorithm with `O(log n)` runtime complexity.
**Example 1:**
**Input:** nums = \[1,3,5,6\], target = 5
**Output:** 2
**Exa... | null | Array,Binary Search | Easy | 278 |
1,187 | Hai Gas Welcome To Me Youtube Channel Today We Are Going To Solve Date Daily Need Code Challenge And Today's Problem Name Is Make It Exactly Increasing Life You Add Integers And Errors To Written Minimum Number Of Operations Needed You Make Erawan Strictly Impressing In One Operation You can choose you in this is one i... | Make Array Strictly Increasing | print-foobar-alternately | Given two integer arrays `arr1` and `arr2`, return the minimum number of operations (possibly zero) needed to make `arr1` strictly increasing.
In one operation, you can choose two indices `0 <= i < arr1.length` and `0 <= j < arr2.length` and do the assignment `arr1[i] = arr2[j]`.
If there is no way to make `arr1` str... | null | Concurrency | Medium | 1203,1216 |
448 | foreign in the range is from 1 to n and we have to return an array of all in pages in Arrangement when they do not appear in the given area so if you see the example the number ranging from 1 to 8 are given so 1 to 3 4 is present okay 5 is not present so that is my number so they can be have duplicates and they are non... | Find All Numbers Disappeared in an Array | find-all-numbers-disappeared-in-an-array | Given an array `nums` of `n` integers where `nums[i]` is in the range `[1, n]`, return _an array of all the integers in the range_ `[1, n]` _that do not appear in_ `nums`.
**Example 1:**
**Input:** nums = \[4,3,2,7,8,2,3,1\]
**Output:** \[5,6\]
**Example 2:**
**Input:** nums = \[1,1\]
**Output:** \[2\]
**Constrain... | This is a really easy problem if you decide to use additional memory. For those trying to write an initial solution using additional memory, think counters! However, the trick really is to not use any additional space than what is already available to use. Sometimes, multiple passes over the input array help find the s... | Array,Hash Table | Easy | 41,442,2107,2305 |
93 | hello everyone welcome to Elko simplified let's solve today's lead code challenge that is restore IP addresses in this problem we are given a string as that contains only digits and we have to return all the possible valid IP addresses that can be formed by inserting dots into s so let me explain you we are given a str... | Restore IP Addresses | restore-ip-addresses | A **valid IP address** consists of exactly four integers separated by single dots. Each integer is between `0` and `255` (**inclusive**) and cannot have leading zeros.
* For example, `"0.1.2.201 "` and `"192.168.1.1 "` are **valid** IP addresses, but `"0.011.255.245 "`, `"192.168.1.312 "` and `"192.168@1.1 "` are **... | null | String,Backtracking | Medium | 752 |
293 | hey everybody this is Larry this is me doing week one of the premium weekly premium challenge in February hit the like button hit the Subscribe button join me on Discord let me know what you think about this one this is a Yeezy one according to them 293 Flip Game premium um I'm trying to think what I do maybe I won't d... | Flip Game | flip-game | You are playing a Flip Game with your friend.
You are given a string `currentState` that contains only `'+'` and `'-'`. You and your friend take turns to flip **two consecutive** `"++ "` into `"-- "`. The game ends when a person can no longer make a move, and therefore the other person will be the winner.
Return all ... | null | String | Easy | 294 |
1,913 | okay let's try to solve L code problem number 19113 maximum product difference between two pairs now the product difference between two pairs a b and c d is defined as a into B minus C into D given an integer array nums choose any four distance indexes like WX y z such that the product difference between Pairs of nums ... | Maximum Product Difference Between Two Pairs | make-the-xor-of-all-segments-equal-to-zero | The **product difference** between two pairs `(a, b)` and `(c, d)` is defined as `(a * b) - (c * d)`.
* For example, the product difference between `(5, 6)` and `(2, 7)` is `(5 * 6) - (2 * 7) = 16`.
Given an integer array `nums`, choose four **distinct** indices `w`, `x`, `y`, and `z` such that the **product differ... | Let's note that for the XOR of all segments with size K to be equal to zeros, nums[i] has to be equal to nums[i+k] Basically, we need to make the first K elements have XOR = 0 and then modify them. | Array,Dynamic Programming,Bit Manipulation | Hard | null |
456 | Hello Hi Everyone Welcome To My Channel Today Problems 132 Pattern For Giving Energy Of Institutions Now 132 Pattern Subscribe I Challenge Se Zinc And Subscribe 4,320 Solution To This Subscribe 4,320 Solution To This Subscribe 4,320 Solution To This Problem Just A Great Life In Stolon Oil Is Equal To One To Neo4j Equal... | 132 Pattern | 132-pattern | Given an array of `n` integers `nums`, a **132 pattern** is a subsequence of three integers `nums[i]`, `nums[j]` and `nums[k]` such that `i < j < k` and `nums[i] < nums[k] < nums[j]`.
Return `true` _if there is a **132 pattern** in_ `nums`_, otherwise, return_ `false`_._
**Example 1:**
**Input:** nums = \[1,2,3,4\]
... | null | Array,Binary Search,Stack,Monotonic Stack,Ordered Set | Medium | null |
145 | hello guys and welcome back to my video series where I saw each one of leeco's problems going for the from the easy ones to the hard ones and now binary tree post order traversal and I have no idea what this is given the root of a binary tree return the post or the reversal of its nodes values this is similar to the pr... | Binary Tree Postorder Traversal | binary-tree-postorder-traversal | Given the `root` of a binary tree, return _the postorder traversal of its nodes' values_.
**Example 1:**
**Input:** root = \[1,null,2,3\]
**Output:** \[3,2,1\]
**Example 2:**
**Input:** root = \[\]
**Output:** \[\]
**Example 3:**
**Input:** root = \[1\]
**Output:** \[1\]
**Constraints:**
* The number of the n... | null | Stack,Tree,Depth-First Search,Binary Tree | Easy | 94,776 |
199 | guys welcome to the channel this is waga we're going to do another leech good question and the question in question is number 199 binary tree right side view right so um what you what this question does or what it is it expects you to write to return the right most value values in a binary search tree right binary tree... | Binary Tree Right Side View | binary-tree-right-side-view | Given the `root` of a binary tree, imagine yourself standing on the **right side** of it, return _the values of the nodes you can see ordered from top to bottom_.
**Example 1:**
**Input:** root = \[1,2,3,null,5,null,4\]
**Output:** \[1,3,4\]
**Example 2:**
**Input:** root = \[1,null,3\]
**Output:** \[1,3\]
**Examp... | null | Tree,Depth-First Search,Breadth-First Search,Binary Tree | Medium | 116,545 |
1,347 | hey everyone today i'll be going over leak code 1347 minimum number of steps to make two strings anagram so we're given two strings basically and uh in one step you can choose any character of one string and replace it with another character so basically you have to count the minimum steps to make them equal by doing t... | Minimum Number of Steps to Make Two Strings Anagram | distance-to-a-cycle-in-undirected-graph | You are given two strings of the same length `s` and `t`. In one step you can choose **any character** of `t` and replace it with **another character**.
Return _the minimum number of steps_ to make `t` an anagram of `s`.
An **Anagram** of a string is a string that contains the same characters with a different (or the... | This problem can be broken down into two parts: finding the cycle, and finding the distance between each node and the cycle. How can we find the cycle? We can use DFS and keep track of the nodes we’ve seen, and the order that we see them in. Once we see a node we’ve already visited, we know that the cycle contains the ... | Depth-First Search,Breadth-First Search,Union Find,Graph | Hard | 2218 |
424 | everyone let's do lead code 424 longest repeating character replacement so we're given a string s which is composed of all uppercase English letters and an integer K we can choose any character in the string and change it to any other uppercase letter we can perform this operation at most K times and we want to find th... | Longest Repeating Character Replacement | longest-repeating-character-replacement | You are given a string `s` and an integer `k`. You can choose any character of the string and change it to any other uppercase English character. You can perform this operation at most `k` times.
Return _the length of the longest substring containing the same letter you can get after performing the above operations_.
... | null | Hash Table,String,Sliding Window | Medium | 340,1046,2119,2134,2319 |
288 | good evening and welcome to my channel welcome back to my channel and thank you for watching keep watching my video and today is lethal time again and before i dab into the problem i first will uh i first want to introduce a really good solving problem method metal name is yellow dark muscle the chinese name is and so ... | Unique Word Abbreviation | unique-word-abbreviation | The **abbreviation** of a word is a concatenation of its first letter, the number of characters between the first and last letter, and its last letter. If a word has only two characters, then it is an **abbreviation** of itself.
For example:
* `dog --> d1g` because there is one letter between the first letter `'d'`... | null | Array,Hash Table,String,Design | Medium | 170,320 |
20 | this is the 20th Elite code Challenge and it is called valid parentheses given a string s containing just the characters parentheses curly braces and square braces determine if the input string is valid an input string is valid if the Open brackets must be closed by the same type of brackets Open brackets must be close... | Valid Parentheses | valid-parentheses | Given a string `s` containing just the characters `'('`, `')'`, `'{'`, `'}'`, `'['` and `']'`, determine if the input string is valid.
An input string is valid if:
1. Open brackets must be closed by the same type of brackets.
2. Open brackets must be closed in the correct order.
3. Every close bracket has a corres... | An interesting property about a valid parenthesis expression is that a sub-expression of a valid expression should also be a valid expression. (Not every sub-expression) e.g.
{ { } [ ] [ [ [ ] ] ] } is VALID expression
[ [ [ ] ] ] is VALID sub-expression
{ } [ ] is VALID sub-express... | String,Stack | Easy | 22,32,301,1045,2221 |
59 | Hello Hi Everyone Welcome To My Channel It's All The Problem Spiral Matrix To Give Positive Veeravansh 2ND Year In Spider-Man Positive Veeravansh 2ND Year In Spider-Man Positive Veeravansh 2ND Year In Spider-Man Subscribe And Elements Of Obscuritism 123456789 Will Solve Problems Will U Will Go Through Subscribe To That... | Spiral Matrix II | spiral-matrix-ii | Given a positive integer `n`, generate an `n x n` `matrix` filled with elements from `1` to `n2` in spiral order.
**Example 1:**
**Input:** n = 3
**Output:** \[\[1,2,3\],\[8,9,4\],\[7,6,5\]\]
**Example 2:**
**Input:** n = 1
**Output:** \[\[1\]\]
**Constraints:**
* `1 <= n <= 20` | null | Array,Matrix,Simulation | Medium | 54,921 |
3 | 4 Rico Le No. 3 Yes, there was a problem called Gist Business String Upper Down Lifting Characters. This is now a sliding degree problem. It is a very similar problem to the Amazon coding interview problem I saw earlier. It feels like u3, and in fact, the problems that appear in this ret code are Yes, most of the codin... | Longest Substring Without Repeating Characters | longest-substring-without-repeating-characters | Given a string `s`, find the length of the **longest** **substring** without repeating characters.
**Example 1:**
**Input:** s = "abcabcbb "
**Output:** 3
**Explanation:** The answer is "abc ", with the length of 3.
**Example 2:**
**Input:** s = "bbbbb "
**Output:** 1
**Explanation:** The answer is "b ", with t... | null | Hash Table,String,Sliding Window | Medium | 159,340,1034,1813,2209 |
1,786 | hey what's up guys uh this is chung here so this time uh 1786 number of restricted paths from first to last node okay so you're given like undirected weighted connected graph here and which is like represents by a n which is the number of nodes and a bunch of edges with the with weight on it right so and the path right... | Number of Restricted Paths From First to Last Node | count-the-number-of-consistent-strings | There is an undirected weighted connected graph. You are given a positive integer `n` which denotes that the graph has `n` nodes labeled from `1` to `n`, and an array `edges` where each `edges[i] = [ui, vi, weighti]` denotes that there is an edge between nodes `ui` and `vi` with weight equal to `weighti`.
A path from ... | A string is incorrect if it contains a character that is not allowed Constraints are small enough for brute force | Array,Hash Table,String,Bit Manipulation | Easy | null |
63 | hi today i'm talking about lead code problem 63 unique paths this problem asks you to do similar to the previous unique it's similar to the previously code problems unique paths one what it asks you to do is it says it's going to give you a grid and the grid can have obstacles on it an obstacle is going to be marked by... | Unique Paths II | unique-paths-ii | You are given an `m x n` integer array `grid`. There is a robot initially located at the **top-left corner** (i.e., `grid[0][0]`). The robot tries to move to the **bottom-right corner** (i.e., `grid[m - 1][n - 1]`). The robot can only move either down or right at any point in time.
An obstacle and space are marked as ... | The robot can only move either down or right. Hence any cell in the first row can only be reached from the cell left to it. However, if any cell has an obstacle, you don't let that cell contribute to any path. So, for the first row, the number of ways will simply be
if obstacleGrid[i][j] is not an obstacle
... | Array,Dynamic Programming,Matrix | Medium | 62,1022 |
1,690 | hey everybody this is larry this is me gorman q3 of the weekly contest 219 of lead code stone game seven wow we're already up to seven too fast too furious so which one was the seven let me know if you have a good point on stone game seven but anyway so stone game this um there's seven of them so hopefully by now you p... | Stone Game VII | maximum-length-of-subarray-with-positive-product | Alice and Bob take turns playing a game, with **Alice starting first**.
There are `n` stones arranged in a row. On each player's turn, they can **remove** either the leftmost stone or the rightmost stone from the row and receive points equal to the **sum** of the remaining stones' values in the row. The winner is the ... | Split the whole array into subarrays by zeroes since a subarray with positive product cannot contain any zero. If the subarray has even number of negative numbers, the whole subarray has positive product. Otherwise, we have two choices, either - remove the prefix till the first negative element in this subarray, or rem... | Array,Dynamic Programming,Greedy | Medium | null |
507 | hey everyone welcome back and today we'll be doing another lead code 507 perfect number and is even a perfect number is a positive integer that is equal to the sum of its positive divisions excluding the number itself a divisor of an integer X is an integer that can divide X evenly given earn integer and return true if... | Perfect Number | perfect-number | A [**perfect number**](https://en.wikipedia.org/wiki/Perfect_number) is a **positive integer** that is equal to the sum of its **positive divisors**, excluding the number itself. A **divisor** of an integer `x` is an integer that can divide `x` evenly.
Given an integer `n`, return `true` _if_ `n` _is a perfect number,... | null | Math | Easy | 728 |
1,312 | hey what's up guys chung here again and so this time let's take a look at this little problem here number 1312 minimum insertion steps to make a string palindrome another classic not classic but another astringent palindrome problem you know i think it's very easy very simple description not easy sorry simple descripti... | Minimum Insertion Steps to Make a String Palindrome | count-artifacts-that-can-be-extracted | Given a string `s`. In one step you can insert any character at any index of the string.
Return _the minimum number of steps_ to make `s` palindrome.
A **Palindrome String** is one that reads the same backward as well as forward.
**Example 1:**
**Input:** s = "zzazz "
**Output:** 0
**Explanation:** The string "zz... | Check if each coordinate of each artifact has been excavated. How can we do this quickly without iterating over the dig array every time? Consider marking all excavated cells in a 2D boolean array. | Array,Hash Table,Simulation | Medium | 221 |
208 | let's take a look at leak code 208 Implement try or prefix tree and this is a great question to be able to practice your tree data structure we've been seeing a lot of binary trees and a try is a string related tree which allows you to better search for Strings such as autocomplete and spell checker so a try or a prefi... | Implement Trie (Prefix Tree) | implement-trie-prefix-tree | A [**trie**](https://en.wikipedia.org/wiki/Trie) (pronounced as "try ") or **prefix tree** is a tree data structure used to efficiently store and retrieve keys in a dataset of strings. There are various applications of this data structure, such as autocomplete and spellchecker.
Implement the Trie class:
* `Trie()` ... | null | Hash Table,String,Design,Trie | Medium | 211,642,648,676,1433,1949 |
1,690 | hi everyone it's albert today let's solve the minion question from the weekly contest stone game seven the question statement so we have two players alice and bob they take turns and playing a game and with alice playing first and they are unstones arranged in a row and on each player's round they can remove either the... | Stone Game VII | maximum-length-of-subarray-with-positive-product | Alice and Bob take turns playing a game, with **Alice starting first**.
There are `n` stones arranged in a row. On each player's turn, they can **remove** either the leftmost stone or the rightmost stone from the row and receive points equal to the **sum** of the remaining stones' values in the row. The winner is the ... | Split the whole array into subarrays by zeroes since a subarray with positive product cannot contain any zero. If the subarray has even number of negative numbers, the whole subarray has positive product. Otherwise, we have two choices, either - remove the prefix till the first negative element in this subarray, or rem... | Array,Dynamic Programming,Greedy | Medium | null |
623 | hi guys welcome to algorithms made easy in this video we will see the question add one row to tree given the root of a binary tree then a value v and a depth d you need to add a row of nodes with value v at the given depth d the root node is at depth 1 that is we are considering the adding rule is that given a positive... | Add One Row to Tree | add-one-row-to-tree | Given the `root` of a binary tree and two integers `val` and `depth`, add a row of nodes with value `val` at the given depth `depth`.
Note that the `root` node is at depth `1`.
The adding rule is:
* Given the integer `depth`, for each not null tree node `cur` at the depth `depth - 1`, create two tree nodes with va... | null | Tree,Depth-First Search,Breadth-First Search,Binary Tree | Medium | null |
241 | all right let's talk about the different ways to add the parentheses so given a string expression of number and operator so you have to return all the possible results from computing all the different possible weight of the group and then you want to return the answer and this is the idea right so two minus one and if ... | Different Ways to Add Parentheses | different-ways-to-add-parentheses | Given a string `expression` of numbers and operators, return _all possible results from computing all the different possible ways to group numbers and operators_. You may return the answer in **any order**.
The test cases are generated such that the output values fit in a 32-bit integer and the number of different res... | null | Math,String,Dynamic Programming,Recursion,Memoization | Medium | 95,224,282,2147,2328 |
343 | Hello everyone welcome back to my YouTube channel discussing our today's problem interior there will be a number in it like how can I do this for free 406 420 you can subscribe ok this is how you break it in Only after break, you have to return whichever product mixture is mixed with your ghee. Okay, so now how will we... | Integer Break | integer-break | Given an integer `n`, break it into the sum of `k` **positive integers**, where `k >= 2`, and maximize the product of those integers.
Return _the maximum product you can get_.
**Example 1:**
**Input:** n = 2
**Output:** 1
**Explanation:** 2 = 1 + 1, 1 \* 1 = 1.
**Example 2:**
**Input:** n = 10
**Output:** 36
**Exp... | There is a simple O(n) solution to this problem. You may check the breaking results of n ranging from 7 to 10 to discover the regularities. | Math,Dynamic Programming | Medium | 1936 |
1,751 | hello and welcome to another leak code video today we're going to be doing the problem of the day for July 15th maximum number of events that can be attended to and so you're given an array of events where events I start day and day in value and the ith event starts at start day and the end day and if you attend this e... | Maximum Number of Events That Can Be Attended II | slowest-key | You are given an array of `events` where `events[i] = [startDayi, endDayi, valuei]`. The `ith` event starts at `startDayi` and ends at `endDayi`, and if you attend this event, you will receive a value of `valuei`. You are also given an integer `k` which represents the maximum number of events you can attend.
You can o... | Get for each press its key and amount of time taken. Iterate on the presses, maintaining the answer so far. The current press will change the answer if and only if its amount of time taken is longer than that of the previous answer, or they are equal but the key is larger than that of the previous answer. | Array,String | Easy | null |
1,567 | hey there welcome back to lead coding on this channel we discuss problems which are frequently asked in programming interviews today we are here with a problem called maximum length of subarray with positive product in this question we are given an array of integers we have to find the length of the sub array where the... | Maximum Length of Subarray With Positive Product | maximum-number-of-vowels-in-a-substring-of-given-length | Given an array of integers `nums`, find the maximum length of a subarray where the product of all its elements is positive.
A subarray of an array is a consecutive sequence of zero or more values taken out of that array.
Return _the maximum length of a subarray with positive product_.
**Example 1:**
**Input:** nums... | Keep a window of size k and maintain the number of vowels in it. Keep moving the window and update the number of vowels while moving. Answer is max number of vowels of any window. | String,Sliding Window | Medium | null |
1,043 | Hello friends welcome to my channel here Sol called problems today's problem number 1, 43 partition array for maximum sum medium level given an integer array R partition the array into contigous subarrays of length at most K after partitioning each subarray has their values changed to be the maximum value of that sub a... | Partition Array for Maximum Sum | grid-illumination | Given an integer array `arr`, partition the array into (contiguous) subarrays of length **at most** `k`. After partitioning, each subarray has their values changed to become the maximum value of that subarray.
Return _the largest sum of the given array after partitioning. Test cases are generated so that the answer fi... | null | Array,Hash Table | Hard | 51 |
417 | hey everybody this is larry this is day 25 of the ditco march daily challenge the like button hit the subscriber and join me in discord let me know what you think about today's farm uh so i don't actually wear glasses uh but i'm trying this new thing with about blue light yellow light something like that so i don't kno... | Pacific Atlantic Water Flow | pacific-atlantic-water-flow | There is an `m x n` rectangular island that borders both the **Pacific Ocean** and **Atlantic Ocean**. The **Pacific Ocean** touches the island's left and top edges, and the **Atlantic Ocean** touches the island's right and bottom edges.
The island is partitioned into a grid of square cells. You are given an `m x n` i... | null | Array,Depth-First Search,Breadth-First Search,Matrix | Medium | null |
219 | lead code number 219 content duplicates 2 So within the window of the size of three which means the distance within the first integer first number and last number if this inside the tree then we will return true then if this has a duplicate I took the code from his video in here no it's not I took the code from the sol... | Contains Duplicate II | contains-duplicate-ii | Given an integer array `nums` and an integer `k`, return `true` _if there are two **distinct indices**_ `i` _and_ `j` _in the array such that_ `nums[i] == nums[j]` _and_ `abs(i - j) <= k`.
**Example 1:**
**Input:** nums = \[1,2,3,1\], k = 3
**Output:** true
**Example 2:**
**Input:** nums = \[1,0,1,1\], k = 1
**Outp... | null | Array,Hash Table,Sliding Window | Easy | 217,220 |
1,816 | hey everyone welcome back to another coding challenge lead code problem 1816 it's called trunet sentence so we have been given here a sentence which is in the form of strings which is called hello how are you contestant and we have been given a K4 which is index so here k equals 4 means how many words they want us to h... | Truncate Sentence | lowest-common-ancestor-of-a-binary-tree-iv | A **sentence** is a list of words that are separated by a single space with no leading or trailing spaces. Each of the words consists of **only** uppercase and lowercase English letters (no punctuation).
* For example, `"Hello World "`, `"HELLO "`, and `"hello world hello world "` are all sentences.
You are given a... | Starting from the root, traverse the left and the right subtrees, checking if one of the nodes exist there. If one of the subtrees doesn't contain any given node, the LCA can be the node returned from the other subtree If both subtrees contain nodes, the LCA node is the current node. | Tree,Depth-First Search,Binary Tree | Medium | 235,236,1218,1780,1790,1816 |
204 | K Ribbon My name is Ayush Mishra and you are watching this mission Dress Today we are going to talk about the problem of this name on the list 34 problems of ours and it is a very important problem that the question is what to do with you Calling brother. What is the number of prime factors listed in the negative numbe... | Count Primes | count-primes | Given an integer `n`, return _the number of prime numbers that are strictly less than_ `n`.
**Example 1:**
**Input:** n = 10
**Output:** 4
**Explanation:** There are 4 prime numbers less than 10, they are 2, 3, 5, 7.
**Example 2:**
**Input:** n = 0
**Output:** 0
**Example 3:**
**Input:** n = 1
**Output:** 0
**Co... | Let's start with a isPrime function. To determine if a number is prime, we need to check if it is not divisible by any number less than n. The runtime complexity of isPrime function would be O(n) and hence counting the total prime numbers up to n would be O(n2). Could we do better? As we know the number must not be div... | Array,Math,Enumeration,Number Theory | Medium | 263,264,279 |
2,000 | yeah so uh yeah so sometimes i don't want to do mathematics so i do something code yeah so just for fun it's very easy question hey so we can do easy i do easy questions so i don't spend a lot of time describing the algorithm okay so reverse uh reverse the prefix of a word so given uh zero index string we're in the cre... | Reverse Prefix of Word | minimum-speed-to-arrive-on-time | Given a **0-indexed** string `word` and a character `ch`, **reverse** the segment of `word` that starts at index `0` and ends at the index of the **first occurrence** of `ch` (**inclusive**). If the character `ch` does not exist in `word`, do nothing.
* For example, if `word = "abcdefd "` and `ch = "d "`, then you s... | Given the speed the trains are traveling at, can you find the total time it takes for you to arrive? Is there a cutoff where any speeds larger will always allow you to arrive on time? | Array,Binary Search | Medium | 1335,2013,2294 |
1,247 | hi friends uh welcome to followup let's have a look at problem 1247 minimum slaps to make strings equal uh this is also a daily challenge problem so in this video we're going to analyze uh the strategy and demonstrate to you uh that starting from example one and example two actually we can derive the um Counting or the... | Minimum Swaps to Make Strings Equal | decrease-elements-to-make-array-zigzag | You are given two strings `s1` and `s2` of equal length consisting of letters `"x "` and `"y "` **only**. Your task is to make these two strings equal to each other. You can swap any two characters that belong to **different** strings, which means: swap `s1[i]` and `s2[j]`.
Return the minimum number of swaps required ... | Do each case (even indexed is greater, odd indexed is greater) separately. In say the even case, you should decrease each even-indexed element until it is lower than its immediate neighbors. | Array,Greedy | Medium | null |
130 | hey everybody this is larry this is day the last day of oh i know is it hey i'm now no longer snorlax it's really hot i guess it's the first day of the november lego day challenge but it's still halloween where i am so i am i'm snorlax so snorlax no dexter alexa you're just joining us um yeah we will do this all week o... | Surrounded Regions | surrounded-regions | Given an `m x n` matrix `board` containing `'X'` and `'O'`, _capture all regions that are 4-directionally surrounded by_ `'X'`.
A region is **captured** by flipping all `'O'`s into `'X'`s in that surrounded region.
**Example 1:**
**Input:** board = \[\[ "X ", "X ", "X ", "X "\],\[ "X ", "O ", "O ", "X "\],\[ "X ", "... | null | Array,Depth-First Search,Breadth-First Search,Union Find,Matrix | Medium | 200,286 |
716 | Hello friends hope you're having a fantastic day today so now we are going to do an awesome stack problem that is a actually a lead code premium problem so this is going to be really interesting very popular question and very interesting subject so without any delay let's get started okay so the lead code problem we ar... | Max Stack | max-stack | Design a max stack data structure that supports the stack operations and supports finding the stack's maximum element.
Implement the `MaxStack` class:
* `MaxStack()` Initializes the stack object.
* `void push(int x)` Pushes element `x` onto the stack.
* `int pop()` Removes the element on top of the stack and re... | null | Linked List,Stack,Design,Doubly-Linked List,Ordered Set | Easy | 155 |
144 | hey guys how's everything going this is chaser who is not looking at algorithms in this video I'm going to take a look at 104 binary tree pre-order traversal at 104 binary tree pre-order traversal at 104 binary tree pre-order traversal because I'm a front-end engineer and because I'm a front-end engineer and because I'... | Binary Tree Preorder Traversal | binary-tree-preorder-traversal | Given the `root` of a binary tree, return _the preorder traversal of its nodes' values_.
**Example 1:**
**Input:** root = \[1,null,2,3\]
**Output:** \[1,2,3\]
**Example 2:**
**Input:** root = \[\]
**Output:** \[\]
**Example 3:**
**Input:** root = \[1\]
**Output:** \[1\]
**Constraints:**
* The number of nodes ... | null | Stack,Tree,Depth-First Search,Binary Tree | Easy | 94,255,775 |
978 | hey everybody this is larry this is day 15 of this summer hit the like button subscribe for enjoyment just because i know you think about getting fun and i'm still in this thing um okay okay i mean it goes up and down and up and down kind of like this even if they're the same um um so yeah if if it is increasing or dec... | Longest Turbulent Subarray | valid-mountain-array | Given an integer array `arr`, return _the length of a maximum size turbulent subarray of_ `arr`.
A subarray is **turbulent** if the comparison sign flips between each adjacent pair of elements in the subarray.
More formally, a subarray `[arr[i], arr[i + 1], ..., arr[j]]` of `arr` is said to be turbulent if and only i... | It's very easy to keep track of a monotonically increasing or decreasing ordering of elements. You just need to be able to determine the start of the valley in the mountain and from that point onwards, it should be a valley i.e. no mini-hills after that. Use this information in regards to the values in the array and yo... | Array | Easy | 1766 |
352 | good evening everyone today we are going to do the daily read code challenge of 28 January 2023 that is question number 352 data stream as disjoint intervals in this question they have given us a data stream which is having non-negative stream which is having non-negative stream which is having non-negative integers th... | Data Stream as Disjoint Intervals | data-stream-as-disjoint-intervals | Given a data stream input of non-negative integers `a1, a2, ..., an`, summarize the numbers seen so far as a list of disjoint intervals.
Implement the `SummaryRanges` class:
* `SummaryRanges()` Initializes the object with an empty stream.
* `void addNum(int value)` Adds the integer `value` to the stream.
* `int... | null | Binary Search,Design,Ordered Set | Hard | 228,436,715 |
1,293 | hi guys welcome to algorithms made easy my name is khushboo and in this video we are going to see the question shortest path in a grid with obstacle elimination you are given an m cross an integer matrix which is named as grid where each cell is either 0 that means empty or 1 that means there is an obstacle you can mov... | Shortest Path in a Grid with Obstacles Elimination | three-consecutive-odds | You are given an `m x n` integer matrix `grid` where each cell is either `0` (empty) or `1` (obstacle). You can move up, down, left, or right from and to an empty cell in **one step**.
Return _the minimum number of **steps** to walk from the upper left corner_ `(0, 0)` _to the lower right corner_ `(m - 1, n - 1)` _giv... | Check every three consecutive numbers in the array for parity. | Array | Easy | null |
1,601 | Hello Gas, today we are back again and today's question is our maximum number of achiever transfer requests and after all this question building is zero to nine minus one and every building has some employees and what do we have to do? Transfer has to be done from one transparent building to another building and the bu... | Maximum Number of Achievable Transfer Requests | maximum-number-of-achievable-transfer-requests | We have `n` buildings numbered from `0` to `n - 1`. Each building has a number of employees. It's transfer season, and some employees want to change the building they reside in.
You are given an array `requests` where `requests[i] = [fromi, toi]` represents an employee's request to transfer from building `fromi` to bu... | null | null | Hard | null |
503 | That if suggestion also singh question number ₹5 off That if suggestion also singh question number ₹5 off That if suggestion also singh question number ₹5 off list code scooter element to sources of previously authorized next filter element way this question in this question veer next element of subscribe button presse... | Next Greater Element II | next-greater-element-ii | Given a circular integer array `nums` (i.e., the next element of `nums[nums.length - 1]` is `nums[0]`), return _the **next greater number** for every element in_ `nums`.
The **next greater number** of a number `x` is the first greater number to its traversing-order next in the array, which means you could search circu... | null | Array,Stack,Monotonic Stack | Medium | 496,556 |
815 | hello and welcome to the cracking fang youtube channel today we're going to be solving lead code problem 815 bus routes before we get into the problem i would just like to kindly ask you to subscribe to my channel i have the goal of reaching a thousand subscribers by the end of may and i need your help to get there if ... | Bus Routes | champagne-tower | You are given an array `routes` representing bus routes where `routes[i]` is a bus route that the `ith` bus repeats forever.
* For example, if `routes[0] = [1, 5, 7]`, this means that the `0th` bus travels in the sequence `1 -> 5 -> 7 -> 1 -> 5 -> 7 -> 1 -> ...` forever.
You will start at the bus stop `source` (You... | null | Dynamic Programming | Medium | 1385 |
1,086 | welcome to interview Pro in today's video Let's solve the lead code problem high five this question appeared in interviews by Goldman Sachs and Amazon the problem gives the list of students and their scores we have to return the average of top 5 scores of each student let's see this example we have two students student... | High Five | divisor-game | Given a list of the scores of different students, `items`, where `items[i] = [IDi, scorei]` represents one score from a student with `IDi`, calculate each student's **top five average**.
Return _the answer as an array of pairs_ `result`_, where_ `result[j] = [IDj, topFiveAveragej]` _represents the student with_ `IDj` ... | If the current number is even, we can always subtract a 1 to make it odd. If the current number is odd, we must subtract an odd number to make it even. | Math,Dynamic Programming,Brainteaser,Game Theory | Easy | null |
4 | foreign welcome back to my channel and today we guys are going to solve a new lead code question that is median of tools or date arrays so guys just before starting to solve discussion please do subscribe to the channel hit the like button press the Bell icon button and book Marti playlist so that you can get the updat... | Median of Two Sorted Arrays | median-of-two-sorted-arrays | Given two sorted arrays `nums1` and `nums2` of size `m` and `n` respectively, return **the median** of the two sorted arrays.
The overall run time complexity should be `O(log (m+n))`.
**Example 1:**
**Input:** nums1 = \[1,3\], nums2 = \[2\]
**Output:** 2.00000
**Explanation:** merged array = \[1,2,3\] and median is ... | null | Array,Binary Search,Divide and Conquer | Hard | null |
141 | Jhal Hello Bhai Students To A Question Only Interact Directly In The Cycle Protection Basically To Identify Weather On Cycle Allu Is Presented In The Recent Pst Flash Lights Of Ban Gaye Mail Address Mintu Return 000 Se Cycle Internships Others Neetu Aka Mintu Later Billion Rising Separate Question Understand Giver Is T... | Linked List Cycle | linked-list-cycle | Given `head`, the head of a linked list, determine if the linked list has a cycle in it.
There is a cycle in a linked list if there is some node in the list that can be reached again by continuously following the `next` pointer. Internally, `pos` is used to denote the index of the node that tail's `next` pointer is co... | null | Hash Table,Linked List,Two Pointers | Easy | 142,202 |
211 | alright so today's second question is 211 add and search word it's a data structure design question we need to design a data structure that is efficiently supports to operations add a word and search word the search word can search for that row or you can search for a regular expression and the only wild card that we a... | Design Add and Search Words Data Structure | design-add-and-search-words-data-structure | Design a data structure that supports adding new words and finding if a string matches any previously added string.
Implement the `WordDictionary` class:
* `WordDictionary()` Initializes the object.
* `void addWord(word)` Adds `word` to the data structure, it can be matched later.
* `bool search(word)` Returns ... | You should be familiar with how a Trie works. If not, please work on this problem: Implement Trie (Prefix Tree) first. | String,Depth-First Search,Design,Trie | Medium | 208,746 |
946 | hey everybody this is larry this is day 16 of the march leeco daily challenge hit the like button hit the subscribe button drum and discord and everything that you want i suppose uh and i yeah well i'm a little bit off today anyway today's problem is validate stack sequences okay so given push and pop you trip distinct... | Validate Stack Sequences | smallest-range-ii | Given two integer arrays `pushed` and `popped` each with distinct values, return `true` _if this could have been the result of a sequence of push and pop operations on an initially empty stack, or_ `false` _otherwise._
**Example 1:**
**Input:** pushed = \[1,2,3,4,5\], popped = \[4,5,3,2,1\]
**Output:** true
**Explana... | null | Array,Math,Greedy,Sorting | Medium | null |
528 | hi everyone it's sorin today we have a problem when we are given an array of integers which represents weight so for example in this case it's a one and a three for the zero index and the first index and we need to implement the function pick index which randomly picks an index from our array and returns it so but the ... | Random Pick with Weight | swapping-nodes-in-a-linked-list | You are given a **0-indexed** array of positive integers `w` where `w[i]` describes the **weight** of the `ith` index.
You need to implement the function `pickIndex()`, which **randomly** picks an index in the range `[0, w.length - 1]` (**inclusive**) and returns it. The **probability** of picking an index `i` is `w[i... | We can transform the linked list to an array this should ease things up After transforming the linked list to an array it becomes as easy as swapping two integers in an array then rebuilding the linked list | Linked List,Two Pointers | Medium | 19,24,25 |
455 | he would so guys Nick white hear you talking coding stuff on Twitch in YouTube check the description for all my information and I do the leak of premium problems on my patreon and you can join my discord reach out to me try and get back to everyone this problem is called assigned cookies it's a pretty easy problem assu... | Assign Cookies | assign-cookies | Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie.
Each child `i` has a greed factor `g[i]`, which is the minimum size of a cookie that the child will be content with; and each cookie `j` has a size `s[j]`. If `s[j] >= g[i]`, we can assign ... | null | Array,Greedy,Sorting | Easy | null |
883 | cool 883 projection area of 3d shapes and an N by n grid we place one by one keeps that access a line on the with two XY and z axes each by UV u goes to quit I J represents a tower of three cubes placed on top quits hours i J now we read the projection of these cubes onto the XY Y Z and said explains we turned the tota... | Projection Area of 3D Shapes | car-fleet | You are given an `n x n` `grid` where we place some `1 x 1 x 1` cubes that are axis-aligned with the `x`, `y`, and `z` axes.
Each value `v = grid[i][j]` represents a tower of `v` cubes placed on top of the cell `(i, j)`.
We view the projection of these cubes onto the `xy`, `yz`, and `zx` planes.
A **projection** is ... | null | Array,Stack,Sorting,Monotonic Stack | Medium | 1902,2317 |
1,595 | hey what's up guys this is sean here so uh so today let's take a look at the last problem of this week's weekly contest number 1595 minimum cost to connect two groups of points i think this is a good hard problem you know i struggled a little bit yeah i struggled on this so basically you're given like two group of poin... | Minimum Cost to Connect Two Groups of Points | minimum-cost-to-connect-two-groups-of-points | You are given two groups of points where the first group has `size1` points, the second group has `size2` points, and `size1 >= size2`.
The `cost` of the connection between any two points are given in an `size1 x size2` matrix where `cost[i][j]` is the cost of connecting point `i` of the first group and point `j` of t... | null | null | Hard | null |
215 | hello everyone welcome to learn overflow in this video we will look into another liquid problem that is the kth largest element in an array okay let's see what the question is like also it's a medium level question not so hard not to tough let's look at it further so it says like given an integer array nums okay we hav... | Kth Largest Element in an Array | kth-largest-element-in-an-array | Given an integer array `nums` and an integer `k`, return _the_ `kth` _largest element in the array_.
Note that it is the `kth` largest element in the sorted order, not the `kth` distinct element.
You must solve it in `O(n)` time complexity.
**Example 1:**
**Input:** nums = \[3,2,1,5,6,4\], k = 2
**Output:** 5
**Ex... | null | Array,Divide and Conquer,Sorting,Heap (Priority Queue),Quickselect | Medium | 324,347,414,789,1014,2113,2204,2250 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.