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,752
hey everybody this is larry this is me going over q1 of the weekly contest 227. check if array is sorted and rotated hit the like button hit the subscribe button join me on discord let me know what you think about this problem um this one i think this i think there's actually a easier uh clever way of doing it in n squ...
Check if Array Is Sorted and Rotated
arithmetic-subarrays
Given an array `nums`, return `true` _if the array was originally sorted in non-decreasing order, then rotated **some** number of positions (including zero)_. Otherwise, return `false`. There may be **duplicates** in the original array. **Note:** An array `A` rotated by `x` positions results in an array `B` of the sa...
To check if a given sequence is arithmetic, just check that the difference between every two consecutive elements is the same. If and only if a set of numbers can make an arithmetic sequence, then its sorted version makes an arithmetic sequence. So to check a set of numbers, sort it, and check if that sequence is arith...
Array,Sorting
Medium
413,1626
63
hey everybody this is larry this is day 28 of the april eco daily challenge hit the like button hit the subscribe button join me on discord uh today is the 28th the last day of week four and we're almost done with april hope y'all enjoying so far in today's promise unique paths too um so this problem you know i usually...
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
322
foreign once again we are going to solve some very classic problems in dynamic programming so um the problem that we are going to solve now this is very well known as Point change and once again uh you know each problem in BP can be thought of as a concept now in interview you might not directly be asked that concept y...
Coin Change
coin-change
You are given an integer array `coins` representing coins of different denominations and an integer `amount` representing a total amount of money. Return _the fewest number of coins that you need to make up that amount_. If that amount of money cannot be made up by any combination of the coins, return `-1`. You may a...
null
Array,Dynamic Programming,Breadth-First Search
Medium
1025,1393,2345
1,513
hi my name is Ray and today I'll be explaining question 2 from the codes weekly competition 197 question 2 is number of sub strings with only ones and the question gives you an input binary string of zeros and ones and it expects you to return all sub strings with all characters ones so that may seem like that may seem...
Number of Substrings With Only 1s
find-all-good-strings
Given a binary string `s`, return _the number of substrings with all characters_ `1`_'s_. Since the answer may be too large, return it modulo `109 + 7`. **Example 1:** **Input:** s = "0110111 " **Output:** 9 **Explanation:** There are 9 substring in total with only 1's characters. "1 " -> 5 times. "11 " -> 3 times...
Use DP with 4 states (pos: Int, posEvil: Int, equalToS1: Bool, equalToS2: Bool) which compute the number of valid strings of size "pos" where the maximum common suffix with string "evil" has size "posEvil". When "equalToS1" is "true", the current valid string is equal to "S1" otherwise it is greater. In a similar way w...
String,Dynamic Programming,String Matching
Hard
null
1,652
Hua Tha Is Problem Tubes So You How Is The Time Of Luck Code Liye Baki Fritters Phone Number Like Example Military Plane Take Care Love You All Subscribe Plus 500 Hai Apne Real Romance And Also Actress Elements In The Field Of Fashion Kare Saunf 125 V4 Plus Seventh Class 5 Result Newly Made Locket in Operation Bigg Bos...
Defuse the Bomb
minimum-suffix-flips
You have a bomb to defuse, and your time is running out! Your informer will provide you with a **circular** array `code` of length of `n` and a key `k`. To decrypt the code, you must replace every number. All the numbers are replaced **simultaneously**. * If `k > 0`, replace the `ith` number with the sum of the **n...
Consider a strategy where the choice of bulb with number i is increasing. In such a strategy, you no longer need to worry about bulbs that have been set to the left.
String,Greedy
Medium
null
456
hi all welcome to learn code repeat so today we will be looking at day twenty three of the october lead code challenge the name of the problem is one three two pattern let us look into the problem so the problem states given an array of n integers norms a 132 pattern is a subsequence of three integers number five num o...
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
213
all right let's talk about hospital 2 and house robert 2 is almost exactly to the same as house rubber one the only thing is different is how swap 2 is arranged in a circle so the last element can go back to the first and you will definitely understand that two cannot go to the last right but two can go to the second l...
House Robber II
house-robber-ii
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place are **arranged in a circle.** That means the first house is the neighbor of the last one. Meanwhile, adjacent houses have a security system connected, and **it will automatical...
Since House[1] and House[n] are adjacent, they cannot be robbed together. Therefore, the problem becomes to rob either House[1]-House[n-1] or House[2]-House[n], depending on which choice offers more money. Now the problem has degenerated to the House Robber, which is already been solved.
Array,Dynamic Programming
Medium
198,256,276,337,600,656
814
so hey there everyone welcome back so it was our today's problem of the day named as binary tree pruning so we are given with that root of a binary we have to return the same tree where every subtree of the given tree not containing a one has been removed right so obser sub tree of a node is a node plus every node that...
Binary Tree Pruning
smallest-rotation-with-highest-score
Given the `root` of a binary tree, return _the same tree where every subtree (of the given tree) not containing a_ `1` _has been removed_. A subtree of a node `node` is `node` plus every node that is a descendant of `node`. **Example 1:** **Input:** root = \[1,null,0,0,1\] **Output:** \[1,null,0,null,1\] **Explanati...
null
Array,Prefix Sum
Hard
null
199
hey guys how's it going in this video i'm going to walk through this legal problem finally right side view so this problem was asked by facebook for 59 times in the past six months so if you're going for an interview with facebook you do not want to miss this video so let's take a look at this problem to see what's ask...
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,514
hey everybody this is Larry this is cute three of the recent indeed contest half of a maximum probability hit the like button hit the subscribe button join me on disco and yeah going over this fall so this poem has a couple of components that you have to think about the thing that I had trouble with a little bit was wh...
Path with Maximum Probability
minimum-value-to-get-positive-step-by-step-sum
You are given an undirected weighted graph of `n` nodes (0-indexed), represented by an edge list where `edges[i] = [a, b]` is an undirected edge connecting the nodes `a` and `b` with a probability of success of traversing that edge `succProb[i]`. Given two nodes `start` and `end`, find the path with the maximum probab...
Find the minimum prefix sum.
Array,Prefix Sum
Easy
null
1,700
okay hello so today we're looking at question 71700 number of students unable to eat lunch so at a school cafe we they offer circular and square sandwiches at lunch break referred to by numbers 0 and 1 respectively all students stand in a queue students will either prefer square so 0 or 1 sandwiches note that the numbe...
Number of Students Unable to Eat Lunch
minimum-time-to-make-rope-colorful
The school cafeteria offers circular and square sandwiches at lunch break, referred to by numbers `0` and `1` respectively. All students stand in a queue. Each student either prefers square or circular sandwiches. The number of sandwiches in the cafeteria is equal to the number of students. The sandwiches are placed i...
Maintain the running sum and max value for repeated letters.
Array,String,Dynamic Programming,Greedy
Medium
null
336
welcome to june's legal challenge today's problem is palindrome pairs given a list of unique words return all the pairs of the distinct indices in a given list so that the concatenation of the two words i plus words j is a palindrome straightforward problem i don't think i need to explain any further we just want to fi...
Palindrome Pairs
palindrome-pairs
You are given a **0-indexed** array of **unique** strings `words`. A **palindrome pair** is a pair of integers `(i, j)` such that: * `0 <= i, j < words.length`, * `i != j`, and * `words[i] + words[j]` (the concatenation of the two strings) is a palindrome. Return _an array of all the **palindrome pairs** of_ `...
null
Array,Hash Table,String,Trie
Hard
5,214,2237
331
hello everyone welcome to coding culture this channel will contain those programs whose explanation is either not present on youtube or the explanation is present but not up to the mark so without wasting time let's get started today's question is the verify pre-order question is the verify pre-order question is the ve...
Verify Preorder Serialization of a Binary Tree
verify-preorder-serialization-of-a-binary-tree
One way to serialize a binary tree is to use **preorder traversal**. When we encounter a non-null node, we record the node's value. If it is a null node, we record using a sentinel value such as `'#'`. For example, the above binary tree can be serialized to the string `"9,3,4,#,#,1,#,#,2,#,6,#,# "`, where `'#'` repres...
null
String,Stack,Tree,Binary Tree
Medium
null
688
hey what's up guys this is chung here so uh today uh let's take a look at this uh 688 night probability in chessboard um i think this is like it's a good question basically you know it's given like a 2d board uh an m by n chessboard and the knight starts at uh our earth row and six column okay and then the knight will ...
Knight Probability in Chessboard
knight-probability-in-chessboard
On an `n x n` chessboard, a knight starts at the cell `(row, column)` and attempts to make exactly `k` moves. The rows and columns are **0-indexed**, so the top-left cell is `(0, 0)`, and the bottom-right cell is `(n - 1, n - 1)`. A chess knight has eight possible moves it can make, as illustrated below. Each move is ...
null
Dynamic Programming
Medium
576
1,624
Hello and Good Morning So today's question is Largest sub string between two equal characters So let's move to the problem statement Given string A returns the length of the longest sub string between two equal characters excluding the two characters If there is no true sub string returns my So basically we have been g...
Largest Substring Between Two Equal Characters
clone-binary-tree-with-random-pointer
Given a string `s`, return _the length of the longest substring between two equal characters, excluding the two characters._ If there is no such substring return `-1`. A **substring** is a contiguous sequence of characters within a string. **Example 1:** **Input:** s = "aa " **Output:** 0 **Explanation:** The optim...
Traverse the tree, keep a hashtable with you and create a nodecopy for each node in the tree. Start traversing the original tree again and connect the left, right and random pointers in the cloned tree the same way as the original tree with the help of the hashtable.
Hash Table,Tree,Depth-First Search,Breadth-First Search,Binary Tree
Medium
133,138,1634
476
hey everybody this is larry this is day 27 of the december lego day challenge hit the like button hit the subscriber and drop me a discord let me know what you think about this problem whatever you like and or the video before um i don't know i'm in panama still right now just to give y'all an update maybe obviously um...
Number Complement
number-complement
The **complement** of an integer is the integer you get when you flip all the `0`'s to `1`'s and all the `1`'s to `0`'s in its binary representation. * For example, The integer `5` is `"101 "` in binary and its **complement** is `"010 "` which is the integer `2`. Given an integer `num`, return _its complement_. **...
null
Bit Manipulation
Easy
null
228
hello and welcome to another daily leap code challenge let's begin question 228 summary arranges you're given assorted unique integer array nums arrange a b is set of all integers from A to B inclusive okay one more time arrange a b is the set of all integers from A to B inclusive return the smallest sorted list of ran...
Summary Ranges
summary-ranges
You are given a **sorted unique** integer array `nums`. A **range** `[a,b]` is the set of all integers from `a` to `b` (inclusive). Return _the **smallest sorted** list of ranges that **cover all the numbers in the array exactly**_. That is, each element of `nums` is covered by exactly one of the ranges, and there is...
null
Array
Easy
163,352
746
If possible, hello everyone welcome to our channel and this onion in this video you will be getting water easy problem no nuker stuffing states and 1746 and the problem is only visit of a positive set saunf 125 request they request your files actually the cost of fire Stick Pan Staircase Detail Sapoch Web Semester's Sl...
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,099
welcome back to tekken navi today i'll be going over to some less than k liquid question number 1099 so let's jump right into it given an array numbers of integers and integer k return the maximum sum such that exists i is less than k with nums plus i or nums plus j equals sum and sum is less than k if no and i j exist...
Two Sum Less Than K
path-with-maximum-minimum-value
Given an array `nums` of integers and integer `k`, return the maximum `sum` such that there exists `i < j` with `nums[i] + nums[j] = sum` and `sum < k`. If no `i`, `j` exist satisfying this equation, return `-1`. **Example 1:** **Input:** nums = \[34,23,1,24,75,33,54,8\], k = 60 **Output:** 58 **Explanation:** We can...
What if we sort each cell of the matrix by the value? Don't include small values in your path if you can only include large values. Let's keep adding a possible cell to use in the path incrementally with decreasing values. If the start and end cells are connected then we don't need to add more cells. Use union-find dat...
Array,Depth-First Search,Breadth-First Search,Union Find,Heap (Priority Queue),Matrix
Medium
1753
746
hey everybody this is lry this is uh day oh Friday to 133 wow hope everyone's having a good Friday to 13 H actually I like this uh wallpaper background it makes me looks like uh like I intentionally care for uh setting this up or something you know uh looks also like very instagrammable I don't know let me know if it m...
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,027
hello everyone welcome back here is van damson and today we are going to tackle a very interesting problem longest arithmetic subsequence uh this time in C sharp so it's medium difficulty problem so it might be tricky to understand it and so with efficiently but we will explain everything so we will try to use dynamic ...
Longest Arithmetic Subsequence
sum-of-even-numbers-after-queries
Given an array `nums` of integers, return _the length of the longest arithmetic subsequence in_ `nums`. **Note** that: * A **subsequence** is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining elements. * A sequence `seq` is arithmetic if `s...
null
Array,Simulation
Medium
null
1,191
Hi Everyone Welcome Back To Coding With Bharat Channel So We Are Back In To The Series On Kaden Algorithm And Will Be Dying Our Third Problem Today Why Is This One's Problem Maximum Some So Without Wasting Any Further Time Let's Get Into The Problem So It Says that we are given an array of some size n and we are also g...
K-Concatenation Maximum Sum
synonymous-sentences
Given an integer array `arr` and an integer `k`, modify the array by repeating it `k` times. For example, if `arr = [1, 2]` and `k = 3` then the modified array will be `[1, 2, 1, 2, 1, 2]`. Return the maximum sub-array sum in the modified array. Note that the length of the sub-array can be `0` and its sum in that cas...
Find all synonymous groups of words. Use union-find data structure. By backtracking, generate all possible statements.
Array,Hash Table,String,Backtracking,Union Find
Medium
null
1,386
hello yours welcome back to my channel I hope you're enjoying all the videos that I am uploading I'm back with another problem from read code today cinema seat allocation a cinema has n rows of seats numbered from 1 to N and there are 10 seats in each row labeled from 1 to 10 as shown in the figure so there are n rows ...
Cinema Seat Allocation
shift-2d-grid
A cinema has `n` rows of seats, numbered from 1 to `n` and there are ten seats in each row, labelled from 1 to 10 as shown in the figure above. Given the array `reservedSeats` containing the numbers of seats already reserved, for example, `reservedSeats[i] = [3,8]` means the seat located in row **3** and labelled with...
Simulate step by step. move grid[i][j] to grid[i][j+1]. handle last column of the grid. Put the matrix row by row to a vector. take k % vector.length and move last k of the vector to the beginning. put the vector to the matrix back the same way.
Array,Matrix,Simulation
Easy
null
109
all right let's talk about conversation binary search trees so you are given a single linked list and the elements are sorted for sure so you are going to convert this linked list to a tree so you are going to find where is the middle value which is your group right so your root has to be a middle value for the languag...
Convert Sorted List to Binary Search Tree
convert-sorted-list-to-binary-search-tree
Given the `head` of a singly linked list where elements are sorted in **ascending order**, convert _it to a_ **_height-balanced_** _binary search tree_. **Example 1:** **Input:** head = \[-10,-3,0,5,9\] **Output:** \[0,-3,9,-10,null,5\] **Explanation:** One possible answer is \[0,-3,9,-10,null,5\], which represents t...
null
Linked List,Divide and Conquer,Tree,Binary Search Tree,Binary Tree
Medium
108,2306
1,584
hey what's up guys this is chung here so today uh before going to bed i would like to talk about uh this week's uh weekly contest 1584 minimum cost to connect all points it's a medium problem i think it's a good problem anyway so you're given like an array point representing integer coordinates of some points on the 2d...
Min Cost to Connect All Points
average-salary-excluding-the-minimum-and-maximum-salary
You are given an array `points` representing integer coordinates of some points on a 2D-plane, where `points[i] = [xi, yi]`. The cost of connecting two points `[xi, yi]` and `[xj, yj]` is the **manhattan distance** between them: `|xi - xj| + |yi - yj|`, where `|val|` denotes the absolute value of `val`. Return _the m...
Get the total sum and subtract the minimum and maximum value in the array. Finally divide the result by n - 2.
Array,Sorting
Easy
null
296
hey everybody this is Larry this is me doing week three of the Leo premium challenge uh I haven't done it before and it's a hard so let's see how long this goes uh hit the like button hit the Subscribe button join me on Discord let me know what you think about today's F uh here I am in taipe uh no intro today so yeah u...
Best Meeting Point
best-meeting-point
Given an `m x n` binary grid `grid` where each `1` marks the home of one friend, return _the minimal **total travel distance**_. The **total travel distance** is the sum of the distances between the houses of the friends and the meeting point. The distance is calculated using [Manhattan Distance](http://en.wikipedia....
Try to solve it in one dimension first. How can this solution apply to the two dimension case?
Array,Math,Sorting,Matrix
Hard
317,462
147
what's up i'm going to solve insertion list on leak code sort a linked list using insertion sort a graphical example of insertion sort the partial sorted list which is the black initially contains only the first element in the list with each iteration one element which is read is removed from the input data and inserte...
Insertion Sort List
insertion-sort-list
Given the `head` of a singly linked list, sort the list using **insertion sort**, and return _the sorted list's head_. The steps of the **insertion sort** algorithm: 1. Insertion sort iterates, consuming one input element each repetition and growing a sorted output list. 2. At each iteration, insertion sort removes...
null
Linked List,Sorting
Medium
148,850
229
hey everybody this is Larry this is Day fth of the Leo daily challenge hit the like button hit the Subscribe button join me on Discord let me know what you think about this problem if it ever loads why is my computer so slow I don't know uh so slow for lead code what is going on uh all right today's problem is H am I l...
Majority Element II
majority-element-ii
Given an integer array of size `n`, find all elements that appear more than `⌊ n/3 ⌋` times. **Example 1:** **Input:** nums = \[3,2,3\] **Output:** \[3\] **Example 2:** **Input:** nums = \[1\] **Output:** \[1\] **Example 3:** **Input:** nums = \[1,2\] **Output:** \[1,2\] **Constraints:** * `1 <= nums.length <...
How many majority elements could it possibly have? Do you have a better hint? Suggest it!
Array,Hash Table,Sorting,Counting
Medium
169,1102
375
so today we will be doing a lead code question number 375 that is guess number higher or lower so what is the Crux of the question is that we will be given a range from 1 up till 7 and we will be guessing some number let's say that we guessed 2 so now the now I will be said that the number which is chosen already as my...
Guess Number Higher or Lower II
guess-number-higher-or-lower-ii
We are playing the Guessing Game. The game will work as follows: 1. I pick a number between `1` and `n`. 2. You guess a number. 3. If you guess the right number, **you win the game**. 4. If you guess the wrong number, then I will tell you whether the number I picked is **higher or lower**, and you will continue gu...
The best strategy to play the game is to minimize the maximum loss you could possibly face. Another strategy is to minimize the expected loss. Here, we are interested in the first scenario. Take a small example (n = 3). What do you end up paying in the worst case? Check out this article if you're still stuck. The purel...
Math,Dynamic Programming,Game Theory
Medium
294,374,464,658
198
hey guys it's offi1 here and today we're going to be solving House robber in this problem we're told that we're a professional robber and we're planning to rob houses along the street each house has a certain amount of money stashed and the only constraint stopping us from robbing each of them is that the adjacent hous...
House Robber
house-robber
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security systems connected and **it will automatically contact the police if two adjacent houses were broken into...
null
Array,Dynamic Programming
Medium
152,213,256,276,337,600,656,740,2262
1,910
So Hi Everyone this is Abhay Mittal and today we will be doing a question in this video which is which question of lead code 1910 11 19 and 10 so this is the question and what you have to do in this question is remove all traces of a If the sub string is fine, then what you have to do in this is that whatever sub strin...
Remove All Occurrences of a Substring
check-if-binary-string-has-at-most-one-segment-of-ones
Given two strings `s` and `part`, perform the following operation on `s` until **all** occurrences of the substring `part` are removed: * Find the **leftmost** occurrence of the substring `part` and **remove** it from `s`. Return `s` _after removing all occurrences of_ `part`. A **substring** is a contiguous seque...
It's guaranteed to have at least one segment The string size is small so you can count all segments of ones with no that have no adjacent ones.
String
Easy
1999
702
That high court se divide yes powder number 02 113 according to pinpoint not only multiple times but Google pass smart subscribe problem that get function qualities in eyes to tears lifted highlighted problem limit for be id - subscribe to the first come for time complexity of authors english chemist Option substance c...
Search in a Sorted Array of Unknown Size
search-in-a-sorted-array-of-unknown-size
This is an **_interactive problem_**. You have a sorted array of **unique** elements and an **unknown size**. You do not have an access to the array but you can use the `ArrayReader` interface to access it. You can call `ArrayReader.get(i)` that: * returns the value at the `ith` index (**0-indexed**) of the secret ...
null
null
Medium
null
893
yeahyeah Hi Hi Hi everyone, I'm a programmer. Today I'm going to introduce to you a math problem that involves multiplication after groups of equivalent strings, especially detailed topics like Then you will be given a copy A consisting of strings, then it is defined that an internal move consists of swapping any two c...
Groups of Special-Equivalent Strings
all-nodes-distance-k-in-binary-tree
You are given an array of strings of the same length `words`. In one **move**, you can swap any two even indexed characters or any two odd indexed characters of a string `words[i]`. Two strings `words[i]` and `words[j]` are **special-equivalent** if after any number of moves, `words[i] == words[j]`. * For example,...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Medium
null
20
Hello everyone, Evgeniy Sulima, today we will look at solving the problem easily from number twenty, valid brackets according to the conditions of this problem are given to me from lines that contain only the following set of characters, that is, open and close rounded curly and square brackets and I also eat that give...
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
1,254
hello so continuing on this lead code contest 162 the third problem was a 1 to 5 for number of closed islands and the problem says we get a grid that has zeros and ones zero represents land and one represents water and consider an island to be a maximal four directionally connected group of zeros that's basically what ...
Number of Closed Islands
deepest-leaves-sum
Given a 2D `grid` consists of `0s` (land) and `1s` (water). An _island_ is a maximal 4-directionally connected group of `0s` and a _closed island_ is an island **totally** (all left, top, right, bottom) surrounded by `1s.` Return the number of _closed islands_. **Example 1:** **Input:** grid = \[\[1,1,1,1,1,1,1,0\],...
Traverse the tree to find the max depth. Traverse the tree again to compute the sum required.
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Medium
null
314
to solve legal question 314 binary tree vertical order traversal it's a median legal question so given the root of any binary tree return the vertical order traversal of its node's value from top to bottom column by column so there's an example here if two nodes are the same row and column the order should be from left...
Binary Tree Vertical Order Traversal
binary-tree-vertical-order-traversal
Given the `root` of a binary tree, return _**the vertical order traversal** of its nodes' values_. (i.e., from top to bottom, column by column). If two nodes are in the same row and column, the order should be from **left to right**. **Example 1:** **Input:** root = \[3,9,20,null,null,15,7\] **Output:** \[\[9\],\[3,...
null
Hash Table,Tree,Depth-First Search,Breadth-First Search,Binary Tree
Medium
102
1,968
hey everyone welcome back and let's write some more neat code today so today let's solve the problem array with elements not equal to the average of its neighbors we're given an array of distinct integers and we just want to rearrange the values in that array such that any particular value in the array such as 3 is not...
Array With Elements Not Equal to Average of Neighbors
maximum-building-height
You are given a **0-indexed** array `nums` of **distinct** integers. You want to rearrange the elements in the array such that every element in the rearranged array is **not** equal to the **average** of its neighbors. More formally, the rearranged array should have the property such that for every `i` in the range `1...
Is it possible to find the max height if given the height range of a particular building? You can find the height range of a restricted building by doing 2 passes from the left and right.
Array,Math
Hard
null
718
hey everybody this is larry this is day eight of the july leco daily challenge hit the like button hit the subscribe button join me in discord let me know what you think um it's already a week into july i hope everyone's doing all right keep that streak going and let's go over today's problem maximum length of repeated...
Maximum Length of Repeated Subarray
maximum-length-of-repeated-subarray
Given two integer arrays `nums1` and `nums2`, return _the maximum length of a subarray that appears in **both** arrays_. **Example 1:** **Input:** nums1 = \[1,2,3,2,1\], nums2 = \[3,2,1,4,7\] **Output:** 3 **Explanation:** The repeated subarray with maximum length is \[3,2,1\]. **Example 2:** **Input:** nums1 = \[0...
Use dynamic programming. dp[i][j] will be the answer for inputs A[i:], B[j:].
Array,Binary Search,Dynamic Programming,Sliding Window,Rolling Hash,Hash Function
Medium
209,2051
1,286
in this problem we have to design an iterator class and that iterator would support two methods or one will be to check whether next exists or not as next and the other one will be to get the next so what we will try to get here so you must have studied about actuators in different containers in languages like so for e...
Iterator for Combination
constrained-subsequence-sum
Design the `CombinationIterator` class: * `CombinationIterator(string characters, int combinationLength)` Initializes the object with a string `characters` of **sorted distinct** lowercase English letters and a number `combinationLength` as arguments. * `next()` Returns the next combination of length `combinationL...
Use dynamic programming. Let dp[i] be the solution for the prefix of the array that ends at index i, if the element at index i is in the subsequence. dp[i] = nums[i] + max(0, dp[i-k], dp[i-k+1], ..., dp[i-1]) Use a heap with the sliding window technique to optimize the dp.
Array,Dynamic Programming,Queue,Sliding Window,Heap (Priority Queue),Monotonic Queue
Hard
null
79
Hello Hi Guys Welcome To Our Dhundhi Si Today We Will Go Through 321 Problem Light Ko Challenge Word Search Please Like Video And Don't Forget To Subscribe To Our Channel Never Miss Any Update On Ho Gayi 120 Board And Word Find The Word You Can Be Constructed From Letters of Sequential Different Cells to Juice and Cell...
Word Search
word-search
Given an `m x n` grid of characters `board` and a string `word`, return `true` _if_ `word` _exists in the grid_. The word can be constructed from letters of sequentially adjacent cells, where adjacent cells are horizontally or vertically neighboring. The same letter cell may not be used more than once. **Example 1:**...
null
Array,Backtracking,Matrix
Medium
212
34
Hello everyone Udayveer what position of elements for kids wear hai to janma chayan hai designer targeted to find lots of number three to the number 108 name - The Video then subscribe to the name - The Video then subscribe to the name - The Video then subscribe to the Page 10 class 5 by two Ajay ko ki hero plus five b...
Find First and Last Position of Element in Sorted Array
find-first-and-last-position-of-element-in-sorted-array
Given an array of integers `nums` sorted in non-decreasing order, find the starting and ending position of a given `target` value. If `target` is not found in the array, return `[-1, -1]`. You must write an algorithm with `O(log n)` runtime complexity. **Example 1:** **Input:** nums = \[5,7,7,8,8,10\], target = 8 *...
null
Array,Binary Search
Medium
278,2165,2210
458
hello everyone welcome back here is vamson with another life coding uh challenge so today we got a fun coding challenge line up uh if you ever wonder how many pigs you would need to find out which bucket of water is poisonous well you are in right uh to find out uh all right so here's the problem statement we have a ce...
Poor Pigs
poor-pigs
There are `buckets` buckets of liquid, where **exactly one** of the buckets is poisonous. To figure out which one is poisonous, you feed some number of (poor) pigs the liquid to see whether they will die or not. Unfortunately, you only have `minutesToTest` minutes to determine which bucket is poisonous. You can feed t...
What if you only have one shot? Eg. 4 buckets, 15 mins to die, and 15 mins to test. How many states can we generate with x pigs and T tests? Find minimum x such that (T+1)^x >= N
Math,Dynamic Programming,Combinatorics
Hard
null
71
Hi everyone, I am Nishant and you have joined with the entry. In this video series, we will prepare for the interview by doing a lot of questions of lead code, so which question are we going to do today, let's see let's dive in. Hi everyone, I am Nishant. Entry from Elevate Hindi and today we are going to solve problem...
Simplify Path
simplify-path
Given a string `path`, which is an **absolute path** (starting with a slash `'/'`) to a file or directory in a Unix-style file system, convert it to the simplified **canonical path**. In a Unix-style file system, a period `'.'` refers to the current directory, a double period `'..'` refers to the directory up a level,...
null
String,Stack
Medium
null
901
hi everyone so let's talk about the online stock span so basically the span of the stock price today is defined as the maximum number of consecutive states so this is an important keyword for which the stock price was less than or equal to today price so i'm going to just uh quickly go over it so um at first i wasn't s...
Online Stock Span
advantage-shuffle
Design an algorithm that collects daily price quotes for some stock and returns **the span** of that stock's price for the current day. The **span** of the stock's price in one day is the maximum number of consecutive days (starting from that day and going backward) for which the stock price was less than or equal to ...
null
Array,Greedy,Sorting
Medium
null
47
foreign number 47 permutations 2. so the only difference is we have duplicate numbers inside the nums for example this is one two and we're gonna return one two one and two one let me first explain it in whiteboard and then go back to the code editor yeah to code it up for example we have one to two as our permutations...
Permutations II
permutations-ii
Given a collection of numbers, `nums`, that might contain duplicates, return _all possible unique permutations **in any order**._ **Example 1:** **Input:** nums = \[1,1,2\] **Output:** \[\[1,1,2\], \[1,2,1\], \[2,1,1\]\] **Example 2:** **Input:** nums = \[1,2,3\] **Output:** \[\[1,2,3\],\[1,3,2\],\[2,1,3\],\[2,3,...
null
Array,Backtracking
Medium
31,46,267,1038
399
hey what's up guys this is chung here so today uh let's revisit this problem 399 evaluate division you know so yesterday i we talked about this problem by utilizing uh like a graph and a dfs search solutions approach where you can call it basically we uh we just built like a graph with the edge from this a to b and wit...
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
617
hi guys welcome to algorithms made easy my name is khushbu and in this video we are going to see the question merge two binary trees you are given two binary tree root one and root two imagine that when you put one of them to cover the other some nodes of the two trees are overlapped while the others are not you need t...
Merge Two Binary Trees
merge-two-binary-trees
You are given two binary trees `root1` and `root2`. Imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not. You need to merge the two trees into a new binary tree. The merge rule is that if two nodes overlap, then sum node values up as the new valu...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Easy
null
89
hey coders welcome back to my youtube channel today we will be discussing a very famous coding question that is called gray code so what is a gray code the gray code is a binary numeral system where two successive values differ in only one bit for example this 0 1 0 so for example these two numbers they are differing b...
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
994
hey everybody this is larry this is me doing day 29 of the october uh lead code daily challenge live so hit the like button in the subscriber and join me on discord let me know what you think and as i said these are live so it's a little bit slow just fast forward whatever you need to do i today i may be rushing a litt...
Rotting Oranges
prison-cells-after-n-days
You are given an `m x n` `grid` where each cell can have one of three values: * `0` representing an empty cell, * `1` representing a fresh orange, or * `2` representing a rotten orange. Every minute, any fresh orange that is **4-directionally adjacent** to a rotten orange becomes rotten. Return _the minimum nu...
null
Array,Hash Table,Math,Bit Manipulation
Medium
null
216
welcome back guys today we're gonna solve this lead code medium level question combination sum three total down my shoes eurostat my move i just cut the ring yeah my fingers hope on a finer thanks in this question we'll be given k and n as input and we need to find every possible combination of length k so that every i...
Combination Sum III
combination-sum-iii
Find all valid combinations of `k` numbers that sum up to `n` such that the following conditions are true: * Only numbers `1` through `9` are used. * Each number is used **at most once**. Return _a list of all possible valid combinations_. The list must not contain the same combination twice, and the combinations...
null
Array,Backtracking
Medium
39
1,315
Hello hello friends today in this video winner discuss mother problem sombir kodan problem name sex notes with life lived reference choudhary cant see independent states that you are giving up by ministry and after 10 years the value of the notes with valid and now you must know the Diamond Club in Tricks The Con is No...
Sum of Nodes with Even-Valued Grandparent
sum-of-nodes-with-even-valued-grandparent
Given the `root` of a binary tree, return _the sum of values of nodes with an **even-valued grandparent**_. If there are no nodes with an **even-valued grandparent**, return `0`. A **grandparent** of a node is the parent of its parent if it exists. **Example 1:** **Input:** root = \[6,7,8,2,7,1,3,9,null,1,4,null,nul...
null
null
Medium
null
823
hey everybody this is larry this is day 13 from the march the code daily challenge hit the like button hit the subscribe button drum and discord let's hang out uh ask me questions okay today's promise binary trees were factors oh i just woke up so my eyes are a little bit winky uh yeah so i stopped this live it's a lit...
Binary Trees With Factors
split-array-with-same-average
Given an array of unique integers, `arr`, where each integer `arr[i]` is strictly greater than `1`. We make a binary tree using these integers, and each number may be used for any number of times. Each non-leaf node's value should be equal to the product of the values of its children. Return _the number of binary tre...
null
Array,Math,Dynamic Programming,Bit Manipulation,Bitmask
Hard
2162
42
hi everybody so let's talk about chopping ring water so you're given a non-negative integer so you're given a non-negative integer so you're given a non-negative integer representing an evaluation map where the width of each bar is one computing how much water it can be trapped after running so you're giving the intege...
Trapping Rain Water
trapping-rain-water
Given `n` non-negative integers representing an elevation map where the width of each bar is `1`, compute how much water it can trap after raining. **Example 1:** **Input:** height = \[0,1,0,2,1,0,1,3,2,1,2,1\] **Output:** 6 **Explanation:** The above elevation map (black section) is represented by array \[0,1,0,2,1,...
null
Array,Two Pointers,Dynamic Programming,Stack,Monotonic Stack
Hard
11,238,407,756
1,942
hey what's up guys this is chung here again so this time number 1942 the number of the smallest unoccupied chair so we have n friends right from zero to n minus one and we have an infinite number of chairs in the party that's a number from zero to infinity so when a friend arrives at the party they sit on an occupied c...
The Number of the Smallest Unoccupied Chair
primary-department-for-each-employee
There is a party where `n` friends numbered from `0` to `n - 1` are attending. There is an **infinite** number of chairs in this party that are numbered from `0` to `infinity`. When a friend arrives at the party, they sit on the unoccupied chair with the **smallest number**. * For example, if chairs `0`, `1`, and `5...
null
Database
Easy
null
3
hello guys Welcome to our YouTube channel today we will see the problem of lead code that is longest substring without repeating characters in this problem we have string s and now we have to calculate the maximum length the longest substring that has no repeating character okay fine so let's take this example but we n...
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,877
Hi Haldighati My name is Rohit and welcome to my channel code YouTube Channel and subscribe comment and Chocolate Chapter Question without first ingredient Usse Means Minimizes Maximizes Pair Time Hey phone, first of all read the question, you will see this cross and then we will dip the people Solve it like this Hello...
Minimize Maximum Pair Sum in Array
find-followers-count
The **pair sum** of a pair `(a,b)` is equal to `a + b`. The **maximum pair sum** is the largest **pair sum** in a list of pairs. * For example, if we have pairs `(1,5)`, `(2,3)`, and `(4,4)`, the **maximum pair sum** would be `max(1+5, 2+3, 4+4) = max(6, 5, 8) = 8`. Given an array `nums` of **even** length `n`, pai...
null
Database
Easy
null
518
lead code problem number 518 coin change to so this problem gives us an integer array called coins which represents the coins of different denominations and an integer called amount which represents the total amount of money so the goal is to return the number of combinations that make up to that amount and if that amo...
Coin Change II
coin-change-2
You are given an integer array `coins` representing coins of different denominations and an integer `amount` representing a total amount of money. Return _the number of combinations that make up that amount_. If that amount of money cannot be made up by any combination of the coins, return `0`. You may assume that yo...
null
Array,Dynamic Programming
Medium
1393
1,238
so today we are doing this problem from little contest 116 so the problem is 1 2 3 8 and says that we have a circular permutation in a binary representation that's the title now what is the problem we get two integers and start and we want to return any permutation from 0 to 2 to the power of n minus 1 such that every ...
Circular Permutation in Binary Representation
alphabet-board-path
Given 2 integers `n` and `start`. Your task is return **any** permutation `p` of `(0,1,2.....,2^n -1)` such that : * `p[0] = start` * `p[i]` and `p[i+1]` differ by only one bit in their binary representation. * `p[0]` and `p[2^n -1]` must also differ by only one bit in their binary representation. **Example 1:*...
Create a hashmap from letter to position on the board. Now for each letter, try moving there in steps, where at each step you check if it is inside the boundaries of the board.
Hash Table,String
Medium
null
1,092
Okay so hello everyone this is Akshay here today we are going to see questions from all the other types of LCS the important questions among them are Shortest Common Super Sequence Hard Category we will cover these but before that we have two more questions which we will Will cover Delete Operation for Two Strings and ...
Shortest Common Supersequence
maximum-difference-between-node-and-ancestor
Given two strings `str1` and `str2`, return _the shortest string that has both_ `str1` _and_ `str2` _as **subsequences**_. If there are multiple valid strings, return **any** of them. A string `s` is a **subsequence** of string `t` if deleting some number of characters from `t` (possibly `0`) results in the string `s`...
For each subtree, find the minimum value and maximum value of its descendants.
Tree,Depth-First Search,Binary Tree
Medium
null
1,838
hey and welcome to today's daily lead code challenge today we'll be solving question 1,838 frequency of most frequent 1,838 frequency of most frequent 1,838 frequency of most frequent element let's get straight to the drawing phase or the drawing portion um I want to read this carefully the frequency of an element is t...
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
122
what's up guys Leeds is elite called 122 there's time to buy and sell stop to say you'll have been already prices or which a I've element is the price of the given is talk on a day I design an algorithm to find the maximum profit you may complete as many transactions as you like for example buy one and sell one share o...
Best Time to Buy and Sell Stock II
best-time-to-buy-and-sell-stock-ii
You are given an integer array `prices` where `prices[i]` is the price of a given stock on the `ith` day. On each day, you may decide to buy and/or sell the stock. You can only hold **at most one** share of the stock at any time. However, you can buy it then immediately sell it on the **same day**. Find and return _t...
null
Array,Dynamic Programming,Greedy
Medium
121,123,188,309,714
145
Hua hai Hua hai Hua hai Hello hello everyone wearing today Solve mindtree poster traversal problem So let's understand what is most wanted poster Means post office has to add printer and factory Printed salwar at this time Creams and finally you printing Very soft ware Printed fruit full length find the best to travel ...
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
1,007
all right let's talk about the minimum dominant rotation for equal rule so you are given a top and bottoms array and then you have to return the minimum number of rotations so that all the values in the top are the same all the bottom are the same so if you cannot do it then you'll turn it on one right so uh i'm gonna ...
Minimum Domino Rotations For Equal Row
numbers-with-same-consecutive-differences
In a row of dominoes, `tops[i]` and `bottoms[i]` represent the top and bottom halves of the `ith` domino. (A domino is a tile with two numbers from 1 to 6 - one on each half of the tile.) We may rotate the `ith` domino, so that `tops[i]` and `bottoms[i]` swap values. Return the minimum number of rotations so that all...
null
Backtracking,Breadth-First Search
Medium
null
253
hey everyone welcome to another video in the algorithm and dash structures series um today we're going to be taking a look at another weak code problem this one's a medium and it's called meeting rooms two so the problem statement we have today is given an array of meaning time intervals where intervals sub i equals st...
Meeting Rooms II
meeting-rooms-ii
Given an array of meeting time intervals `intervals` where `intervals[i] = [starti, endi]`, return _the minimum number of conference rooms required_. **Example 1:** **Input:** intervals = \[\[0,30\],\[5,10\],\[15,20\]\] **Output:** 2 **Example 2:** **Input:** intervals = \[\[7,10\],\[2,4\]\] **Output:** 1 **Constr...
Think about how we would approach this problem in a very simplistic way. We will allocate rooms to meetings that occur earlier in the day v/s the ones that occur later on, right? If you've figured out that we have to sort the meetings by their start time, the next thing to think about is how do we do the allocation? Th...
Array,Two Pointers,Greedy,Sorting,Heap (Priority Queue)
Medium
56,252,452,1184
1,282
hello everyone welcome to another video now in this video we are going to look at this question which is of medium level difficulty and this is quite easy if you know like what if you know the concept that we have covered in our easy level question if you are a regular solver of uh easy level questions then there is no...
Group the People Given the Group Size They Belong To
number-of-valid-words-for-each-puzzle
There are `n` people that are split into some unknown number of groups. Each person is labeled with a **unique ID** from `0` to `n - 1`. You are given an integer array `groupSizes`, where `groupSizes[i]` is the size of the group that person `i` is in. For example, if `groupSizes[1] = 3`, then person `1` must be in a g...
Exploit the fact that the length of the puzzle is only 7. Use bit-masks to represent the word and puzzle strings. For each puzzle, count the number of words whose bit-mask is a sub-mask of the puzzle's bit-mask.
Array,Hash Table,String,Bit Manipulation,Trie
Hard
null
729
hi guys we are live today and we continue with binary search uh so let's share our screen okay so we have today the next task that calls my calendar and the task is the following so uh we should Implement a program that called my calendar uh in this program we can add new event and uh what does me event uh double booki...
My Calendar I
my-calendar-i
You are implementing a program to use as your calendar. We can add a new event if adding the event will not cause a **double booking**. A **double booking** happens when two events have some non-empty intersection (i.e., some moment is common to both events.). The event can be represented as a pair of integers `start...
Store the events as a sorted list of intervals. If none of the events conflict, then the new event can be added.
Design,Segment Tree,Ordered Set
Medium
731,732
108
version 108 converted sorted convert sorted array to binary search tree given an integer array noms where the elements are sorted in ascending order so an array of integers is given to us and these numbers are sorted in ascending order the question is asking us to convert this array to a height balance binary tree so w...
Convert Sorted Array to Binary Search Tree
convert-sorted-array-to-binary-search-tree
Given an integer array `nums` where the elements are sorted in **ascending order**, convert _it to a_ **_height-balanced_** _binary search tree_. **Example 1:** **Input:** nums = \[-10,-3,0,5,9\] **Output:** \[0,-3,9,-10,null,5\] **Explanation:** \[0,-10,5,null,-3,null,9\] is also accepted: **Example 2:** **Input...
null
Array,Divide and Conquer,Tree,Binary Search Tree,Binary Tree
Easy
109
1,465
hey guys how's reading this is Jay sir in this video I'm going to take a look at one four six five maximum area of a piece of cake after horizontal and vertical cut we're giving a rectangular cake with a high height H and width W and two arrays of integers horizontal cuts and a vertical cut and we're her wear horizonta...
Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts
maximum-product-of-splitted-binary-tree
You are given a rectangular cake of size `h x w` and two arrays of integers `horizontalCuts` and `verticalCuts` where: * `horizontalCuts[i]` is the distance from the top of the rectangular cake to the `ith` horizontal cut and similarly, and * `verticalCuts[j]` is the distance from the left of the rectangular cake ...
If we know the sum of a subtree, the answer is max( (total_sum - subtree_sum) * subtree_sum) in each node.
Tree,Depth-First Search,Binary Tree
Medium
2175
71
now let's move on to the actual coding if you remember from the previous video where we talked about the intuition behind the static I said using a stack may not be the optimal solution so why is that in this case if you are given a input ring let look like that looks like this your final result should be ABC right now...
Simplify Path
simplify-path
Given a string `path`, which is an **absolute path** (starting with a slash `'/'`) to a file or directory in a Unix-style file system, convert it to the simplified **canonical path**. In a Unix-style file system, a period `'.'` refers to the current directory, a double period `'..'` refers to the directory up a level,...
null
String,Stack
Medium
null
190
welcome back to our adjust today's question is leak code 190 reverse bits so all this question is asking is for us to reverse bits of a given 32 bits unsigned integer so as you can see in example one we have this 32-bit integer example one we have this 32-bit integer example one we have this 32-bit integer and we need ...
Reverse Bits
reverse-bits
Reverse bits of a given 32 bits unsigned integer. **Note:** * Note that in some languages, such as Java, there is no unsigned integer type. In this case, both input and output will be given as a signed integer type. They should not affect your implementation, as the integer's internal binary representation is the s...
null
Divide and Conquer,Bit Manipulation
Easy
7,191,2238
378
okay so lead code practice time uh so there are two goals in this video the first one is to see how to solve this problem and also we are going to do some coding work on top of it and the second goal is to see um how to behave during interviews suppose this is um a question given real interview so let's get started um ...
Kth Smallest Element in a Sorted Matrix
kth-smallest-element-in-a-sorted-matrix
Given an `n x n` `matrix` where each of the rows and columns is sorted in ascending order, return _the_ `kth` _smallest element in the matrix_. Note that it is the `kth` smallest element **in the sorted order**, not the `kth` **distinct** element. You must find a solution with a memory complexity better than `O(n2)`....
null
Array,Binary Search,Sorting,Heap (Priority Queue),Matrix
Medium
373,668,719,802
424
hi everyone today we are going to solve the readable question longest repeating character replacement so you are giving a string s and the 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 l...
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
11
hello everyone welcome to harsha lectures in this lecture i am going to explain you about container with most water given and non-negative integers a1 a2 so given and non-negative integers a1 a2 so given and non-negative integers a1 a2 so on n where each represents a pointed coordinate i comma a i and vertical lines ar...
Container With Most Water
container-with-most-water
You are given an integer array `height` of length `n`. There are `n` vertical lines drawn such that the two endpoints of the `ith` line are `(i, 0)` and `(i, height[i])`. Find two lines that together with the x-axis form a container, such that the container contains the most water. Return _the maximum amount of water...
The aim is to maximize the area formed between the vertical lines. The area of any container is calculated using the shorter line as length and the distance between the lines as the width of the rectangle. Area = length of shorter vertical line * distance between lines We can definitely get the maximum width ...
Array,Two Pointers,Greedy
Medium
42
1,359
hey everyone welcome back and let's write some more neat code today so today let's solve the problem count all valid pickup and delivery options this one is a hard but it's actually easier than you would think especially if you are good at like discrete math and more specifically if you're good at like combinatorics an...
Count All Valid Pickup and Delivery Options
circular-permutation-in-binary-representation
Given `n` orders, each order consist in pickup and delivery services. Count all valid pickup/delivery possible sequences such that delivery(i) is always after of pickup(i). Since the answer may be too large, return it modulo 10^9 + 7. **Example 1:** **Input:** n = 1 **Output:** 1 **Explanation:** Unique order (P1, ...
Use gray code to generate a n-bit sequence. Rotate the sequence such that its first element is start.
Math,Backtracking,Bit Manipulation
Medium
null
377
hello hi guys good morning welcome back to the new video so basically in this video from combination some four although like it's an easy problem so you should be able to do it if you have seen the last videos or if you have been watching us for the last month so like last one month so you should be able to solve it bu...
Combination Sum IV
combination-sum-iv
Given an array of **distinct** integers `nums` and a target integer `target`, return _the number of possible combinations that add up to_ `target`. The test cases are generated so that the answer can fit in a **32-bit** integer. **Example 1:** **Input:** nums = \[1,2,3\], target = 4 **Output:** 7 **Explanation:** Th...
null
Array,Dynamic Programming
Medium
39
1,710
Hello guys, today we will leave Delhi question because if you keep maximum units omelette then what is the giver in the head of this question, we have life in which I show any person that I can market you, as if in this effort What is the giver that we have been given a boxer, meaning in every studio, every girl is sin...
Maximum Units on a Truck
find-servers-that-handled-most-number-of-requests
You are assigned to put some amount of boxes onto **one truck**. You are given a 2D array `boxTypes`, where `boxTypes[i] = [numberOfBoxesi, numberOfUnitsPerBoxi]`: * `numberOfBoxesi` is the number of boxes of type `i`. * `numberOfUnitsPerBoxi` is the number of units in each box of the type `i`. You are also given...
To speed up the next available server search, keep track of the available servers in a sorted structure such as an ordered set. To determine if a server is available, keep track of the end times for each task in a heap and add the server to the available set once the soonest task ending time is less than or equal to th...
Array,Greedy,Heap (Priority Queue),Ordered Set
Hard
null
1,944
here is the question 1944 we have n people standing on Q and they numbered from Z zero to n minus one and the height are like distinct integers and high represent the height of I personis you can see another person to the right if everyone is shorter than both of them like okay so we return an array answer of the l n s...
Number of Visible People in a Queue
truncate-sentence
There are `n` people standing in a queue, and they numbered from `0` to `n - 1` in **left to right** order. You are given an array `heights` of **distinct** integers where `heights[i]` represents the height of the `ith` person. A person can **see** another person to their right in the queue if everybody in between is ...
It's easier to solve this problem on an array of strings so parse the string to an array of words After return the first k words as a sentence
Array,String
Easy
null
1,844
foreign so we're going to continue our 1844 question replacing all digits with characters now in our last uh video I was not able to figure it out now after looking into it I realized there is couple things that we should have done or should change um for instance there's multiple way of doing it however in this instan...
Replace All Digits with Characters
maximum-number-of-balls-in-a-box
You are given a **0-indexed** string `s` that has lowercase English letters in its **even** indices and digits in its **odd** indices. There is a function `shift(c, x)`, where `c` is a character and `x` is a digit, that returns the `xth` character after `c`. * For example, `shift('a', 5) = 'f'` and `shift('x', 0) =...
Note that both lowLimit and highLimit are of small constraints so you can iterate on all nubmer between them You can simulate the boxes by counting for each box the number of balls with digit sum equal to that box number
Hash Table,Math,Counting
Easy
null
1,706
hey everybody this is Larry this is the first of November hit the like button hit the Subscribe button join me on Discord let me know what you think about today's problem we'll be doing it all week or all month until whenever I don't know if you're new here I have a four uh 944 day streak hopefully 9 55 after this and ...
Where Will the Ball Fall
min-cost-to-connect-all-points
You have a 2-D `grid` of size `m x n` representing a box, and you have `n` balls. The box is open on the top and bottom sides. Each cell in the box has a diagonal board spanning two corners of the cell that can redirect a ball to the right or to the left. * A board that redirects the ball to the right spans the top...
Connect each pair of points with a weighted edge, the weight being the manhattan distance between those points. The problem is now the cost of minimum spanning tree in graph with above edges.
Array,Union Find,Minimum Spanning Tree
Medium
2287
1,610
today's question is maximum number of visible points let us see what is the question so we are given with an array of points an integer angle and your location so this is an array and then we have an angle and location is um also an array which contains position of x position of y so these are coordinates x coordinate ...
Maximum Number of Visible Points
xor-operation-in-an-array
You are given an array `points`, an integer `angle`, and your `location`, where `location = [posx, posy]` and `points[i] = [xi, yi]` both denote **integral coordinates** on the X-Y plane. Initially, you are facing directly east from your position. You **cannot move** from your position, but you can **rotate**. In othe...
Simulate the process, create an array nums and return the Bitwise XOR of all elements of it.
Math,Bit Manipulation
Easy
null
791
hey guys welcome to a new video in today's video we're going to look at a lead code problem and the problem's name is custom sort string so in this question we given two strings order and S all the characters of order are unique and were sorted in some custom order previously so order will give us the order in which we...
Custom Sort String
split-bst
You are given two strings order and s. All the characters of `order` are **unique** and were sorted in some custom order previously. Permute the characters of `s` so that they match the order that `order` was sorted. More specifically, if a character `x` occurs before a character `y` in `order`, then `x` should occur ...
Use recursion. If root.val <= V, you split root.right into two halves, then join it's left half back on root.right.
Tree,Binary Search Tree,Recursion,Binary Tree
Medium
450
1,743
hello shangi I hope that you guys are doing good so as in this video we're going to see this problem restor the array from adjacent pairs it has been asked by Uber Capital 1 Robin Hood so let's see this problem statement itself it's going to be a bit tricky but as soon as you got the solution you can just relate it rig...
Restore the Array From Adjacent Pairs
count-substrings-that-differ-by-one-character
There is an integer array `nums` that consists of `n` **unique** elements, but you have forgotten it. However, you do remember every pair of adjacent elements in `nums`. You are given a 2D integer array `adjacentPairs` of size `n - 1` where each `adjacentPairs[i] = [ui, vi]` indicates that the elements `ui` and `vi` a...
Take every substring of s, change a character, and see how many substrings of t match that substring. Use a Trie to store all substrings of t as a dictionary.
Hash Table,String,Dynamic Programming
Medium
2256
202
first of all there is no such thing as a happy number it is just a problem statement and we have to solve for it i am talking about the problem happy number on lead code let us see what is it all about hello friends welcome back to my channel first i will explain you the problem statement and we will look at some sampl...
Happy Number
happy-number
Write an algorithm to determine if a number `n` is happy. A **happy number** is a number defined by the following process: * Starting with any positive integer, replace the number by the sum of the squares of its digits. * Repeat the process until the number equals 1 (where it will stay), or it **loops endlessly ...
null
Hash Table,Math,Two Pointers
Easy
141,258,263,2076
398
all right so today's question is 398 random pick index we are given an array of integers with possible duplicates we ask you to write something to write some code to randomly output the index of a given target number you can assume that the given target number must exist in the array so less corner case with either han...
Random Pick Index
random-pick-index
Given an integer array `nums` with possible **duplicates**, randomly output the index of a given `target` number. You can assume that the given target number must exist in the array. Implement the `Solution` class: * `Solution(int[] nums)` Initializes the object with the array `nums`. * `int pick(int target)` Pic...
null
Hash Table,Math,Reservoir Sampling,Randomized
Medium
382,894,912
86
Hello gas I am Lalita Agarwal welcome you who is owner on coding channel the trick is made by you so late na start today this lead card problem actually late ki problem kya bol rahi hai achha before going tu tours have problem na 1 minute session par Those who understand this problem well and have six to try, look at t...
Partition List
partition-list
Given the `head` of a linked list and a value `x`, partition it such that all nodes **less than** `x` come before nodes **greater than or equal** to `x`. You should **preserve** the original relative order of the nodes in each of the two partitions. **Example 1:** **Input:** head = \[1,4,3,2,5,2\], x = 3 **Output:**...
null
Linked List,Two Pointers
Medium
2265
132
hey everybody this is larry this is day seven of the august league daily challenge hit the like button hit the subscribe button join me on this call let me know what you think about today's problem pattern drum petitioning too so how's everyone doing hope uh this august month has been treating you well we'll weekend co...
Palindrome Partitioning II
palindrome-partitioning-ii
Given a string `s`, partition `s` such that every substring of the partition is a palindrome. Return _the **minimum** cuts needed for a palindrome partitioning of_ `s`. **Example 1:** **Input:** s = "aab " **Output:** 1 **Explanation:** The palindrome partitioning \[ "aa ", "b "\] could be produced using 1 cut. **...
null
String,Dynamic Programming
Hard
131,1871
883
welcome to about the training difficult solution if you want the best knocking of your experience in North America feel free to check us out and above the training door org so we provide the most real mock interviews from all the top interviewers from all these top companies so today we are going to talk about this pro...
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,609
hey everyone today we are going to solve theal equation even or3 okay so let me explain with this example so we have to check if even index level has integer value with strictly increasing order from left to right on the other hand we have to check if what index level has even integer value with decreasing order from l...
Even Odd Tree
find-all-the-lonely-nodes
A binary tree is named **Even-Odd** if it meets the following conditions: * The root of the binary tree is at level index `0`, its children are at level index `1`, their children are at level index `2`, etc. * For every **even-indexed** level, all nodes at the level have **odd** integer values in **strictly increa...
Do a simple tree traversal, try to check if the current node is lonely or not. Node is lonely if at least one of the left/right pointers is null.
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Easy
563,1005
116
hello everyone hope you all are doing well so i am back with another lit code daily challenge and it is lit code number 116 populating next right pointer in each node and it is a medial medium level question and i also feel the same so the question is you are given a perfect binary tree where all leaves are on the same...
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
150
hello guys and welcome back to lead Logics this is the evaluate reverse polish notation problem from lead code this is a lead code medium and the number for this is 150 so in this problem we are having an array of strings tokens that collectively represent a reverse polished notation of a expression so we have an arith...
Evaluate Reverse Polish Notation
evaluate-reverse-polish-notation
You are given an array of strings `tokens` that represents an arithmetic expression in a [Reverse Polish Notation](http://en.wikipedia.org/wiki/Reverse_Polish_notation). Evaluate the expression. Return _an integer that represents the value of the expression_. **Note** that: * The valid operators are `'+'`, `'-'`, ...
null
Array,Math,Stack
Medium
224,282
430
hey you out of there let's talk about today's liquid in China question it's called flatten a multi-level called flatten a multi-level called flatten a multi-level doubly-linked list so we have this thing doubly-linked list so we have this thing doubly-linked list so we have this thing that's called a multi-level doubly...
Flatten a Multilevel Doubly Linked List
flatten-a-multilevel-doubly-linked-list
You are given a doubly linked list, which contains nodes that have a next pointer, a previous pointer, and an additional **child pointer**. This child pointer may or may not point to a separate doubly linked list, also containing these special nodes. These child lists may have one or more children of their own, and so ...
null
null
Medium
null
1,510
hello everyone welcome back to decoding on this channel we discussed problems which are frequently asking programming interviews and today we are going to solve a problem from lead code VT contest the name of the problem is stone came for so let us see what the problem statement is Alice and Bob they take turn playing ...
Stone Game IV
find-lucky-integer-in-an-array
Alice and Bob take turns playing a game, with Alice starting first. Initially, there are `n` stones in a pile. On each player's turn, that player makes a _move_ consisting of removing **any** non-zero **square number** of stones in the pile. Also, if a player cannot make a move, he/she loses the game. Given a positi...
Count the frequency of each integer in the array. Get all lucky numbers and return the largest of them.
Array,Hash Table,Counting
Easy
null
350
Ajay Ko that welcome back to day today they are going to solid problem 30 intersection of tourists and the see tomorrow office problem 350 intersection of tourists to solve this problem now they are going to discuss and solve into a session before I started liking details into this Problem He Want To Mention The Type O...
Intersection of Two Arrays II
intersection-of-two-arrays-ii
Given two integer arrays `nums1` and `nums2`, return _an array of their intersection_. Each element in the result must appear as many times as it shows in both arrays and you may return the result in **any order**. **Example 1:** **Input:** nums1 = \[1,2,2,1\], nums2 = \[2,2\] **Output:** \[2,2\] **Example 2:** **I...
null
Array,Hash Table,Two Pointers,Binary Search,Sorting
Easy
349,1044,1392,2282
402
hello everyone welcome or welcome back to my channel so today we are going to discuss another problem but before going forward if you not like the video please like it subscribe to my channel and hit the bell icon so that you get notified whenever i post a new video so without any further ado let's get started so probl...
Remove K Digits
remove-k-digits
Given string num representing a non-negative integer `num`, and an integer `k`, return _the smallest possible integer after removing_ `k` _digits from_ `num`. **Example 1:** **Input:** num = "1432219 ", k = 3 **Output:** "1219 " **Explanation:** Remove the three digits 4, 3, and 2 to form the new number 1219 which ...
null
String,Stack,Greedy,Monotonic Stack
Medium
321,738,1792,2305
51
hey everybody this is larry this is june 4th uh of the lego day challenge hit the like button hit the subscribe button join me on discord let me know what you think about today's prom today's bomb seems to be a classic prom and queen so i guess we're no longer doing that prefix thing uh yeah end queen is a classic prob...
N-Queens
n-queens
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 _all distinct solutions to the **n-queens puzzle**_. You may return the answer in **any order**. Each solution contains a distinct board configuration of the n-...
null
Array,Backtracking
Hard
52,1043
1,091
In this video we will discuss this problem in the shortest lesson in binary matrix. In this you have been given a binary matrix. Binary matrix means that the value of each of your cells is either zero or one. In this you have to go from the starting to the last cell. And you have to go to minimum staff, what is the mea...
Shortest Path in Binary Matrix
maximum-average-subtree
Given an `n x n` binary matrix `grid`, return _the length of the shortest **clear path** in the matrix_. If there is no clear path, return `-1`. A **clear path** in a binary matrix is a path from the **top-left** cell (i.e., `(0, 0)`) to the **bottom-right** cell (i.e., `(n - 1, n - 1)`) such that: * All the visite...
Can you find the sum of values and the number of nodes for every sub-tree ? Can you find the sum of values and the number of nodes for a sub-tree given the sum of values and the number of nodes of it's left and right sub-trees ? Use depth first search to recursively find the solution for the children of a node then use...
Tree,Depth-First Search,Binary Tree
Medium
2126
32
hey what's up guys welcome back to this video in this video we're going to solve this query interview question the longest valid parenthesis the difficulty level of this question is hard in this problem we are given a string the string contains opening parenthesis or closing parenthesis we have to return the length of ...
Longest Valid Parentheses
longest-valid-parentheses
Given a string containing just the characters `'('` and `')'`, return _the length of the longest valid (well-formed) parentheses_ _substring_. **Example 1:** **Input:** s = "(() " **Output:** 2 **Explanation:** The longest valid parentheses substring is "() ". **Example 2:** **Input:** s = ")()()) " **Output:** ...
null
String,Dynamic Programming,Stack
Hard
20
999
So hi friends, in this video we are going to talk about the problem number 999 of elite code, its name is available capture for ruk, ok so this problem is very simple, what is given to us in this, what is a ruk, ok elephant that walks plus directions. OK, what we have to return is how many number of pawns are killed, O...
Available Captures for Rook
regions-cut-by-slashes
On an `8 x 8` chessboard, there is **exactly one** white rook `'R'` and some number of white bishops `'B'`, black pawns `'p'`, and empty squares `'.'`. When the rook moves, it chooses one of four cardinal directions (north, east, south, or west), then moves in that direction until it chooses to stop, reaches the edge ...
null
Depth-First Search,Breadth-First Search,Union Find,Graph
Medium
null
134
hello everyone i hope you're all doing really well so today in this video we'll go over this question which is generally being asked by amazon in their coding interview rounds the question goes by the name of gas station available on lead code and it's defined to be a medium difficulty problem so we'll quickly go over ...
Gas Station
gas-station
There are `n` gas stations along a circular route, where the amount of gas at the `ith` station is `gas[i]`. You have a car with an unlimited gas tank and it costs `cost[i]` of gas to travel from the `ith` station to its next `(i + 1)th` station. You begin the journey with an empty tank at one of the gas stations. Gi...
null
Array,Greedy
Medium
1346
920
hey everybody this is Larry this is day seven day six of the liko day challenge hit the like button and subscribe and join my Discord let me know what you think about today's Farm 920 number of Music uh music playlist musical playlist music playlist all right uh your music player contains and different songs you want t...
Number of Music Playlists
uncommon-words-from-two-sentences
Your music player contains `n` different songs. You want to listen to `goal` songs (not necessarily different) during your trip. To avoid boredom, you will create a playlist so that: * Every song is played **at least once**. * A song can only be played again only if `k` other songs have been played. Given `n`, `g...
null
Hash Table,String
Easy
2190