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,450
welcome back everyone we're going to be solving Lee code 1450 number of students doing homework at a given time so for this problem we are given two arrays start time and end time and a query time which is an integer and we need to check um whether this query time integer is within the start time and end time at the it...
Number of Students Doing Homework at a Given Time
delete-leaves-with-a-given-value
Given two integer arrays `startTime` and `endTime` and given an integer `queryTime`. The `ith` student started doing their homework at the time `startTime[i]` and finished it at time `endTime[i]`. Return _the number of students_ doing their homework at time `queryTime`. More formally, return the number of students wh...
Use the DFS to reconstruct the tree such that no leaf node is equal to the target. If the leaf node is equal to the target, return an empty object instead.
Tree,Depth-First Search,Binary Tree
Medium
null
334
um hello so today we are going to do this problem called increasing triplet subsequence which is part of lead code daily challenge um so the problem says we get an array of numbers and we want to return true if there exists a triple of indices i j k such that I is smaller than J and J is smaller than k and the numbers ...
Increasing Triplet Subsequence
increasing-triplet-subsequence
Given an integer array `nums`, return `true` _if there exists a triple of indices_ `(i, j, k)` _such that_ `i < j < k` _and_ `nums[i] < nums[j] < nums[k]`. If no such indices exists, return `false`. **Example 1:** **Input:** nums = \[1,2,3,4,5\] **Output:** true **Explanation:** Any triplet where i < j < k is valid. ...
null
Array,Greedy
Medium
300,2122,2280
295
Facility of Ice How are you all, today we are going to talk about problem number 3363 Leaders for Indians from data screen Okay, let's move ahead on this problem, why is this flour problem, now you will know, it is easy but the way to do it, look at the hands, know how to take out the media. If it doesn't come, then se...
Find Median from Data Stream
find-median-from-data-stream
The **median** is the middle value in an ordered integer list. If the size of the list is even, there is no middle value, and the median is the mean of the two middle values. * For example, for `arr = [2,3,4]`, the median is `3`. * For example, for `arr = [2,3]`, the median is `(2 + 3) / 2 = 2.5`. Implement the M...
null
Two Pointers,Design,Sorting,Heap (Priority Queue),Data Stream
Hard
480,1953,2207
312
Hello hello everyone popular doing well so first of all happy new year to all 100 I'm back with another late co david number se 1000 questions and answers in this question adhir wa during more channel subscribe button more example1 more problems saunf host west first one To exit point of three do the amazing subscribe ...
Burst Balloons
burst-balloons
You are given `n` balloons, indexed from `0` to `n - 1`. Each balloon is painted with a number on it represented by an array `nums`. You are asked to burst all the balloons. If you burst the `ith` balloon, you will get `nums[i - 1] * nums[i] * nums[i + 1]` coins. If `i - 1` or `i + 1` goes out of bounds of the array, ...
null
Array,Dynamic Programming
Hard
1042
1,944
Come so high everyone on this is aman divinely and today we are going to question late gold 1984 monosta monotonic track pe depend hai solve number of zero you end left you right order left you right representatives like here Here [MUSIC] is made [MUSIC] [MUSIC] [MUSIC] So if it remains on the side, who will remain [ r...
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
840
yeah hi hello everyone I'm a programmer today I will introduce to you a math problem on the following topic magic squares in a matrix detailed problem a square 3 A block of size 3 x3 will be a restaurant, so we will make one that is not three x3 but filled with different numbers from 1 to 9 so that each row, each colum...
Magic Squares In Grid
magic-squares-in-grid
A `3 x 3` magic square is a `3 x 3` grid filled with distinct numbers **from** `1` **to** `9` such that each row, column, and both diagonals all have the same sum. Given a `row x col` `grid` of integers, how many `3 x 3` "magic square " subgrids are there? (Each subgrid is contiguous). **Example 1:** **Input:** grid...
null
null
Medium
null
141
Hello everyone welcome back tu take distribution today in this video we will be discussing a problem statement linked list cycle we have to tell whether cycle is present in english or not present and what do I have to do this function has to return bullion if cycle is present So that will be true, what will the adrevis...
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
151
hey everybody this is larry this is me going with day 20 wow almost three weeks of the october league daily challenge hit the like button hit the subscribe button join me on discord let me know what you think about today's farm we were we always i'm just looking at the title uh reverse words in a string okay why is thi...
Reverse Words in a String
reverse-words-in-a-string
Given an input string `s`, reverse the order of the **words**. A **word** is defined as a sequence of non-space characters. The **words** in `s` will be separated by at least one space. Return _a string of the words in reverse order concatenated by a single space._ **Note** that `s` may contain leading or trailing s...
null
Two Pointers,String
Medium
186
148
gonna demonstrate sort list only code given the head of a linked list return the list after sorting it in ascending order you can sort the link list on an o n log of n time and an o of one memory which is a constant space so here's the example here of the linked list that is unsorted and then it's sorted in ascending o...
Sort List
sort-list
Given the `head` of a linked list, return _the list after sorting it in **ascending order**_. **Example 1:** **Input:** head = \[4,2,1,3\] **Output:** \[1,2,3,4\] **Example 2:** **Input:** head = \[-1,5,3,4,0\] **Output:** \[-1,0,3,4,5\] **Example 3:** **Input:** head = \[\] **Output:** \[\] **Constraints:** * ...
null
Linked List,Two Pointers,Divide and Conquer,Sorting,Merge Sort
Medium
21,75,147,1992
682
okay I like the prom 682 baseball game you're now a baseball game point recorder it's called once they've runs not points I came in a straight and given a list of strings are you sure and give me one of the four following types integer plus D or C and they do directive represented number ones you get this inning man th...
Baseball Game
baseball-game
You are keeping the scores for a baseball game with strange rules. At the beginning of the game, you start with an empty record. You are given a list of strings `operations`, where `operations[i]` is the `ith` operation you must apply to the record and is one of the following: * An integer `x`. * Record a new...
null
Array,Stack,Simulation
Easy
1720
1,621
hey what's up guys this is chung here so um so today i want to talk about uh this week uh week's bi-weekly contest problem uh number 1621 bi-weekly contest problem uh number 1621 bi-weekly contest problem uh number 1621 number of sets of k none overlapping line segments um it's a great medium problem i think for me it'...
Number of Sets of K Non-Overlapping Line Segments
number-of-subsequences-that-satisfy-the-given-sum-condition
Given `n` points on a 1-D plane, where the `ith` point (from `0` to `n-1`) is at `x = i`, find the number of ways we can draw **exactly** `k` **non-overlapping** line segments such that each segment covers two or more points. The endpoints of each segment must have **integral coordinates**. The `k` line segments **do n...
Sort the array nums. Use two pointers approach: Given an index i (choose it as the minimum in a subsequence) find the maximum j where j ≥ i and nums[i] +nums[j] ≤ target. Count the number of subsequences.
Array,Two Pointers,Binary Search,Sorting
Medium
null
70
welcome to nuggies in this short problem we're going to climb up some stairs taking either one or two steps at a time until we reach the top to approach the problem in a generic way we'll Define the top as the nth step the question we are trying to answer is how many distinct paths can we take to reach the nth step tak...
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,046
were given an array of integers stones with stone of I is the weight of the eighth Stone here we are playing a game with the stones okay on each turn we are choosing ABS to two stones and we are smashing them together suppose The Atheist two stones have weights X and Y with the x is less than or equals to Y the result ...
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
513
welcome back everyone we're gonna be solving Lee code 513 find the bottom left tree value so we're given the root of a binary tree we need to return the leftmost value in the very last row of the tree so taking a look at example one they give us a tree of two one and three the very last row in this tree contains the va...
Find Bottom Left Tree Value
find-bottom-left-tree-value
Given the `root` of a binary tree, return the leftmost value in the last row of the tree. **Example 1:** **Input:** root = \[2,1,3\] **Output:** 1 **Example 2:** **Input:** root = \[1,2,3,4,null,5,6,null,null,7\] **Output:** 7 **Constraints:** * The number of nodes in the tree is in the range `[1, 104]`. * `-...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Medium
null
1,328
hello hi everyone so today we are going to solve another lead code daily challenge problem and I know it's been quite some time again that I have not created any video uploaded it and apologies for that but yeah it's like I have come back and Pope I'll continue again I was a bit occupied with the work so let's look at ...
Break a Palindrome
monthly-transactions-ii
Given a palindromic string of lowercase English letters `palindrome`, replace **exactly one** character with any lowercase English letter so that the resulting string is **not** a palindrome and that it is the **lexicographically smallest** one possible. Return _the resulting string. If there is no way to replace a ch...
null
Database
Medium
1317
1,695
today we're going to look at the second problem from the lead code weekly contest 220 problem is called maximum erasure value you're given an array of positive integers nums and want to erase a sub ray containing unique elements score you get by erasing the sub array is equal to the sum of its elements return the maxim...
Maximum Erasure Value
maximum-sum-obtained-of-any-permutation
You are given an array of positive integers `nums` and want to erase a subarray containing **unique elements**. The **score** you get by erasing the subarray is equal to the **sum** of its elements. Return _the **maximum score** you can get by erasing **exactly one** subarray._ An array `b` is called to be a subarray...
Indexes with higher frequencies should be bound with larger values
Array,Greedy,Sorting,Prefix Sum
Medium
null
1,697
extraordinarily tired for some reason but that's no excuse if you don't get enough sleep if you don't get enough to eat it doesn't matter there's no excuse you have to do one leak code every day right Legend says if you go four days without doing a lead code you could die all right you could seriously die you know you ...
Checking Existence of Edge Length Limited Paths
strings-differ-by-one-character
An undirected graph of `n` nodes is defined by `edgeList`, where `edgeList[i] = [ui, vi, disi]` denotes an edge between nodes `ui` and `vi` with distance `disi`. Note that there may be **multiple** edges between two nodes. Given an array `queries`, where `queries[j] = [pj, qj, limitj]`, your task is to determine for e...
BruteForce, check all pairs and verify if they differ in one character. O(n^2 * m) where n is the number of words and m is the length of each string. O(m^2 * n), Use hashset, to insert all possible combinations adding a character "*". For example: If dict[i] = "abc", insert ("*bc", "a*c" and "ab*").
Hash Table,String,Rolling Hash,Hash Function
Medium
2256
387
Hello Amrita welcome back to our channel today string so basically I am trying to cover all the easy problems first and then I will move on to medium and hard problems so let's get started let's first understand the problem given as string find it first non repeating. character in it and return its index return -1 -1 -...
First Unique Character in a String
first-unique-character-in-a-string
Given a string `s`, _find the first non-repeating character in it and return its index_. If it does not exist, return `-1`. **Example 1:** **Input:** s = "leetcode" **Output:** 0 **Example 2:** **Input:** s = "loveleetcode" **Output:** 2 **Example 3:** **Input:** s = "aabb" **Output:** -1 **Constraints:** * `...
null
Hash Table,String,Queue,Counting
Easy
451
188
hello guys so let's talk about baseline to buy and sell stock full so if you didn't watch the base buy to buy and sell stock one two and three which is 121 to 123 so if you didn't watch it just go back to watch and that will help you a lot to understand why i'm typing in this question so uh you are given the integer k ...
Best Time to Buy and Sell Stock IV
best-time-to-buy-and-sell-stock-iv
You are given an integer array `prices` where `prices[i]` is the price of a given stock on the `ith` day, and an integer `k`. Find the maximum profit you can achieve. You may complete at most `k` transactions: i.e. you may buy at most `k` times and sell at most `k` times. **Note:** You may not engage in multiple tran...
null
Array,Dynamic Programming
Hard
121,122,123
151
hey guys welcome to a new video in today's video we're going to look at the lead code problem and the problems name is reverse words in a string so in this question we are given a string s and we need to reverse the order of the words so this is the function given to us this is the name of the function and this is the ...
Reverse Words in a String
reverse-words-in-a-string
Given an input string `s`, reverse the order of the **words**. A **word** is defined as a sequence of non-space characters. The **words** in `s` will be separated by at least one space. Return _a string of the words in reverse order concatenated by a single space._ **Note** that `s` may contain leading or trailing s...
null
Two Pointers,String
Medium
186
1,768
hey so welcome back and this is another daily kill prom so today it was called merge strings alternately and so it's an easy level problem where all you're given is these two words here and you just want to kind of interleave the them to together and so you just grab the first letter of the first word here and then you...
Merge Strings Alternately
design-an-expression-tree-with-evaluate-function
You are given two strings `word1` and `word2`. Merge the strings by adding letters in alternating order, starting with `word1`. If a string is longer than the other, append the additional letters onto the end of the merged string. Return _the merged string._ **Example 1:** **Input:** word1 = "abc ", word2 = "pqr "...
Apply the concept of Polymorphism to get a good design Implement the Node class using NumericNode and OperatorNode classes. NumericNode only maintains the value and evaluate returns this value. OperatorNode Maintains the left and right nodes representing the left and right operands, and the evaluate function applies th...
Math,Stack,Tree,Design,Binary Tree
Medium
null
71
everyone welcome back and let's write some more neat code today so today let's look at another problem a medium one simplify path so we're given a path like the path to a directory or something or a file like on your computer and so it's an absolute path it's guaranteed to be an absolute path right and you might rememb...
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
64
hello welcome to the channel and today we have lee code64 minimum part sum so this question basically looking at this example we can see um we will have a matrix and we are moving from the top left to all the way to the bottom right here and you can only move right or down every step so you can go down right or down ri...
Minimum Path Sum
minimum-path-sum
Given a `m x n` `grid` filled with non-negative numbers, find a path from top left to bottom right, which minimizes the sum of all numbers along its path. **Note:** You can only move either down or right at any point in time. **Example 1:** **Input:** grid = \[\[1,3,1\],\[1,5,1\],\[4,2,1\]\] **Output:** 7 **Explanat...
null
Array,Dynamic Programming,Matrix
Medium
62,174,741,2067,2192
57
Hello everyone welcome to my channel, if you have been doing such hard problems for a few days then you will start finding medium problems easy. Similarly, if you improve through practice, then the name of the question, insert interval, is also easy. Whatever is honest, now samjhaunga will start seeming easy. How to kn...
Insert Interval
insert-interval
You are given an array of non-overlapping intervals `intervals` where `intervals[i] = [starti, endi]` represent the start and the end of the `ith` interval and `intervals` is sorted in ascending order by `starti`. You are also given an interval `newInterval = [start, end]` that represents the start and end of another i...
null
Array
Medium
56,715
735
hello everyone welcome back here is Vanessa and today we have a pretty interesting problem on our hands uh it's medium level problem from political called asteroid Collision so without further Ado let's Dive Right In and understand the problem first so we are given an array of integers that represent asteroids the abso...
Asteroid Collision
asteroid-collision
We are given an array `asteroids` of integers representing asteroids in a row. For each asteroid, the absolute value represents its size, and the sign represents its direction (positive meaning right, negative meaning left). Each asteroid moves at the same speed. Find out the state of the asteroids after all collisio...
Say a row of asteroids is stable. What happens when a new asteroid is added on the right?
Array,Stack
Medium
605,2245,2317
137
hello wait on the attentive Allah so we play either going to solve this little problem single number what to do then so the problem statement is saying that we will be given one input array and it will condition number only and so suppose we will have four ingredient number out of both see Shane and one number equation...
Single Number II
single-number-ii
Given an integer array `nums` where every element appears **three times** except for one, which appears **exactly once**. _Find the single element and return it_. You must implement a solution with a linear runtime complexity and use only constant extra space. **Example 1:** **Input:** nums = \[2,2,3,2\] **Output:**...
null
Array,Bit Manipulation
Medium
136,260
1,856
hey what's up guys uh this is chung here again so this time 1856 maximum subarray minimum product okay so a minimum product of an array is equal to the minimum value in the array right multiplied by the rate sum so for example the rate is this one right the minimum value is two and the sum is 10 that's why the minimum ...
Maximum Subarray Min-Product
maximum-subarray-min-product
The **min-product** of an array is equal to the **minimum value** in the array **multiplied by** the array's **sum**. * For example, the array `[3,2,5]` (minimum value is `2`) has a min-product of `2 * (3+2+5) = 2 * 10 = 20`. Given an array of integers `nums`, return _the **maximum min-product** of any **non-empty ...
null
null
Medium
null
278
hello everyone welcome to the channel today's question is first bad version if you are new to the channel please consider subscribing we sold a lot of into question on this channel and that can definitely help you with your interview the question says you are a product manager and country leading a team to develop a ne...
First Bad Version
first-bad-version
You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the previous version, all the versions after a bad version are also bad. Suppose you have `n` versions `[1, 2, ..., n]` an...
null
Binary Search,Interactive
Easy
34,35,374
101
hey guys welcome to another easy lethal question today we're going to solve the symmetric tree question so this question gives you a binary tree and then you should check whether this tree is symmetric so what exactly does a symmetric tree mean so if you take a look at the tree we have in front of us we have nodes one ...
Symmetric Tree
symmetric-tree
Given the `root` of a binary tree, _check whether it is a mirror of itself_ (i.e., symmetric around its center). **Example 1:** **Input:** root = \[1,2,2,3,4,4,3\] **Output:** true **Example 2:** **Input:** root = \[1,2,2,null,3,null,3\] **Output:** false **Constraints:** * The number of nodes in the tree is in...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Easy
null
380
hey everyone welcome back and let's write some more neat code today so today let's solve the problem insert delete get random all in o of one time so as the problem says we're basically implementing these three methods and we want to design them in such a way that we can do all these operations in constant time we're g...
Insert Delete GetRandom O(1)
insert-delete-getrandom-o1
Implement the `RandomizedSet` class: * `RandomizedSet()` Initializes the `RandomizedSet` object. * `bool insert(int val)` Inserts an item `val` into the set if not present. Returns `true` if the item was not present, `false` otherwise. * `bool remove(int val)` Removes an item `val` from the set if present. Retur...
null
Array,Hash Table,Math,Design,Randomized
Medium
381
206
hi everyone it's albert starting this week let's try to solve some very good legal questions that got asked very frequently in coding interviews and today let's solve the question reverse linked list and before we start don't forget to subscribe to my channel i'll be constantly solving good and classic clinical questio...
Reverse Linked List
reverse-linked-list
Given the `head` of a singly linked list, reverse the list, and return _the reversed list_. **Example 1:** **Input:** head = \[1,2,3,4,5\] **Output:** \[5,4,3,2,1\] **Example 2:** **Input:** head = \[1,2\] **Output:** \[2,1\] **Example 3:** **Input:** head = \[\] **Output:** \[\] **Constraints:** * The number...
null
Linked List,Recursion
Easy
92,156,234,2196,2236
1,171
we mu0 some consecutive nodes from linked lists given a linked list something like this there are consecutive nodes that sum up to zero for example these three that sum up to zero so you remove them you return three one there can also be other possibilities for example these two consecutive nodes sum up is zero if you ...
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
721
hey how's it going guys today i want to go through this elite code problem uh problem 721 uh is for account merge so um using uh the depth first search and um i'll go through my approach later so let's take a first take a look at the problem so uh what we have is to um uh given a list of account where each element is a...
Accounts Merge
accounts-merge
Given a list of `accounts` where each element `accounts[i]` is a list of strings, where the first element `accounts[i][0]` is a name, and the rest of the elements are **emails** representing emails of the account. Now, we would like to merge these accounts. Two accounts definitely belong to the same person if there is...
For every pair of emails in the same account, draw an edge between those emails. The problem is about enumerating the connected components of this graph.
Array,String,Depth-First Search,Breadth-First Search,Union Find
Medium
684,734,737
171
hey everybody today we'll be doing another lead code 171 excel sheet column number given uh this is an easy one given a column title that represents column title as appears in an excel sheet return its corresponding column number we have already done a problem like this where we convert numbers into excel title and now...
Excel Sheet Column Number
excel-sheet-column-number
Given a string `columnTitle` that represents the column title as appears in an Excel sheet, return _its corresponding column number_. For example: A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 AB -> 28 ... **Example 1:** **Input:** columnTitle = "A " **Output:** 1 **Example 2:** **Input:** columnTitle = "AB " **Ou...
null
Math,String
Easy
168,2304
582
yo what's up guys this is shown here so this time we're gonna do this lead called problem 5 8 2 Q process it's marked as a medium problem but to me it's kind of like I'm a easier side off of the medium problem ok let's take a look here so you're given two arrays the first array is the process ID array and the second ar...
Kill Process
kill-process
You have `n` processes forming a rooted tree structure. You are given two integer arrays `pid` and `ppid`, where `pid[i]` is the ID of the `ith` process and `ppid[i]` is the ID of the `ith` process's parent process. Each process has only **one parent process** but may have multiple children processes. Only one process...
null
Array,Hash Table,Tree,Depth-First Search,Breadth-First Search
Medium
null
1,986
hey everybody this is larry just me going with q3 of the weekly contest 256 minimum number of work sessions to finish the tasks um hit the like button near the subscribe button show me some support join uh join me on discord especially if you like these contest problems because we love talking about con contest problem...
Minimum Number of Work Sessions to Finish the Tasks
largest-color-value-in-a-directed-graph
There are `n` tasks assigned to you. The task times are represented as an integer array `tasks` of length `n`, where the `ith` task takes `tasks[i]` hours to finish. A **work session** is when you work for **at most** `sessionTime` consecutive hours and then take a break. You should finish the given tasks in a way tha...
Use topological sort. let dp[u][c] := the maximum count of vertices with color c of any path starting from vertex u. (by JerryJin2905)
Hash Table,Dynamic Programming,Graph,Topological Sort,Memoization,Counting
Hard
null
1,818
hello all uh welcome to another leadco problems so today we are going to solve problem number 1818 minimum absolute sound defense so in this problem if we read the product description so there are two errors given numbers 1 and number two and then we have to minimize the absolute sum difference of an array so if I take...
Minimum Absolute Sum Difference
maximum-score-from-removing-substrings
You are given two positive integer arrays `nums1` and `nums2`, both of length `n`. The **absolute sum difference** of arrays `nums1` and `nums2` is defined as the **sum** of `|nums1[i] - nums2[i]|` for each `0 <= i < n` (**0-indexed**). You can replace **at most one** element of `nums1` with **any** other element in ...
Note that it is always more optimal to take one type of substring before another You can use a stack to handle erasures
String,Stack,Greedy
Medium
2256
1,905
hello everyone welcome to my youtube channel today i'm solving the lead pro question 1905 concept of islands so this problem is going to be solved using depth first search dfs so this problem is also very similar to some of the dfs uh problem we already solved for example the very classic number of islands so let's fir...
Count Sub Islands
design-authentication-manager
You are given two `m x n` binary matrices `grid1` and `grid2` containing only `0`'s (representing water) and `1`'s (representing land). An **island** is a group of `1`'s connected **4-directionally** (horizontal or vertical). Any cells outside of the grid are considered water cells. An island in `grid2` is considered ...
Using a map, track the expiry times of the tokens. When generating a new token, add it to the map with its expiry time. When renewing a token, check if it's on the map and has not expired yet. If so, update its expiry time. To count unexpired tokens, iterate on the map and check for each token if it's not expired yet.
Hash Table,Design
Medium
null
404
hi welcome back to the channel i hope everyone is doing well today we are going to do another question the question is a binary tree question the question is lego 404 sun of left leaves now let's work for the question given root of binary tree return the sound of all left leaves leaf is a note with no chosen a left lea...
Sum of Left Leaves
sum-of-left-leaves
Given the `root` of a binary tree, return _the sum of all left leaves._ A **leaf** is a node with no children. A **left leaf** is a leaf that is the left child of another node. **Example 1:** **Input:** root = \[3,9,20,null,null,15,7\] **Output:** 24 **Explanation:** There are two left leaves in the binary tree, wit...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Easy
null
915
hi everyone once again welcome to my channel if you are new to the channel hit the subscribe button and the problem we are solving in this video is partition array into disjoint interval where like in this problem we are given a integral array nums and we need to partition this array into two contiguous array left and ...
Partition Array into Disjoint Intervals
generate-random-point-in-a-circle
Given an integer array `nums`, partition it into two (contiguous) subarrays `left` and `right` so that: * Every element in `left` is less than or equal to every element in `right`. * `left` and `right` are non-empty. * `left` has the smallest possible size. Return _the length of_ `left` _after such a partitioni...
null
Math,Geometry,Rejection Sampling,Randomized
Medium
914
829
hi guys this is urj and today we're going to look at another problem lead code a to 9 consecutive number sum so this is a pretty interesting problem so let's read the problem given an integer n um written number of ways you can write n as a sum of consecutive positive integers so okay let's see this example so you're g...
Consecutive Numbers Sum
subdomain-visit-count
Given an integer `n`, return _the number of ways you can write_ `n` _as the sum of consecutive positive integers._ **Example 1:** **Input:** n = 5 **Output:** 2 **Explanation:** 5 = 2 + 3 **Example 2:** **Input:** n = 9 **Output:** 3 **Explanation:** 9 = 4 + 5 = 2 + 3 + 4 **Example 3:** **Input:** n = 15 **Output...
null
Array,Hash Table,String,Counting
Medium
null
455
hello everyone welcome back today we have 455 assigned cookies it says here that we are to assume we're an awesome parent and want to give each of our children some cookies but we need to give each child at most one cookie fair enough each child also has some greed factor which is the minimum size of a cookie that the ...
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
108
Hello Friends India Fashion Wear Printed Discuss Another List Problem Convert 60 to Binary Search Tree Will Be Given in This Year Which Sort in Ascending Order How to Convert Decide Are * Height Order How to Convert Decide Are * Height Order How to Convert Decide Are * Height Balance Binary Search Tree to Understand Wh...
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
213
hi everyone today we are going to interrupt the radical question house robots are two and you are a professional robber planning to rob houses around the street each house has a certain amount of money stashed all houses at this place are arranged in asaco that means the first house is neighbor of the last one meanwhil...
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
139
hi this is lead called the question word break we will use dynamic programming solve this question and we will use two or we will solve it in two different way the first way is we create a table of length equal to the size of the string and each index or each value of the table TB of I is either true or false if it's t...
Word Break
word-break
Given a string `s` and a dictionary of strings `wordDict`, return `true` if `s` can be segmented into a space-separated sequence of one or more dictionary words. **Note** that the same word in the dictionary may be reused multiple times in the segmentation. **Example 1:** **Input:** s = "leetcode ", wordDict = \[ "...
null
Hash Table,String,Dynamic Programming,Trie,Memoization
Medium
140
95
Hey hi friends I'm going to discuss the solution of question by 95 okay code that is unifying a research group - yeah that is unifying a research group - yeah that is unifying a research group - yeah so I already have the solution here this is the github link and I'm going to explain you over the Eclipse yeah so this i...
Unique Binary Search Trees II
unique-binary-search-trees-ii
Given an integer `n`, return _all the structurally unique **BST'**s (binary search trees), which has exactly_ `n` _nodes of unique values from_ `1` _to_ `n`. Return the answer in **any order**. **Example 1:** **Input:** n = 3 **Output:** \[\[1,null,2,null,3\],\[1,null,3,2\],\[2,1,3\],\[3,1,null,null,2\],\[3,2,null,1\...
null
Dynamic Programming,Backtracking,Tree,Binary Search Tree,Binary Tree
Medium
96,241
497
welcome to august eco challenge today's problem is random point in non-overlapping non-overlapping non-overlapping rectangles given a list of non-overlapping non-overlapping non-overlapping rectangles write a function which randomly and uniformly picks an integer point in the space covered by the rectangles essentially...
Random Point in Non-overlapping Rectangles
random-point-in-non-overlapping-rectangles
You are given an array of non-overlapping axis-aligned rectangles `rects` where `rects[i] = [ai, bi, xi, yi]` indicates that `(ai, bi)` is the bottom-left corner point of the `ith` rectangle and `(xi, yi)` is the top-right corner point of the `ith` rectangle. Design an algorithm to pick a random integer point inside th...
null
null
Medium
null
640
hello friends now let's stop there equation problem that's a statement solve a given Christian and return the value of x in the form of stream like the x equal to number value the Christian could test only plus minus operation the variable X and it's a coefficient if there is no solution for the equation return no solu...
Solve the Equation
solve-the-equation
Solve a given equation and return the value of `'x'` in the form of a string `"x=#value "`. The equation contains only `'+'`, `'-'` operation, the variable `'x'` and its coefficient. You should return `"No solution "` if there is no solution for the equation, or `"Infinite solutions "` if there are infinite solutions f...
null
Math,String,Simulation
Medium
592,2328
226
hey guys welcome back to has today's algorithm in this video we would be solving this problem invert a binary tree so this is a quite famous problem which is asking many of the Fang interviews so we are given a root of a binary tree and we have to invert this tree and return the root of the inverted tree so we have thi...
Invert Binary Tree
invert-binary-tree
Given the `root` of a binary tree, invert the tree, and return _its root_. **Example 1:** **Input:** root = \[4,2,7,1,3,6,9\] **Output:** \[4,7,2,9,6,3,1\] **Example 2:** **Input:** root = \[2,1,3\] **Output:** \[2,3,1\] **Example 3:** **Input:** root = \[\] **Output:** \[\] **Constraints:** * The number of n...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Easy
null
403
hello hi guys good morning and welcome back to the new video firstly apologies for not being a regular lately but for from now I will be for sure regular medium and hard questions will be coming in I will not pick up easy questions only the beginning the hard question will be coming in first or regular good I'll next q...
Frog Jump
frog-jump
A frog is crossing a river. The river is divided into some number of units, and at each unit, there may or may not exist a stone. The frog can jump on a stone, but it must not jump into the water. Given a list of `stones`' positions (in units) in sorted **ascending order**, determine if the frog can cross the river by...
null
Array,Dynamic Programming
Hard
1952,2262
73
so question 73 leak code set matrix zeros so given an m by n integer matrix if an element is zero set its entire row and column to zeros you must do this in place so it's a pretty self-explanatory so it's a pretty self-explanatory so it's a pretty self-explanatory question we just need to set the rows to zeros and the ...
Set Matrix Zeroes
set-matrix-zeroes
Given an `m x n` integer matrix `matrix`, if an element is `0`, set its entire row and column to `0`'s. You must do it [in place](https://en.wikipedia.org/wiki/In-place_algorithm). **Example 1:** **Input:** matrix = \[\[1,1,1\],\[1,0,1\],\[1,1,1\]\] **Output:** \[\[1,0,1\],\[0,0,0\],\[1,0,1\]\] **Example 2:** **In...
If any cell of the matrix has a zero we can record its row and column number using additional memory. But if you don't want to use extra memory then you can manipulate the array instead. i.e. simulating exactly what the question says. Setting cell values to zero on the fly while iterating might lead to discrepancies. ...
Array,Hash Table,Matrix
Medium
289,2244,2259,2314
1,335
job schedule or question it is better to reward it into something that makes more sense here's what i think makes more sense given an array cut it into d contiguous subarrays and return the minimum sum of max of each subarray with the example given 654321 with d2 what we have to do is cut it at some spot and create two...
Minimum Difficulty of a Job Schedule
maximum-candies-allocated-to-k-children
You want to schedule a list of jobs in `d` days. Jobs are dependent (i.e To work on the `ith` job, you have to finish all the jobs `j` where `0 <= j < i`). You have to finish **at least** one task every day. The difficulty of a job schedule is the sum of difficulties of each day of the `d` days. The difficulty of a da...
For a fixed number of candies c, how can you check if each child can get c candies? Use binary search to find the maximum c as the answer.
Array,Binary Search
Medium
907,1886,2000,2027,2188,2294
1,470
hi everybody welcome to my channel let's solve the lit code problem 1470 shuffle the array given the arrays nums consisting of two of n elements in the form of x1 x2 and xn then y1 y2 and yn and we have to return the array in the form of x 1 y 1 then x 2 y 2 and so on till the x and y n so for example 1 we have 2 5 1 3...
Shuffle the Array
tweet-counts-per-frequency
Given the array `nums` consisting of `2n` elements in the form `[x1,x2,...,xn,y1,y2,...,yn]`. _Return the array in the form_ `[x1,y1,x2,y2,...,xn,yn]`. **Example 1:** **Input:** nums = \[2,5,1,3,4,7\], n = 3 **Output:** \[2,3,5,4,1,7\] **Explanation:** Since x1\=2, x2\=5, x3\=1, y1\=3, y2\=4, y3\=7 then the answer ...
null
Hash Table,Binary Search,Design,Sorting,Ordered Set
Medium
null
987
hello guys welcome back to tech dose and in this video we will see the vertical order traversal of a binary tree problem which is from lead code august challenge and this is from day seven so let us first see the problem statement and then we will look at the examples given a binary tree return the vertical order trave...
Vertical Order Traversal of a Binary Tree
reveal-cards-in-increasing-order
Given the `root` of a binary tree, calculate the **vertical order traversal** of the binary tree. For each node at position `(row, col)`, its left and right children will be at positions `(row + 1, col - 1)` and `(row + 1, col + 1)` respectively. The root of the tree is at `(0, 0)`. The **vertical order traversal** o...
null
Array,Queue,Sorting,Simulation
Medium
null
239
for the question you can refer lead code I'll attach the problem Link in the description section overall the problem is that you are given an array and you are given as K value now K denotes the size of the window and you have to find out the maximum element in every window of size k for example if you see here I have ...
Sliding Window Maximum
sliding-window-maximum
You are given an array of integers `nums`, there is a sliding window of size `k` which is moving from the very left of the array to the very right. You can only see the `k` numbers in the window. Each time the sliding window moves right by one position. Return _the max sliding window_. **Example 1:** **Input:** nums...
How about using a data structure such as deque (double-ended queue)? The queue size need not be the same as the window’s size. Remove redundant elements and the queue should store only elements that need to be considered.
Array,Queue,Sliding Window,Heap (Priority Queue),Monotonic Queue
Hard
76,155,159,265,1814
1,759
hello friends welcome to coding interviews channel hope you are doing great if you haven't subscribed to the channel yet please go ahead and subscribe also i have created a bunch of playlists to cover various categories of problems such as bfs dfs dynamic programming stacks queues linked list please check them out i ha...
Count Number of Homogenous Substrings
find-the-missing-ids
Given a string `s`, return _the number of **homogenous** substrings of_ `s`_._ Since the answer may be too large, return it **modulo** `109 + 7`. A string is **homogenous** if all the characters of the string are the same. A **substring** is a contiguous sequence of characters within a string. **Example 1:** **Inpu...
null
Database
Medium
1357,1420,1467
173
okay so lead code practice time it's really late so probably the last video the last question for tonight so two goals one is to find the solution for this question and the other one is to see how to solve this problem during a real interview so let's get started usually the first step in the real interview is to under...
Binary Search Tree Iterator
binary-search-tree-iterator
Implement the `BSTIterator` class that represents an iterator over the **[in-order traversal](https://en.wikipedia.org/wiki/Tree_traversal#In-order_(LNR))** of a binary search tree (BST): * `BSTIterator(TreeNode root)` Initializes an object of the `BSTIterator` class. The `root` of the BST is given as part of the co...
null
Stack,Tree,Design,Binary Search Tree,Binary Tree,Iterator
Medium
94,251,281,284,285,1729
1,911
hey everyone welcome back and let's write some more neat code today so today let's solve maximum alternating subsequence sum this is a problem from this morning's leak code contest and i'll probably also be solving a problem from this afternoon's lee code contest as well so the first thing i want to mention is that thi...
Maximum Alternating Subsequence Sum
minimum-elements-to-add-to-form-a-given-sum
The **alternating sum** of a **0-indexed** array is defined as the **sum** of the elements at **even** indices **minus** the **sum** of the elements at **odd** indices. * For example, the alternating sum of `[4,2,5,3]` is `(4 + 5) - (2 + 3) = 4`. Given an array `nums`, return _the **maximum alternating sum** of any...
Try thinking about the problem as if the array is empty. Then you only need to form goal using elements whose absolute value is <= limit. You can greedily set all of the elements except one to limit or -limit, so the number of elements you need is ceil(abs(goal)/ limit). You can "normalize" goal by offsetting it by the...
Array,Greedy
Medium
null
1,095
hey what's up guys this is john here so today let's take a look at 1095 finding mountain array um i like this problem because we rarely see an interactive problem in lead code so okay so you may recall like that an array a is a mountain ray if and only if there's a single summit right so array that's a summit if it's l...
Find in Mountain Array
two-city-scheduling
_(This problem is an **interactive problem**.)_ You may recall that an array `arr` is a **mountain array** if and only if: * `arr.length >= 3` * There exists some `i` with `0 < i < arr.length - 1` such that: * `arr[0] < arr[1] < ... < arr[i - 1] < arr[i]` * `arr[i] > arr[i + 1] > ... > arr[arr.length ...
null
Array,Greedy,Sorting
Medium
null
1,413
welcome back to aggregious today's question is leak code 1413 minimum value to get positive step-by-step sum so to get positive step-by-step sum so to get positive step-by-step sum so we're given an array of integers nums we start with an initial position value start value in each iteration you can calculate the step-b...
Minimum Value to Get Positive Step by Step Sum
maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold
Given an array of integers `nums`, you start with an initial **positive** value _startValue__._ In each iteration, you calculate the step by step sum of _startValue_ plus elements in `nums` (from left to right). Return the minimum **positive** value of _startValue_ such that the step by step sum is never less than 1....
Store prefix sum of all grids in another 2D array. Try all possible solutions and if you cannot find one return -1. If x is a valid answer then any y < x is also valid answer. Use binary search to find answer.
Array,Binary Search,Matrix,Prefix Sum
Medium
null
377
hey everyone in this video let's take a look at question 377 combination Sum 4 only code this is part of our blind 75 list of questions so let's begin in this question we're given an array of distinct integers called nums and a Target integer called Target and we want to return the number of possible combinations that ...
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
377
hello everyone welcome to my channel coding together my name is vikas hoja today we will see another lead code problem that is combination Sun sum 4. so we are given with an uh array of distinct integer norms and a Target value we have to return the number of possible condition combinations that are that I have up to T...
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,975
do not scroll let's solve a super cool Google interview question in 30 seconds we are given a matrix and we can choose any two adjacent elements and multiply them by negative one arbitrarily many times if we want to return the max sum of the Matrix the main observation is that we can move negatives anywhere we'd like a...
Maximum Matrix Sum
minimum-distance-to-the-target-element
You are given an `n x n` integer `matrix`. You can do the following operation **any** number of times: * Choose any two **adjacent** elements of `matrix` and **multiply** each of them by `-1`. Two elements are considered **adjacent** if and only if they share a **border**. Your goal is to **maximize** the summatio...
Loop in both directions until you find the target element. For each index i such that nums[i] == target calculate abs(i - start).
Array
Easy
null
782
hey everybody this is larry this is day 26 of the league code daily challenge the like button to subscribe and drama and discord so whenever i do a long video i usually just do another intro so that you can see what is up with the situation and for this one uh it's just a lot of case analysis to be honest um and from t...
Transform to Chessboard
jewels-and-stones
You are given an `n x n` binary grid `board`. In each move, you can swap any two rows with each other, or any two columns with each other. Return _the minimum number of moves to transform the board into a **chessboard board**_. If the task is impossible, return `-1`. A **chessboard board** is a board where no `0`'s a...
For each stone, check if it is a jewel.
Hash Table,String
Easy
null
1,324
Scientist A Kar Do Hua Hai Guys How Are You I Am Positive In Good Academic World Tour Every Question Print Words Vertically OK So In This Question It Is Given In The Spring Has Written All The Words Delhi HC Order In Which Day Appear In The Voice Of Eternal Bliss To Spring Complete With Specific Ki Nursery Shudh Is The...
Print Words Vertically
where-will-the-ball-fall
Given a string `s`. Return all the words vertically in the same order in which they appear in `s`. Words are returned as a list of strings, complete with spaces when is necessary. (Trailing spaces are not allowed). Each word would be put on only one column and that in one column there will be only one word. **Exam...
Use DFS. Traverse the path of the ball downwards until you reach the bottom or get stuck.
Array,Dynamic Programming,Depth-First Search,Matrix,Simulation
Medium
null
923
hey everybody this is larry this is day six of the april eco daily challenge hit the like button to subscribe and let me try to find a way to click on this uh join me on discord and we'll hang out chill talk about this farm talk about the problems uh interviewing uh contests and stuff like that today's problem is nine ...
3Sum With Multiplicity
super-egg-drop
Given an integer array `arr`, and an integer `target`, return the number of tuples `i, j, k` such that `i < j < k` and `arr[i] + arr[j] + arr[k] == target`. As the answer can be very large, return it **modulo** `109 + 7`. **Example 1:** **Input:** arr = \[1,1,2,2,3,3,4,4,5,5\], target = 8 **Output:** 20 **Explanatio...
null
Math,Binary Search,Dynamic Programming
Hard
2031
1,568
hey what's up guys juan here again so this time let's take a look at the as this list called problem number 1568 minimum number of days to disconnect i island this is another problem during this week's weekly contest so okay you're given like a 2d grade consisting of either one or zero okay one means it's a land and ze...
Minimum Number of Days to Disconnect Island
pseudo-palindromic-paths-in-a-binary-tree
You are given an `m x n` binary grid `grid` where `1` represents land and `0` represents water. An **island** is a maximal **4-directionally** (horizontal or vertical) connected group of `1`'s. The grid is said to be **connected** if we have **exactly one island**, otherwise is said **disconnected**. In one day, we a...
Note that the node values of a path form a palindrome if at most one digit has an odd frequency (parity). Use a Depth First Search (DFS) keeping the frequency (parity) of the digits. Once you are in a leaf node check if at most one digit has an odd frequency (parity).
Bit Manipulation,Tree,Depth-First Search,Breadth-First Search,Binary Tree
Medium
null
974
and welcome back to the cracking fan YouTube channel today we're going to be solving lead code problem 974 subarray sums divisible by K before we get into the video if you guys are enjoying this content leave a like and a comment helps me a ton with the YouTube algorithm all right given an integer array nums and an int...
Subarray Sums Divisible by K
reorder-data-in-log-files
Given an integer array `nums` and an integer `k`, return _the number of non-empty **subarrays** that have a sum divisible by_ `k`. A **subarray** is a **contiguous** part of an array. **Example 1:** **Input:** nums = \[4,5,0,-2,-3,1\], k = 5 **Output:** 7 **Explanation:** There are 7 subarrays with a sum divisible b...
null
Array,String,Sorting
Easy
null
1,235
hey what's up guys this is chung here so it's lead code time again and today let's take a look at 1235 maximum profit in job scheduling okay another interval problem here so you have n jobs and where every job has a start time and end time also we are we have a third property here which is the profit by finishing that ...
Maximum Profit in Job Scheduling
maximum-profit-in-job-scheduling
We have `n` jobs, where every job is scheduled to be done from `startTime[i]` to `endTime[i]`, obtaining a profit of `profit[i]`. You're given the `startTime`, `endTime` and `profit` arrays, return the maximum profit you can take such that there are no two jobs in the subset with overlapping time range. If you choose...
null
null
Hard
null
242
what's up youtube today we're going to take a look at lead called problem number 242 valid anagram marked as easy let's get into it so the problem statement says given two strings s and t write a function to determine if t is an anagram of s anagram meaning you can spell out the first string using the second string and...
Valid Anagram
valid-anagram
Given two strings `s` and `t`, return `true` _if_ `t` _is an anagram of_ `s`_, and_ `false` _otherwise_. An **Anagram** is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. **Example 1:** **Input:** s = "anagram", t = "nagaram" **...
null
Hash Table,String,Sorting
Easy
49,266,438
304
That a hello everyone welcome develop milk put injured as well as in the recent today I am not able subscribe and subscribe a model presents a state which gives me tracks and meet computer 10 sum of numbers from all 120 days and tenth of now computer lock v5 plus 6 plus 7000 end delete multiple do subscribe united subs...
Range Sum Query 2D - Immutable
range-sum-query-2d-immutable
Given a 2D matrix `matrix`, handle multiple queries of the following type: * Calculate the **sum** of the elements of `matrix` inside the rectangle defined by its **upper left corner** `(row1, col1)` and **lower right corner** `(row2, col2)`. Implement the `NumMatrix` class: * `NumMatrix(int[][] matrix)` Initial...
null
Array,Design,Matrix,Prefix Sum
Medium
303,308
263
Hello Gas, Azamgarh, it is mentioned in the question that what is this number, the next number should be a number whose prime factor will always be 2, 3 and 5 among us and will be limited to this and there should not be anything more than this. For example I take n = 6 and 6S is a multiple that is n = 6 and 6S is a mul...
Ugly Number
ugly-number
An **ugly number** is a positive integer whose prime factors are limited to `2`, `3`, and `5`. Given an integer `n`, return `true` _if_ `n` _is an **ugly number**_. **Example 1:** **Input:** n = 6 **Output:** true **Explanation:** 6 = 2 \* 3 **Example 2:** **Input:** n = 1 **Output:** true **Explanation:** 1 has n...
null
Math
Easy
202,204,264
1,716
hi my name is david today we're going to do number 1716 calculate money in league code bank this is an easy level problem only code and we're going to solve it in javascript so the idea behind this prop is that we want to think of a bank and this function is the amount of days and for it we start off at monday and for ...
Calculate Money in Leetcode Bank
maximum-non-negative-product-in-a-matrix
Hercy wants to save money for his first car. He puts money in the Leetcode bank **every day**. He starts by putting in `$1` on Monday, the first day. Every day from Tuesday to Sunday, he will put in `$1` more than the day before. On every subsequent Monday, he will put in `$1` more than the **previous Monday**. Given...
Use Dynamic programming. Keep the highest value and lowest value you can achieve up to a point.
Array,Dynamic Programming,Matrix
Medium
null
878
Hello everyone welcome back to my channel short debut in the discussion wellington problem problems now problems in this magical number to interest problem positive interior is magically divisible by either a and b given there individual in the incident in this magical number listen very large stone models tanipar 1972...
Nth Magical Number
shifting-letters
A positive integer is _magical_ if it is divisible by either `a` or `b`. Given the three integers `n`, `a`, and `b`, return the `nth` magical number. Since the answer may be very large, **return it modulo** `109 + 7`. **Example 1:** **Input:** n = 1, a = 2, b = 3 **Output:** 2 **Example 2:** **Input:** n = 4, a = ...
null
Array,String
Medium
1954
138
hey everyone welcome back and let's write some more neat code today so today let's solve copy list with a random pointer so we're given a linked list and so this is a pretty big description of the problem but it's actually more simple than that so basically you can see down in the example this is what you should pay at...
Copy List with Random Pointer
copy-list-with-random-pointer
A linked list of length `n` is given such that each node contains an additional random pointer, which could point to any node in the list, or `null`. Construct a [**deep copy**](https://en.wikipedia.org/wiki/Object_copying#Deep_copy) of the list. The deep copy should consist of exactly `n` **brand new** nodes, where e...
Just iterate the linked list and create copies of the nodes on the go. Since a node can be referenced from multiple nodes due to the random pointers, make sure you are not making multiple copies of the same node. You may want to use extra space to keep old node ---> new node mapping to prevent creating multiples copies...
Hash Table,Linked List
Medium
133,1624,1634
392
substring prefix suffix subsequence all of these terms come hand in hand when it comes to problems on strings one such problem is available on lead code where you are given two strings and you have to determine if one of the string is a subsequence of the other one in this problem statement the term subsequence is very...
Is Subsequence
is-subsequence
Given two strings `s` and `t`, return `true` _if_ `s` _is a **subsequence** of_ `t`_, or_ `false` _otherwise_. A **subsequence** of a string is a new string that is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (i...
null
Two Pointers,String,Dynamic Programming
Easy
808,1051
1,970
all right let's look at this problem called last day where you can still cross this is something that we have already done once uh and we did it using BF or so DFS and using binary search this time we'll do it using disjointed set Union or the union find so let's still go through the problem again so basically we are g...
Last Day Where You Can Still Cross
sorting-the-sentence
There is a **1-based** binary matrix where `0` represents land and `1` represents water. You are given integers `row` and `col` representing the number of rows and columns in the matrix, respectively. Initially on day `0`, the **entire** matrix is **land**. However, each day a new cell becomes flooded with **water**. ...
Divide the string into the words as an array of strings Sort the words by removing the last character from each word and sorting according to it
String,Sorting
Easy
2168
1,611
Hello friends welcome to my channel here islet code problems today's problem number 1611 minimum one bit operations to make integer zero given an integer n you must transform it into zero using the following operation any numbers of times first change the rightmost bit in the binary representation of n change the I bit...
Minimum One Bit Operations to Make Integers Zero
making-file-names-unique
Given an integer `n`, you must transform it into `0` using the following operations any number of times: * Change the rightmost (`0th`) bit in the binary representation of `n`. * Change the `ith` bit in the binary representation of `n` if the `(i-1)th` bit is set to `1` and the `(i-2)th` through `0th` bits are set...
Keep a map of each name and the smallest valid integer that can be appended as a suffix to it. If the name is not present in the map, you can use it without adding any suffixes. If the name is present in the map, append the smallest proper suffix, and add the new name to the map.
Array,Hash Table,String
Medium
null
739
hi guys this is n and you are watching get solution in today's video I'll solve for aad code question again so without any further delay let's get started question goes like this daily temperature given an aray of integer temperature represent the daily temperature written an AR answer such that answer of I is the numb...
Daily Temperatures
daily-temperatures
Given an array of integers `temperatures` represents the daily temperatures, return _an array_ `answer` _such that_ `answer[i]` _is the number of days you have to wait after the_ `ith` _day to get a warmer temperature_. If there is no future day for which this is possible, keep `answer[i] == 0` instead. **Example 1:**...
If the temperature is say, 70 today, then in the future a warmer temperature must be either 71, 72, 73, ..., 99, or 100. We could remember when all of them occur next.
Array,Stack,Monotonic Stack
Medium
496,937
2
in this video we are going to uh take another read code problem and that is the add the two number so you have been given the two rink list and these are the first rink list that node one node have the seven and the node has eight and the node is nine and second increas we have the three node So eventually this is the ...
Add Two Numbers
add-two-numbers
You are given two **non-empty** linked lists representing two non-negative integers. The digits are stored in **reverse order**, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list. You may assume the two numbers do not contain any leading zero, except the number 0 ...
null
Linked List,Math,Recursion
Medium
43,67,371,415,445,1031,1774
438
hello everyone welcome or welcome back to codingcharms in today's video we are going to be solving the problem find all anagrams in a string in this problem we are given with two strings S and P we have to return an array of start indices piece anagrams in s you may return the answer in any order and anagram is a word ...
Find All Anagrams in a String
find-all-anagrams-in-a-string
Given two strings `s` and `p`, return _an array of all the start indices of_ `p`_'s anagrams in_ `s`. You may return the answer in **any order**. An **Anagram** is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. **Example 1:** *...
null
Hash Table,String,Sliding Window
Medium
242,567
908
hello guys I am this we see problem smallest Range one so you given integer ARR and integer K in one operation you can choose any index I that index I should beit in the array range itself and change nums of Y to nums of I plus X where X is an integer from the range minus K to K so you can apply this operation at most ...
Smallest Range I
middle-of-the-linked-list
You are given an integer array `nums` and an integer `k`. In one operation, you can choose any index `i` where `0 <= i < nums.length` and change `nums[i]` to `nums[i] + x` where `x` is an integer from the range `[-k, k]`. You can apply this operation **at most once** for each index `i`. The **score** of `nums` is the...
null
Linked List,Two Pointers
Easy
2216,2236
739
everyone welcome to my channel in this video i'm going to cover the solution to this question do some lab coding work at the same time i'm going to follow the general steps we should follow in the coding interview so before we start the real content for today i would really appreciate that if you can help support this ...
Daily Temperatures
daily-temperatures
Given an array of integers `temperatures` represents the daily temperatures, return _an array_ `answer` _such that_ `answer[i]` _is the number of days you have to wait after the_ `ith` _day to get a warmer temperature_. If there is no future day for which this is possible, keep `answer[i] == 0` instead. **Example 1:**...
If the temperature is say, 70 today, then in the future a warmer temperature must be either 71, 72, 73, ..., 99, or 100. We could remember when all of them occur next.
Array,Stack,Monotonic Stack
Medium
496,937
979
hey what's up guys it's Nick white I do tech encoding stuff on twitch and YouTube and I'm doing all the leak oh problems everything's in the description and my youtube channel has a playlist of all these little code problems doing all the tree ones today this one's called distribute coins in a binary tree so given the ...
Distribute Coins in Binary Tree
di-string-match
You are given the `root` of a binary tree with `n` nodes where each `node` in the tree has `node.val` coins. There are `n` coins in total throughout the whole tree. In one move, we may choose two adjacent nodes and move one coin from one node to another. A move may be from parent to child, or from child to parent. Re...
null
Array,Math,Two Pointers,String,Greedy
Easy
null
662
welcome back in this another daily kill prom so today it was called maximum width of a binary tree and so yeah it's yet to get another tree question where it's not a balanced binary tree or like a complete so it only can have at most each node can have only at most two children but you can see here like there could be ...
Maximum Width of Binary Tree
maximum-width-of-binary-tree
Given the `root` of a binary tree, return _the **maximum width** of the given tree_. The **maximum width** of a tree is the maximum **width** among all levels. The **width** of one level is defined as the length between the end-nodes (the leftmost and rightmost non-null nodes), where the null nodes between the end-no...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Medium
null
671
so today we would be doing the question second minimum node in a binary tree so basically the question is like that we have been given a binary tree and we have to get this second minimum node in the binary tree so my approach would be like this i would be simply doing a pre-order transverse throughout doing a pre-orde...
Second Minimum Node In a Binary Tree
second-minimum-node-in-a-binary-tree
Given a non-empty special binary tree consisting of nodes with the non-negative value, where each node in this tree has exactly `two` or `zero` sub-node. If the node has two sub-nodes, then this node's value is the smaller value among its two sub-nodes. More formally, the property `root.val = min(root.left.val, root.ri...
null
Tree,Depth-First Search,Binary Tree
Easy
230
222
foreign problem of counting of the complete binary tree nodes let us begin we are given a complete binary tree it means that all levels are completely filled except a few nodes at the end of the last level we are required to count the number of nodes in less than o and time complexity in the first method we will use DF...
Count Complete Tree Nodes
count-complete-tree-nodes
Given the `root` of a **complete** binary tree, return the number of the nodes in the tree. According to **[Wikipedia](http://en.wikipedia.org/wiki/Binary_tree#Types_of_binary_trees)**, every level, except possibly the last, is completely filled in a complete binary tree, and all nodes in the last level are as far lef...
null
Binary Search,Tree,Depth-First Search,Binary Tree
Medium
270
486
so today we're going to discuss almost same problem which i have discussed earlier but many of my viewers have not understand that question well so i found this question also and i will try my best to make this question understand well so the question is on game theory as well as on tp predict the winner so you are giv...
Predict the Winner
predict-the-winner
You are given an integer array `nums`. Two players are playing a game with this array: player 1 and player 2. Player 1 and player 2 take turns, with player 1 starting first. Both players start the game with a score of `0`. At each turn, the player takes one of the numbers from either end of the array (i.e., `nums[0]` ...
null
Array,Math,Dynamic Programming,Recursion,Game Theory
Medium
464
334
triplet subsequence this is a middle level problem and we will understand how we can solve a question like this so we'll understand this one step by step and before moving on if you haven't subscribed to learn overflow make sure to subscribe to learn workflow for regular Network videos like this so the question says we...
Increasing Triplet Subsequence
increasing-triplet-subsequence
Given an integer array `nums`, return `true` _if there exists a triple of indices_ `(i, j, k)` _such that_ `i < j < k` _and_ `nums[i] < nums[j] < nums[k]`. If no such indices exists, return `false`. **Example 1:** **Input:** nums = \[1,2,3,4,5\] **Output:** true **Explanation:** Any triplet where i < j < k is valid. ...
null
Array,Greedy
Medium
300,2122,2280
1,696
all right so let's talk about the jump game for so jump um you're going to jump at most case step in Array and yeah you can re over you want to return the maximum score you can get so in this situation um don't think too much you need to remember three uh three rules one is you want to keep in the K windows so what doe...
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
299
uh hey everybody this is larry this is day 10 of the september league daily challenge i hit the like button to subscribe and join my discord and let's do today's prom together bows and cows uh you're giving birds and cows as guests number okay so this is like mastermind or some sort of board game where you have to gues...
Bulls and Cows
bulls-and-cows
You are playing the **[Bulls and Cows](https://en.wikipedia.org/wiki/Bulls_and_Cows)** game with your friend. You write down a secret number and ask your friend to guess what the number is. When your friend makes a guess, you provide a hint with the following info: * The number of "bulls ", which are digits in the ...
null
Hash Table,String,Counting
Medium
null
4
okay so our next problem we're going to be working on is number four it's a hard one I'm excited to do our first hard problem I think hard problems are probably going to be more interesting that's the only reason so actually I don't think this problem is too hard though but we'll see I think they're a bit being a bit g...
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
1,775
so hello everyone uh in this video i will be explaining the problem equal sum arrays with minimum number of operations so this problem is a little bit tougher than medium because there are several instances in while solving the problem that you can go wrong and in fact i was also able to solve this problem only after t...
Equal Sum Arrays With Minimum Number of Operations
design-an-ordered-stream
You are given two arrays of integers `nums1` and `nums2`, possibly of different lengths. The values in the arrays are between `1` and `6`, inclusive. In one operation, you can change any integer's value in **any** of the arrays to **any** value between `1` and `6`, inclusive. Return _the minimum number of operations ...
Maintain the next id that should be outputted. Maintain the ids that were inserted in the stream. Per each insert, make a loop where you check if the id that has the turn has been inserted, and if so increment the id that has the turn and continue the loop, else break.
Array,Hash Table,Design,Data Stream
Easy
null
616
okay so lead code practice question so in this video there are two goals so the first goal is to see how you're going to solve this problem and the second goal is uh to see how you're going to behave during the real interview so let's get started so the first step in the real interview is always to try to first um unde...
Add Bold Tag in String
add-bold-tag-in-string
You are given a string `s` and an array of strings `words`. You should add a closed pair of bold tag **and** to wrap the substrings in `s` that exist in `words`. * If two such substrings overlap, you should wrap them together with only one pair of closed bold-tag. * If two substrings wrapped by bold tags are cons...
null
Array,Hash Table,String,Trie,String Matching
Medium
56,591
1,354
hey everybody this is larry this is may 9th uh the nine day of the main league daily challenge hit the like button hit the subscribe button join me on discord let me know what you think about today's farm uh it is mother's day by the way in at least the us uh so you know happy day to all the mothers out there and yeah ...
Construct Target Array With Multiple Sums
find-players-with-zero-or-one-losses
You are given an array `target` of n integers. From a starting array `arr` consisting of `n` 1's, you may perform the following procedure : * let `x` be the sum of all elements currently in your array. * choose index `i`, such that `0 <= i < n` and set the value of `arr` at index `i` to `x`. * You may repeat thi...
Count the number of times a player loses while iterating through the matches.
Array,Hash Table,Sorting,Counting
Medium
236
287
hey everyone welcome back and let's write some more neat code today so today let's all find the duplicate number and you can see that i'm not really a big fan of this problem and maybe i'm just salty but i really feel like this type of problem is the ultimate test of whether you've seen the problem or not but i'm still...
Find the Duplicate Number
find-the-duplicate-number
Given an array of integers `nums` containing `n + 1` integers where each integer is in the range `[1, n]` inclusive. There is only **one repeated number** in `nums`, return _this repeated number_. You must solve the problem **without** modifying the array `nums` and uses only constant extra space. **Example 1:** **...
null
Array,Two Pointers,Binary Search,Bit Manipulation
Medium
41,136,142,268,645
41
you hey what's up guys Andrew here today we're gonna be doing another Levite Code episode so today we're gonna be doing question number 41 which is called first missing positive so today I had our this weekend I had time to do a hard question or what they consider to be hard so let's go ahead and take a look at it so t...
First Missing Positive
first-missing-positive
Given an unsorted integer array `nums`, return the smallest missing positive integer. You must implement an algorithm that runs in `O(n)` time and uses constant extra space. **Example 1:** **Input:** nums = \[1,2,0\] **Output:** 3 **Explanation:** The numbers in the range \[1,2\] are all in the array. **Example 2:*...
Think about how you would solve the problem in non-constant space. Can you apply that logic to the existing space? We don't care about duplicates or non-positive integers Remember that O(2n) = O(n)
Array,Hash Table
Hard
268,287,448,770
1,993
hey what's up guys it's chung here so this time it's called number 1993 operations on three okay so this one is a design problem so basically you're given like a tree with unknowns right from zero to n minus 1 and then in the form of a parent array where like the value of the of this parent i is the parent of the ice n...
Operations on Tree
sum-of-all-subset-xor-totals
You are given a tree with `n` nodes numbered from `0` to `n - 1` in the form of a parent array `parent` where `parent[i]` is the parent of the `ith` node. The root of the tree is node `0`, so `parent[0] = -1` since it has no parent. You want to design a data structure that allows users to lock, unlock, and upgrade node...
Is there a way to iterate through all the subsets of the array? Can we use recursion to efficiently iterate through all the subsets?
Array,Math,Backtracking,Bit Manipulation,Combinatorics
Easy
null
25
Hello Guys Welcome Pilgrims Video Subscribe Thursday Modified Cars in Adhir and Nodal Mist Subscribe's To-Do List Notes in To-Do List Notes in To-Do List Notes in Hindi Dubbed Subscribe Query in Report The Key Elements in Awadh Liberty Interview subscribe and subscribe the Channel Total of Wave Vidron Its 2nd Floor And...
Reverse Nodes in k-Group
reverse-nodes-in-k-group
Given the `head` of a linked list, reverse the nodes of the list `k` at a time, and return _the modified list_. `k` is a positive integer and is less than or equal to the length of the linked list. If the number of nodes is not a multiple of `k` then left-out nodes, in the end, should remain as it is. You may not alt...
null
Linked List,Recursion
Hard
24,528,2196
981
hey everybody this is Larry this is day six of the liko day challenge hit the like button hit the Subscribe button join me on Discord let me know what you think about this problem no bonus points today's problem is time based key Value Store okay so what are we doing here time based Cuba you thought I could store multi...
Time Based Key-Value Store
delete-columns-to-make-sorted
Design a time-based key-value data structure that can store multiple values for the same key at different time stamps and retrieve the key's value at a certain timestamp. Implement the `TimeMap` class: * `TimeMap()` Initializes the object of the data structure. * `void set(String key, String value, int timestamp)...
null
Array,String
Easy
null