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
42
so if I was to give you a elevation map represented by non-negative integers represented by non-negative integers represented by non-negative integers where each width of the bar is one how much water is there in this graph so the water would be falling into these uh troughs or pits basically so how would we go about c...
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
778
today we are solving swim and Rising water problem we are given an N cross and integer Matrix grid Andross and means this is a square Matrix where each value represents the elevation at that point we have to return the least time it takes to get to the bottom right Square from the top left Square we also can swim infin...
Swim in Rising Water
reorganize-string
You are given an `n x n` integer matrix `grid` where each value `grid[i][j]` represents the elevation at that point `(i, j)`. The rain starts to fall. At time `t`, the depth of the water everywhere is `t`. You can swim from a square to another 4-directionally adjacent square if and only if the elevation of both square...
Alternate placing the most common letters.
Hash Table,String,Greedy,Sorting,Heap (Priority Queue),Counting
Medium
358,621,1304
37
So this question number 37 is only box, so it should have all the 9 elements from van to van, like I have written the condition here, now we will solve it using reasoning, so first of all what will we do, so what will be our first step that we will People will check what 129 will not happen in our show, first of all we...
Sudoku Solver
sudoku-solver
Write a program to solve a Sudoku puzzle by filling the empty cells. A sudoku solution must satisfy **all of the following rules**: 1. Each of the digits `1-9` must occur exactly once in each row. 2. Each of the digits `1-9` must occur exactly once in each column. 3. Each of the digits `1-9` must occur exactly onc...
null
Array,Backtracking,Matrix
Hard
36,1022
51
Hello hello viewers welcome back to my channel thank you are in extreme level shoppers stop and thank you so much for deep 124 response to destroy subscribe series is really no one by banai reddy comment and everything thank you so much sona will be back to Replacement Released In The End Today Will Be Discussing A Pro...
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,716
Hello and welcome to this channel again this is Shaur Awasti and today we will talk about easy level problem of lead quote which is calculate money in lead quote bank so basically this problem says that there is a man named Harsi and this man keeps his money lead code in the bank. Saves and saves in this order that he ...
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
916
Hello hello guys welcome oil hot midding on whatsapp subscribe And subscribe The Amazing Bramble your subscribe Video subscribe award from every subscribe to a vital role of all the universal what can you do subscribe my channel do n't forget to subscribe and subscribe to every word that IS PRESENT IN THIS FRIENDS LET'...
Word Subsets
decoded-string-at-index
You are given two string arrays `words1` and `words2`. A string `b` is a **subset** of string `a` if every letter in `b` occurs in `a` including multiplicity. * For example, `"wrr "` is a subset of `"warrior "` but is not a subset of `"world "`. A string `a` from `words1` is **universal** if for every string `b` i...
null
String,Stack
Medium
null
463
Jai Hind in this video national grid problem number 460 free ireland per meter give way to learn great depression in this map and greater physical world one drops loop and create a physical 50 per cent of total arm hole 100 water is a silent in directions first Rot in directions sample which is ireland which control ca...
Island Perimeter
island-perimeter
You are given `row x col` `grid` representing a map where `grid[i][j] = 1` represents land and `grid[i][j] = 0` represents water. Grid cells are connected **horizontally/vertically** (not diagonally). The `grid` is completely surrounded by water, and there is exactly one island (i.e., one or more connected land cells)...
null
Array,Depth-First Search,Breadth-First Search,Matrix
Easy
695,733,1104
73
It is 100 friends, today we are going to see question number 108 Matrix Russia, it is good that the playlist of Swar Din Bhi Alarms Show should be checked in the description. A question is simple that wherever we are seeing many heroes, its whole soul is zero to the entire column. I do it, okay, I will explain the rest...
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
7
hello everyone today we're going to be doing a elite code medium algorithm question we're going to be doing this submission in python we're going to take a look at leak code number seven reverse and integer so the idea here is they're going to give us an integer it's going to be no greater than a 32-bit integer to be n...
Reverse Integer
reverse-integer
Given a signed 32-bit integer `x`, return `x` _with its digits reversed_. If reversing `x` causes the value to go outside the signed 32-bit integer range `[-231, 231 - 1]`, then return `0`. **Assume the environment does not allow you to store 64-bit integers (signed or unsigned).** **Example 1:** **Input:** x = 123 ...
null
Math
Medium
8,190,2238
172
172 factorial trailing zeros from lithgow given an integer and return the number of trailing zeros in n factorial so the question is asking us an integer is given we should calculate the factorial and see if it has any trailing zeros three factorial is going to be six and six has no trailing zero and for this example f...
Factorial Trailing Zeroes
factorial-trailing-zeroes
Given an integer `n`, return _the number of trailing zeroes in_ `n!`. Note that `n! = n * (n - 1) * (n - 2) * ... * 3 * 2 * 1`. **Example 1:** **Input:** n = 3 **Output:** 0 **Explanation:** 3! = 6, no trailing zero. **Example 2:** **Input:** n = 5 **Output:** 1 **Explanation:** 5! = 120, one trailing zero. **Exa...
null
Math
Medium
233,809,2222
838
Hello Everyone Welcome to Date Whose Light Chalu Necklace Questions Ask Dominance in This Question Will Give in This Inspirational Lines of Side and Applied Chiffon 20 York The Video then subscribe to the Page if you liked The Video then subscribe to the Video then Jhaal ke dask in the space provided a question is pair...
Push Dominoes
design-linked-list
There are `n` dominoes in a line, and we place each domino vertically upright. In the beginning, we simultaneously push some of the dominoes either to the left or to the right. After each second, each domino that is falling to the left pushes the adjacent domino on the left. Similarly, the dominoes falling to the righ...
null
Linked List,Design
Medium
1337
767
hey everyone welcome back today we are going to solve problem number 767 reorganized string first we will see the explanation of the problem statement then the logic on the code now let's tab under the solution so in this problem we are given a string and we need to arrange this string such that we don't have repeated ...
Reorganize String
prime-number-of-set-bits-in-binary-representation
Given a string `s`, rearrange the characters of `s` so that any two adjacent characters are not the same. Return _any possible rearrangement of_ `s` _or return_ `" "` _if not possible_. **Example 1:** **Input:** s = "aab" **Output:** "aba" **Example 2:** **Input:** s = "aaab" **Output:** "" **Constraints:** * ...
Write a helper function to count the number of set bits in a number, then check whether the number of set bits is 2, 3, 5, 7, 11, 13, 17 or 19.
Math,Bit Manipulation
Easy
191
65
hello and welcome back to the cracking fang youtube channel today we're going to be solving leak code problem 65 valid number before we do i just want to ask that you subscribe to the channel i'm making a lot of these videos for you guys and i want to grow help me grow subscribe to the channel all right a valid number ...
Valid Number
valid-number
A **valid number** can be split up into these components (in order): 1. A **decimal number** or an **integer**. 2. (Optional) An `'e'` or `'E'`, followed by an **integer**. A **decimal number** can be split up into these components (in order): 1. (Optional) A sign character (either `'+'` or `'-'`). 2. One of the...
null
String
Hard
8
1,920
Them from American Today they will discuss the problem that is the way are from permission okay so the scene is something that you must be given deep and that is you have to shoot that must be ravish ambulance and which is our answer of I is that bare shot name injury There should be flu due to eye and IQ hero, you wil...
Build Array from Permutation
determine-color-of-a-chessboard-square
Given a **zero-based permutation** `nums` (**0-indexed**), build an array `ans` of the **same length** where `ans[i] = nums[nums[i]]` for each `0 <= i < nums.length` and return it. A **zero-based permutation** `nums` is an array of **distinct** integers from `0` to `nums.length - 1` (**inclusive**). **Example 1:** *...
Convert the coordinates to (x, y) - that is, "a1" is (1, 1), "d7" is (4, 7). Try add the numbers together and look for a pattern.
Math,String
Easy
null
763
hey everybody this is larry this is day four of the september league daily challenge uh hit the like button hit the subscribe button join me on discord and let's get started on this farm so i'm solving this lives i don't know what it is so let's see how it goes petition label uh let's see uh a string s of lowercase eng...
Partition Labels
special-binary-string
You are given a string `s`. We want to partition the string into as many parts as possible so that each letter appears in at most one part. Note that the partition is done so that after concatenating all the parts in order, the resultant string should be `s`. Return _a list of integers representing the size of these ...
Draw a line from (x, y) to (x+1, y+1) if we see a "1", else to (x+1, y-1). A special substring is just a line that starts and ends at the same y-coordinate, and that is the lowest y-coordinate reached. Call a mountain a special substring with no special prefixes - ie. only at the beginning and end is the lowest y-coo...
String,Recursion
Hard
678
134
Jhaal Hello Hi Guys Welcome To Ko Dad Today's Question Is Gas Station In This Question Bihar Government Gas Here And Appointed To Find A Starting Point From Which We Can Start So That We Can Cover All The Guests In A Circular Wait For Example In This Case Yagya Gas Station Where Is This represents the amount of gas wit...
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
58
welcome back to Alo GS today's question is leak code 58 length of the last word right so this easy question has given us a string s containing words and spaces return the length of the last word in the string a word is a maximum substring consisting of non-space characters only consisting of non-space characters only c...
Length of Last Word
length-of-last-word
Given a string `s` consisting of words and spaces, return _the length of the **last** word in the string._ A **word** is a maximal substring consisting of non-space characters only. **Example 1:** **Input:** s = "Hello World " **Output:** 5 **Explanation:** The last word is "World " with length 5. **Example 2:** ...
null
String
Easy
null
1,550
Hello hello friends welcome back to my channel today we are going to discuss easy problem from the wiki contest 202 sauda problem title has three positive and isro and is awards were given as were given in this way are and what were to meanwhile have to shabad Dhun lagi re chal vighnaachi quantity number 2,000 hai boon...
Three Consecutive Odds
find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows
Given an integer array `arr`, return `true` if there are three consecutive odd numbers in the array. Otherwise, return `false`. **Example 1:** **Input:** arr = \[2,6,4,1\] **Output:** false **Explanation:** There are no three consecutive odds. **Example 2:** **Input:** arr = \[1,2,34,3,4,5,7,23,12\] **Output:** tru...
Save all visited sums and corresponding indexes in a priority queue. Then, once you pop the smallest sum so far, you can quickly identify the next m candidates for smallest sum by incrementing each row index by 1.
Array,Binary Search,Heap (Priority Queue),Matrix
Hard
null
1,979
hey everybody this is larry this is me going with q1 of the weekly contest 255. find greatest common divisor of a way uh hit the like button hit a subscriber and join me on discord hopefully you shouldn't have trouble with this is just doing what they tell you and i would also say that most languages have a library fun...
Find Greatest Common Divisor of Array
maximum-number-of-people-that-can-be-caught-in-tag
Given an integer array `nums`, return _the **greatest common divisor** of the smallest number and largest number in_ `nums`. The **greatest common divisor** of two numbers is the largest positive integer that evenly divides both numbers. **Example 1:** **Input:** nums = \[2,5,6,9,10\] **Output:** 2 **Explanation:** ...
Try to use as much of the range of a person who is "it" as possible. Find the leftmost person who is "it" that has not caught anyone yet, and the leftmost person who is not "it" that has not been caught yet. If the person who is not "it" can be caught, pair them together and repeat the process. If the person who is not...
Array,Greedy
Medium
2191
152
hello welcome to my channel today we have leeco 152 maximum product sub array so given an integer array nums find the continuous sub array within an array then containing at least one number which is the largest uh product so the example one is having input array two three negative two four then you would have two and ...
Maximum Product Subarray
maximum-product-subarray
Given an integer array `nums`, find a subarray that has the largest product, and return _the product_. The test cases are generated so that the answer will fit in a **32-bit** integer. **Example 1:** **Input:** nums = \[2,3,-2,4\] **Output:** 6 **Explanation:** \[2,3\] has the largest product 6. **Example 2:** **I...
null
Array,Dynamic Programming
Medium
53,198,238,628,713
128
welcome to my youtube channel today we will see another late code problem longest consecutive sequence and here we have an unsorted array of integers called nums and here we will need to find out the longest uh the c consecutive sequences let's say for this array what will be the longest consecutive sequence that will ...
Longest Consecutive Sequence
longest-consecutive-sequence
Given an unsorted array of integers `nums`, return _the length of the longest consecutive elements sequence._ You must write an algorithm that runs in `O(n)` time. **Example 1:** **Input:** nums = \[100,4,200,1,3,2\] **Output:** 4 **Explanation:** The longest consecutive elements sequence is `[1, 2, 3, 4]`. Therefor...
null
Array,Hash Table,Union Find
Medium
298,2278
3
hey how's it going uh this is casa moani and in this video we will go through a very popular uh coding interview question um called longest substring without repeating characters this is a fairly simple coding question but is often sort of non-trivial to come up often sort of non-trivial to come up often sort of non-tr...
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,752
so hello guys welcome back again today we will do the problem check if it is either a sorted array or not at first I will make our book okay fine so our today's problem is check if the array is sorted or rotated you know the sorted array what is and you need to know what is a rotated array it is a basic question is in ...
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
1,834
hey everybody this is Larry this is day 29 of the legal daily challenge hit the like button hit the Subscribe button join me on Discord let me know what you think about this Farm uh yeah a few more days of the Year hope everyone had a good year uh Market's been tough uh for me anyway so and of course the tech markets a...
Single-Threaded CPU
minimum-number-of-people-to-teach
You are given `n`​​​​​​ tasks labeled from `0` to `n - 1` represented by a 2D integer array `tasks`, where `tasks[i] = [enqueueTimei, processingTimei]` means that the `i​​​​​​th`​​​​ task will be available to process at `enqueueTimei` and will take `processingTimei` to finish processing. You have a single-threaded CPU...
You can just use brute force and find out for each language the number of users you need to teach Note that a user can appear in multiple friendships but you need to teach that user only once
Array,Greedy
Medium
null
205
hey everybody this is larry this is day 12 of the july deco daily challenge hit the like button hit the subscribe button join me on discord let me know what you think about today's problem isomorphic string given s and t demanding the isomorphic if the characters and s can replace the t okay no two characters may map t...
Isomorphic Strings
isomorphic-strings
Given two strings `s` and `t`, _determine if they are isomorphic_. Two strings `s` and `t` are isomorphic if the characters in `s` can be replaced to get `t`. All occurrences of a character must be replaced with another character while preserving the order of characters. No two characters may map to the same characte...
null
Hash Table,String
Easy
290
82
hey everyone welcome back and let's write some more neat code today so today let's solve the problem remove duplicates from sorted list so we did solve a very similar problem to this one where instead of removing the duplicates from a sorted list we were doing it with a sorted array and in this case when they say list ...
Remove Duplicates from Sorted List II
remove-duplicates-from-sorted-list-ii
Given the `head` of a sorted linked list, _delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list_. Return _the linked list **sorted** as well_. **Example 1:** **Input:** head = \[1,2,3,3,4,4,5\] **Output:** \[1,2,5\] **Example 2:** **Input:** head = \[1,1,1,2,3\] **Outpu...
null
Linked List,Two Pointers
Medium
83,1982
918
Hello hello guys welcome back to take 2 sign in this video bhi seedha maximum circular saver problem with established codification of the match so let's no problem the giver simple and will last for limited subscribe to the Page if you liked The Video then subscribe to the maximum subscribe and subscribe the Video then...
Maximum Sum Circular Subarray
reachable-nodes-in-subdivided-graph
Given a **circular integer array** `nums` of length `n`, return _the maximum possible sum of a non-empty **subarray** of_ `nums`. A **circular array** means the end of the array connects to the beginning of the array. Formally, the next element of `nums[i]` is `nums[(i + 1) % n]` and the previous element of `nums[i]` ...
null
Graph,Heap (Priority Queue),Shortest Path
Hard
2213,2218
380
Hello friends today I'm going to solve record problem number 380 insert delete get random of one so in this uh problem we need to implement a randomized set class in this class we need to initialize our randomized set object in this function which is the very first function here and then we need to Define our insert re...
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
1,603
hey guys welcome to my channel thanks for coming back to my channel and choosing my video to solve the problem so today we'll try to solve the lead code problem 1603 easy which is design parking system so here we are given what we have to do is we are given an input which is uh a area of string which says parking syste...
Design Parking System
running-sum-of-1d-array
Design a parking system for a parking lot. The parking lot has three kinds of parking spaces: big, medium, and small, with a fixed number of slots for each size. Implement the `ParkingSystem` class: * `ParkingSystem(int big, int medium, int small)` Initializes object of the `ParkingSystem` class. The number of slot...
Think about how we can calculate the i-th number in the running sum from the (i-1)-th number.
Array,Prefix Sum
Easy
null
925
yeahyeah Hi everyone, I'm a programmer. Today I'm going to introduce to you a math problem with pronouns as follows. The name is typed out long. Let's go into the details of the problem. The details are as follows, your friend is typing his name on the keyboard. Sometimes when typing a letter c, the keyboard can be pre...
Long Pressed Name
construct-binary-tree-from-preorder-and-postorder-traversal
Your friend is typing his `name` into a keyboard. Sometimes, when typing a character `c`, the key might get _long pressed_, and the character will be typed 1 or more times. You examine the `typed` characters of the keyboard. Return `True` if it is possible that it was your friends name, with some characters (possibly ...
null
Array,Hash Table,Divide and Conquer,Tree,Binary Tree
Medium
null
73
Hello guys welcome to my video dham coding cricket us problem call me to elements of obscuritism example subscribe to like this 12345 videos do subscribe thank you to all so much that they cry to retire from this inter college students were already Made Column Jimmy Rolls Royce Ne Xerox Suresh Point From Bigg Boss Simi...
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
289
Hello Everyone and Welcome back to my channel Algorithm HQ Today I am going to write the code and also explain to you all the algorithm to solve this game of life problem what is there in lead code it is a medium level problem and can be solved Intuitive using a very easy approach. So let's start it by taking the name ...
Game of Life
game-of-life
According to [Wikipedia's article](https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life): "The **Game of Life**, also known simply as **Life**, is a cellular automaton devised by the British mathematician John Horton Conway in 1970. " The board is made up of an `m x n` grid of cells, where each cell has an initial st...
null
Array,Matrix,Simulation
Medium
73
518
Hai Bhai Kalyan Loot Se Hai Jhaal Shri Ram Products will be very good and will group you in DP, these accused patience tablets will also be learning Prakash today's video back bus naam barabar video bana raha yudhak hum aur Big End This Question Custom Should Be Destino Light Come Tourist Attraction Shyam Different Use...
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,081
hey guys uh today we will be solving a new question of lead code uh the question is smallest sub sequence of additional characters okay so we have to return the lexicographically smallest subsequence of s that contains all the distinct characters of s exactly once and the constraints are that the length of the string w...
Smallest Subsequence of Distinct Characters
video-stitching
Given a string `s`, return _the_ _lexicographically smallest_ _subsequence_ _of_ `s` _that contains all the distinct characters of_ `s` _exactly once_. **Example 1:** **Input:** s = "bcabc " **Output:** "abc " **Example 2:** **Input:** s = "cbacdcbc " **Output:** "acdb " **Constraints:** * `1 <= s.length <=...
What if we sort the intervals? Considering the sorted intervals, how can we solve the problem with dynamic programming? Let's consider a DP(pos, limit) where pos represents the position of the current interval we are gonna take the decision and limit is the current covered area from [0 - limit]. This DP returns the mi...
Array,Dynamic Programming,Greedy
Medium
null
83
foreign this is Topher and today we're going to go over remove duplicates from sorted list number 83 of lead code so given the head of a sorted linked list delete all duplicates such that each element appears only once and return the link list sorted as well so you can see below here I have an example of a linked list ...
Remove Duplicates from Sorted List
remove-duplicates-from-sorted-list
Given the `head` of a sorted linked list, _delete all duplicates such that each element appears only once_. Return _the linked list **sorted** as well_. **Example 1:** **Input:** head = \[1,1,2\] **Output:** \[1,2\] **Example 2:** **Input:** head = \[1,1,2,3,3\] **Output:** \[1,2,3\] **Constraints:** * The numb...
null
Linked List
Easy
82,1982
377
hello everyone welcome to coding decoded my name is anthony i'm working as technical architect at adobe and here i present the 5th of august liquid challenge the problem that we have in today's combination sum four this problem is based on the concept of recursion plus memoization and i know most of the subscribers of ...
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,727
let's go to code number 1,727 largest submatrix with 1,727 largest submatrix with 1,727 largest submatrix with rearrangement for this question it give us a matrix which is in integer two dimensional integer array and there is one and zero the s that we want to find the largest area uh rect angle area right but there is...
Largest Submatrix With Rearrangements
cat-and-mouse-ii
You are given a binary matrix `matrix` of size `m x n`, and you are allowed to rearrange the **columns** of the `matrix` in any order. Return _the area of the largest submatrix within_ `matrix` _where **every** element of the submatrix is_ `1` _after reordering the columns optimally._ **Example 1:** **Input:** matri...
Try working backward: consider all trivial states you know to be winning or losing, and work backward to determine which other states can be labeled as winning or losing.
Math,Dynamic Programming,Breadth-First Search,Graph,Memoization,Game Theory
Hard
805,949
1,005
all right let's talk about the maximum sound of array after k negation so you're given a really numbs and into the k so modify the array in a following way so this is it right so you have exactly k times and then you're going to choose in this eye to multiple times right so you can have it multiple times for same index...
Maximize Sum Of Array After K Negations
univalued-binary-tree
Given an integer array `nums` and an integer `k`, modify the array in the following way: * choose an index `i` and replace `nums[i]` with `-nums[i]`. You should apply this process exactly `k` times. You may choose the same index `i` multiple times. Return _the largest possible sum of the array after modifying it i...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Easy
1609
1,748
Number of - Friends, today we will talk about Number of - Friends, today we will talk about Number of - Friends, today we will talk about question for, so let's see what is the question for? Well, let's see, this is the question we have, this is a proper question, okay, so here you notice this thing and notice is writt...
Sum of Unique Elements
best-team-with-no-conflicts
You are given an integer array `nums`. The unique elements of an array are the elements that appear **exactly once** in the array. Return _the **sum** of all the unique elements of_ `nums`. **Example 1:** **Input:** nums = \[1,2,3,2\] **Output:** 4 **Explanation:** The unique elements are \[1,3\], and the sum is 4. ...
First, sort players by age and break ties by their score. You can now consider the players from left to right. If you choose to include a player, you must only choose players with at least that score later on.
Array,Dynamic Programming,Sorting
Medium
null
1,234
let's look at problem uh one two three four replace the substring for balanced string so first i will go over the statement of the problem and then we will give a walkthrough of the example and lastly we're going to write a solution using the standard two-pointer sliding window solution two-pointer sliding window solut...
Replace the Substring for Balanced String
number-of-paths-with-max-score
You are given a string s of length `n` containing only four kinds of characters: `'Q'`, `'W'`, `'E'`, and `'R'`. A string is said to be **balanced** if each of its characters appears `n / 4` times where `n` is the length of the string. Return _the minimum length of the substring that can be replaced with **any** othe...
Use dynamic programming to find the path with the max score. Use another dynamic programming array to count the number of paths with max score.
Array,Dynamic Programming,Matrix
Hard
null
99
hey what's up guys this is Chung here again so continue on the late cold problems here today we're gonna do talk about this night number 99 recover binary search tree this is marked as a hard problem I think you know for the native naive log n log and solutions I think it's kind of like a medium each level problem but ...
Recover Binary Search Tree
recover-binary-search-tree
You are given the `root` of a binary search tree (BST), where the values of **exactly** two nodes of the tree were swapped by mistake. _Recover the tree without changing its structure_. **Example 1:** **Input:** root = \[1,3,null,null,2\] **Output:** \[3,1,null,null,2\] **Explanation:** 3 cannot be a left child of 1 ...
null
Tree,Depth-First Search,Binary Search Tree,Binary Tree
Medium
null
138
hey everybody this is larry this is day 10 of the february let go daily challenge hit the like button hit the subscribe button join me on discord ask questions hang out talk about the market or something uh okay so 10 days in today's problem is copy list with a random pointer so i do solve this live so if it goes a lit...
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
367
because 367 question perfect square um a valid perfect square so basically uh we are given a positive integer norm uh while a function which returns true if num is a perfect square else false so do not use any booting library functions such as square root um so for example 16 uh we know it's like 4 times 4 is 16 so it'...
Valid Perfect Square
valid-perfect-square
Given a positive integer num, return `true` _if_ `num` _is a perfect square or_ `false` _otherwise_. A **perfect square** is an integer that is the square of an integer. In other words, it is the product of some integer with itself. You must not use any built-in library function, such as `sqrt`. **Example 1:** **In...
null
Math,Binary Search
Easy
69,633
799
hey everyone today we are going to throw the little question Champion tour so there are glasses in a pyramid like this and we put champagne from the top and each glass holds one cup of champagne and when the topmost glass is full any excess liquid food we will fall equal to the grass immediately to the left and the rig...
Champagne Tower
minimum-distance-between-bst-nodes
We stack glasses in a pyramid, where the **first** row has `1` glass, the **second** row has `2` glasses, and so on until the 100th row. Each glass holds one cup of champagne. Then, some champagne is poured into the first glass at the top. When the topmost glass is full, any excess liquid poured will fall equally to t...
null
Tree,Depth-First Search,Breadth-First Search,Binary Search Tree,Binary Tree
Easy
94
509
hello everyone welcome to learn book club in this video we will discuss about today's list code problem that is the fibonacci number obviously this is an easy level question and uh but we'll try to understand how we can impose this question in like top down dp and bottom updp like we'll go ahead with dp we can i will d...
Fibonacci Number
inorder-successor-in-bst-ii
The **Fibonacci numbers**, commonly denoted `F(n)` form a sequence, called the **Fibonacci sequence**, such that each number is the sum of the two preceding ones, starting from `0` and `1`. That is, F(0) = 0, F(1) = 1 F(n) = F(n - 1) + F(n - 2), for n > 1. Given `n`, calculate `F(n)`. **Example 1:** **Input:** n = ...
null
Tree,Binary Search Tree,Binary Tree
Medium
285
235
foreign code called the lowest common ancestor of a binary search tree it is a medium we're going to jump right into it given a binary search tree or a BSC find the lowest common ancestor node of two given nodes in the BST according to the definition of LCA on Wiki the lowest common ancestor is defined between two node...
Lowest Common Ancestor of a Binary Search Tree
lowest-common-ancestor-of-a-binary-search-tree
Given a binary search tree (BST), find the lowest common ancestor (LCA) node of two given nodes in the BST. According to the [definition of LCA on Wikipedia](https://en.wikipedia.org/wiki/Lowest_common_ancestor): "The lowest common ancestor is defined between two nodes `p` and `q` as the lowest node in `T` that has bo...
null
Tree,Depth-First Search,Binary Search Tree,Binary Tree
Easy
236,1190,1780,1790,1816
1,832
um hello so today we are going to do this problem which is part of lead code October challenge check if sentence is pangram um so the problem says a plan gram is a sentence where every letter of the alphabet appears at least once right so given a sentence we're going to check if it contains only lowercase English lette...
Check if the Sentence Is Pangram
minimum-operations-to-make-a-subsequence
A **pangram** is a sentence where every letter of the English alphabet appears at least once. Given a string `sentence` containing only lowercase English letters, return `true` _if_ `sentence` _is a **pangram**, or_ `false` _otherwise._ **Example 1:** **Input:** sentence = "thequickbrownfoxjumpsoverthelazydog " **O...
The problem can be reduced to computing Longest Common Subsequence between both arrays. Since one of the arrays has distinct elements, we can consider that these elements describe an arrangement of numbers, and we can replace each element in the other array with the index it appeared at in the first array. Then the pro...
Array,Hash Table,Binary Search,Greedy
Hard
null
373
hello everyone welcome back here is vanamsen and today we are going to solve uh and optimize lead code problem 373 find Keepers with smallest sum so let's dive in to briefly explain the problem we are given two sorted integer RI and an integer key and we need to return the key smallest per form by taking one elements f...
Find K Pairs with Smallest Sums
find-k-pairs-with-smallest-sums
You are given two integer arrays `nums1` and `nums2` sorted in **ascending order** and an integer `k`. Define a pair `(u, v)` which consists of one element from the first array and one element from the second array. Return _the_ `k` _pairs_ `(u1, v1), (u2, v2), ..., (uk, vk)` _with the smallest sums_. **Example 1:**...
null
Array,Heap (Priority Queue)
Medium
378,719,2150
1,466
Hello everyone welcome, you are going to channel me, okay and I will repeat again that if you have not seen my players with graph construction questions, then watch it, the fundamentals of the graph will be clear to you very well. The questions and the graph are okay, so if that If you have n't seen the play list then ...
Reorder Routes to Make All Paths Lead to the City Zero
jump-game-v
There are `n` cities numbered from `0` to `n - 1` and `n - 1` roads such that there is only one way to travel between two different cities (this network form a tree). Last year, The ministry of transport decided to orient the roads in one direction because they are too narrow. Roads are represented by `connections` wh...
Use dynamic programming. dp[i] is max jumps you can do starting from index i. Answer is max(dp[i]). dp[i] = 1 + max (dp[j]) where j is all indices you can reach from i.
Array,Dynamic Programming,Sorting
Hard
2001
237
hey everyone welcome back and today we will be doing another lead code problem 237 delete node in a linked list this is a medium one there is a singly linked list head and we want to delete a node in it so we are just given the node and we have to delete the node we do not have the access to the Head of the node and we...
Delete Node in a Linked List
delete-node-in-a-linked-list
There is a singly-linked list `head` and we want to delete a node `node` in it. You are given the node to be deleted `node`. You will **not be given access** to the first node of `head`. All the values of the linked list are **unique**, and it is guaranteed that the given node `node` is not the last node in the linke...
null
Linked List
Easy
203
64
hi guys hope you're doing great today's question is minimum path some given M by n great filled with non-negative numbers find a path from non-negative numbers find a path from non-negative numbers find a path from top left to bottom right which is for example in this case 0 comma 0 to 3 comma 3 right sorry 2 comma 2 r...
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
225
so this question asks you to implement that using cues so we'll start off by describing what the difference is between a stack and the queue so with the queue you'll commonly hear the term FIFO this means first-in first-out FIFO this means first-in first-out FIFO this means first-in first-out and what that means is the...
Implement Stack using Queues
implement-stack-using-queues
Implement a last-in-first-out (LIFO) stack using only two queues. The implemented stack should support all the functions of a normal stack (`push`, `top`, `pop`, and `empty`). Implement the `MyStack` class: * `void push(int x)` Pushes element x to the top of the stack. * `int pop()` Removes the element on the top...
null
Stack,Design,Queue
Easy
232
234
given a singly linked list determine whether this is a palindrome best today's video let's get into it everyone my name is Steve today we are going through a legal problem in 234 palindrome linked lists the problem is very simple and straight for let's take a look given a singly linked list determining whether this is ...
Palindrome Linked List
palindrome-linked-list
Given the `head` of a singly linked list, return `true` _if it is a_ _palindrome_ _or_ `false` _otherwise_. **Example 1:** **Input:** head = \[1,2,2,1\] **Output:** true **Example 2:** **Input:** head = \[1,2\] **Output:** false **Constraints:** * The number of nodes in the list is in the range `[1, 105]`. * ...
null
Linked List,Two Pointers,Stack,Recursion
Easy
9,125,206,2236
11
hey everyone welcome back and let's write some more neat code so today we're going to be solving leak code 11 container with most water so we're given an array of heights so this is a height 1 this is i 8 6 so on and using these heights we want to see what's the biggest area we can form with a container that has a left...
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
138
hey everyone welcome to Latvia coding today we are going to soft than 38 communists with random pointer and we can see this is a really commonly asked interval question let's see the question together so a linked list is given such that each node contains an additional random pointer that can point to any node in the l...
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
1,962
Hello everyone and welcome question, nowadays we will get minimize d total as if it is mixed and we have to do some operations by doing exactly number of time operation. What is the operation to be done, you have to choose any one number, any one file is there, it basically contains stone. This is the file, now you hav...
Remove Stones to Minimize the Total
single-threaded-cpu
You are given a **0-indexed** integer array `piles`, where `piles[i]` represents the number of stones in the `ith` pile, and an integer `k`. You should apply the following operation **exactly** `k` times: * Choose any `piles[i]` and **remove** `floor(piles[i] / 2)` stones from it. **Notice** that you can apply the ...
To simulate the problem we first need to note that if at any point in time there are no enqueued tasks we need to wait to the smallest enqueue time of a non-processed element We need a data structure like a min-heap to support choosing the task with the smallest processing time from all the enqueued tasks
Array,Sorting,Heap (Priority Queue)
Medium
2176
39
so you want to solve combination sum what does it even ask you given an array of distinct integers candidates and a target integer target return a list of all unique combinations of candidates where the chosen numbers sum to target you may return the combinations in any order the same order may be chosen from candidate...
Combination Sum
combination-sum
Given an array of **distinct** integers `candidates` and a target integer `target`, return _a list of all **unique combinations** of_ `candidates` _where the chosen numbers sum to_ `target`_._ You may return the combinations in **any order**. The **same** number may be chosen from `candidates` an **unlimited number of...
null
Array,Backtracking
Medium
17,40,77,216,254,377
1,784
hey everybody this is larry this is me going with q1 of the weekly contest 231 checking the binary string has at most one segment of ones so i think this is a i don't know if you know hit the like button hit the subscribe and join me on discord but let me know what you think about my solution even though i actually lik...
Check if Binary String Has at Most One Segment of Ones
minimum-initial-energy-to-finish-tasks
Given a binary string `s` **​​​​​without leading zeros**, return `true`​​​ _if_ `s` _contains **at most one contiguous segment of ones**_. Otherwise, return `false`. **Example 1:** **Input:** s = "1001 " **Output:** false **Explanation:** The ones do not form a contiguous segment. **Example 2:** **Input:** s = "1...
We can easily figure that the f(x) : does x solve this array is monotonic so binary Search is doable Figure a sorting pattern
Array,Greedy,Sorting
Hard
null
1,176
hi hello today we'll talk another sliding window question this question is diet plan performance let's see what this question is all about all right so this question says there is a dieter that person consumes calories every day so suppose on day zero he consumes two calories three on the first day and so we have to te...
Diet Plan Performance
design-a-leaderboard
A dieter consumes `calories[i]` calories on the `i`\-th day. Given an integer `k`, for **every** consecutive sequence of `k` days (`calories[i], calories[i+1], ..., calories[i+k-1]` for all `0 <= i <= n-k`), they look at _T_, the total calories consumed during that sequence of `k` days (`calories[i] + calories[i+1] + ...
What data structure can we use to keep the players' data? Keep a map (dictionary) of player scores. For each top(K) function call, find the maximum K scores and add them.
Hash Table,Design,Sorting
Medium
null
1,605
Hello Hi Everyone Welcome To My Channel It's All Related Problem For Invalid Matrix Giving Row And Column Sums So You Are You Rate Tours Roshan And Columns Of Negative Interior Roshan Fi System Of This Element India Through And Column Of J Is This Period Element Of Baje Jogging Column of Today Matrix in Words You Don't...
Find Valid Matrix Given Row and Column Sums
minimum-number-of-days-to-make-m-bouquets
You are given two arrays `rowSum` and `colSum` of non-negative integers where `rowSum[i]` is the sum of the elements in the `ith` row and `colSum[j]` is the sum of the elements of the `jth` column of a 2D matrix. In other words, you do not know the elements of the matrix, but you do know the sums of each row and column...
If we can make m or more bouquets at day x, then we can still make m or more bouquets at any day y > x. We can check easily if we can make enough bouquets at day x if we can get group adjacent flowers at day x.
Array,Binary Search
Medium
2134,2257
270
welcome back everyone we're going to be solving leeco 270 closest binary search tree value so we're given the root of a binary search tree and a Target value we need to return the value in the tree that is closest to the Target so we're given a tree of four two five and one three and a target of 3.71 right and one thre...
Closest Binary Search Tree Value
closest-binary-search-tree-value
Given the `root` of a binary search tree and a `target` value, return _the value in the BST that is closest to the_ `target`. If there are multiple answers, print the smallest. **Example 1:** **Input:** root = \[4,2,5,1,3\], target = 3.714286 **Output:** 4 **Example 2:** **Input:** root = \[1\], target = 4.428571 *...
null
Binary Search,Tree,Depth-First Search,Binary Search Tree,Binary Tree
Easy
222,272,783
967
welcome to another video in the graph series today's question might make you go like how will I realize that this is a graphs question and I completely get it but it is better to learn while practicing than make mistakes in the interview correct and once you do two three of these questions you will get the intuition an...
Numbers With Same Consecutive Differences
minimum-falling-path-sum
Given two integers n and k, return _an array of all the integers of length_ `n` _where the difference between every two consecutive digits is_ `k`. You may return the answer in **any order**. Note that the integers should not have leading zeros. Integers as `02` and `043` are not allowed. **Example 1:** **Input:** n...
null
Array,Dynamic Programming,Matrix
Medium
1224
700
hey everyone welcome back and today we'll be doing another lead code problem 700 search in a binary search tree this is an easy one you are given the root of the binary search tree BST and an integer valve find the node in the binary search key that node values equals the value and return the node if such a node does n...
Search in a Binary Search Tree
search-in-a-binary-search-tree
You are given the `root` of a binary search tree (BST) and an integer `val`. Find the node in the BST that the node's value equals `val` and return the subtree rooted with that node. If such a node does not exist, return `null`. **Example 1:** **Input:** root = \[4,2,7,1,3\], val = 2 **Output:** \[2,1,3\] **Example...
null
null
Easy
null
234
hi and welcome to this video today i will be talking about lead code problem 2 3 4 palindrome linked list the question says given a singly linked list determine if it's a palindrome now i'll assume you already know what palindrome is um but just to summarize it's basically the inverse of the word or the string will be ...
Palindrome Linked List
palindrome-linked-list
Given the `head` of a singly linked list, return `true` _if it is a_ _palindrome_ _or_ `false` _otherwise_. **Example 1:** **Input:** head = \[1,2,2,1\] **Output:** true **Example 2:** **Input:** head = \[1,2\] **Output:** false **Constraints:** * The number of nodes in the list is in the range `[1, 105]`. * ...
null
Linked List,Two Pointers,Stack,Recursion
Easy
9,125,206,2236
847
first okay 847 shortest-path first okay 847 shortest-path first okay 847 shortest-path visiting or notes and untie my have to connect the graph of n nodes is convenient and input graph grabbed our link as you go to N and J of chain IG goes to minus in the list graph sub I exactly once if and only if notes I and J are c...
Shortest Path Visiting All Nodes
shortest-path-visiting-all-nodes
You have an undirected, connected graph of `n` nodes labeled from `0` to `n - 1`. You are given an array `graph` where `graph[i]` is a list of all the nodes connected with node `i` by an edge. Return _the length of the shortest path that visits every node_. You may start and stop at any node, you may revisit nodes mul...
null
null
Hard
null
216
uh hey everybody this is larry this is day 12 of the lego dairy challenge for september hit the like button to subscribe and join me in discord uh let me know what you think um yeah my neck's still a little bit sore but i feel a little bit better now so i could talk a little bit faster so i hope that's okay uh and toda...
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,696
let's solve this problem let's see today's sleep code problem 5. or six what is that look at me I don't even know Roman numbers uh Let's uh what I'm going to do is I'm going to think at the uh think as if I'm in the interview and I am going to solve this problem so and I'm going to guide uh you or let's say uh talk thr...
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
392
so our question is to find the subsequence so we have given two strings so we have to return true if s is a sub subsequence of T so we can say that ABC can occur in this string if we remove h g d so a B and C similarly a c there's no X in this and we only have a and C we don't have any X between them so it is not a sub...
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
727
hey what's up guys this is john here so uh so today let's take a look at this uh 727 minimum window subsequence uh heart problem you know i think this is a good one okay let's take a look so this is like another classic like two string problem you know basically you're given like a string s and t and you need to find o...
Minimum Window Subsequence
minimum-window-subsequence
Given strings `s1` and `s2`, return _the minimum contiguous substring part of_ `s1`_, so that_ `s2` _is a subsequence of the part_. If there is no such window in `s1` that covers all characters in `s2`, return the empty string `" "`. If there are multiple such minimum-length windows, return the one with the **left-mos...
Let dp[j][e] = s be the largest index for which S[s:e+1] has T[:j] as a substring.
String,Dynamic Programming,Sliding Window
Hard
76,674
994
uh hey everybody this is larry this is the ninth day of the august decode dairy challenge uh let's get to it uh hit the like button hit the subscribe button and join me on discord and let's get to one oranges uh okay in the cellar of empty cell fresh orange and white oranges every minute of any fresh orange that's adja...
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
1,359
hey everybody this is larry this is day six of the lego daily challenge hit the like button hit the subscribe button join my discord let me know what you think about today's problem i'm in the airport right now i met it in uh mesut again and i'm going back to new york but i have maybe an hour to the fight so hopefully ...
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
1
in this video we're going to take a look at a legal problem called two sum so given an array of integer nums and a integer target return indexes of two numbers such that they add up to a target so here you can see we have an example of two seven eleven fifteen so the target is 9. so the goal is we want to return the in...
Two Sum
two-sum
Given an array of integers `nums` and an integer `target`, return _indices of the two numbers such that they add up to `target`_. You may assume that each input would have **_exactly_ one solution**, and you may not use the _same_ element twice. You can return the answer in any order. **Example 1:** **Input:** nums...
A really brute force way would be to search for all possible pairs of numbers but that would be too slow. Again, it's best to try out brute force solutions for just for completeness. It is from these brute force solutions that you can come up with optimizations. So, if we fix one of the numbers, say x, we have to scan ...
Array,Hash Table
Easy
15,18,167,170,560,653,1083,1798,1830,2116,2133,2320
11
hi everyone in this video Let's solve lead code problem number 11 container with most water the problem states that given an integer array height of length n where all the elements of vertical lines drawn such that the two endpoints of the ith line or I comma 0 and I comma height of I we need to find two lines that for...
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,637
hey everyone welcome back and let's write some more neat code today so today let's solve the problem widest vertical area between two points containing no points and if you ever needed a reminder that the difficulties on leak code problems can be really random this is a perfect example of that probably the hardest thin...
Widest Vertical Area Between Two Points Containing No Points
string-compression-ii
Given `n` `points` on a 2D plane where `points[i] = [xi, yi]`, Return _the **widest vertical area** between two points such that no points are inside the area._ A **vertical area** is an area of fixed-width extending infinitely along the y-axis (i.e., infinite height). The **widest vertical area** is the one with the ...
Use dynamic programming. The state of the DP can be the current index and the remaining characters to delete. Having a prefix sum for each character can help you determine for a certain character c in some specific range, how many characters you need to delete to merge all occurrences of c in that range.
String,Dynamic Programming
Hard
null
1,022
all right so let's talk about some of the root to leave binary number so you're given a root of binary tree so basically you just have to keep adding the number from the root to the leaf and you will return the final answer so you're going to be you're going to add 1 0 to the equation and then 1 0 1 and you will get 22...
Sum of Root To Leaf Binary Numbers
unique-paths-iii
You are given the `root` of a binary tree where each node has a value `0` or `1`. Each root-to-leaf path represents a binary number starting with the most significant bit. * For example, if the path is `0 -> 1 -> 1 -> 0 -> 1`, then this could represent `01101` in binary, which is `13`. For all leaves in the tree, c...
null
Array,Backtracking,Bit Manipulation,Matrix
Hard
37,63,212
295
hello and welcome back to the cracking fang youtube channel today we're going to be solving lead code problem 295 find median from data stream the median is the middle value of 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 exampl...
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
286
hello everyone welcome to this great dfa series of videos again so this will be the last video in this series so that is walls and gates 86 so the problem statement is saying you are given an aim into a grid rooms initialized with these three possible values minus one is represent as a wall or obstacle zero means a gat...
Walls and Gates
walls-and-gates
You are given an `m x n` grid `rooms` initialized with these three possible values. * `-1` A wall or an obstacle. * `0` A gate. * `INF` Infinity means an empty room. We use the value `231 - 1 = 2147483647` to represent `INF` as you may assume that the distance to a gate is less than `2147483647`. Fill each empt...
null
Array,Breadth-First Search,Matrix
Medium
130,200,317,865,1036
190
If you see a special then what you have to do is you will get this number, you have to print the final of this number and its reverse smile, you have to print this, if you got 11:00, then do 11:00. Bring to front 101 if you want 3000 1000 only here. But if we you got 11:00, then do 11:00. Bring to front 101 if you want...
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
1,814
Hello Hi Everyone Welcome To My YouTube Channel Students Were Decided To Me Awasthi Vriksha Subscribe My YouTube Channel Now Subscribe Our Channel Telegram Channel Subscribe Skin Problem Solve Question Subscribe The Giver Is You Are A Great Words Of The Non Negative Integer App For Example Reports 1234 Giver C-20 To An...
Count Nice Pairs in an Array
jump-game-vi
You are given an array `nums` that consists of non-negative integers. Let us define `rev(x)` as the reverse of the non-negative integer `x`. For example, `rev(123) = 321`, and `rev(120) = 21`. A pair of indices `(i, j)` is **nice** if it satisfies all of the following conditions: * `0 <= i < j < nums.length` * `nu...
Let dp[i] be "the maximum score to reach the end starting at index i". The answer for dp[i] is nums[i] + max{dp[i+j]} for 1 <= j <= k. That gives an O(n*k) solution. Instead of checking every j for every i, keep track of the largest dp[i] values in a heap and calculate dp[i] from right to left. When the largest value i...
Array,Dynamic Programming,Queue,Sliding Window,Heap (Priority Queue),Monotonic Queue
Medium
239,2001
35
hi guys today I will be explaining the lead chord challenge which is called search in insert position in Python language so there are two parameters in this function uh numbers list and the target value the task is to return the index of the target value and if you cannot find the this target value in this list it want...
Search Insert Position
search-insert-position
Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You must write an algorithm with `O(log n)` runtime complexity. **Example 1:** **Input:** nums = \[1,3,5,6\], target = 5 **Output:** 2 **Exa...
null
Array,Binary Search
Easy
278
1,314
Hello hello friends today in this video Vikram discusses another problem from dynamic programming problems fiction show problem test matric verse no shirt you in simple terms of list with you are with all the tips and cross ho but problem vitamin c tomato x and jakve loose it Front Development Research Assistant Answer...
Matrix Block Sum
matrix-block-sum
Given a `m x n` matrix `mat` and an integer `k`, return _a matrix_ `answer` _where each_ `answer[i][j]` _is the sum of all elements_ `mat[r][c]` _for_: * `i - k <= r <= i + k,` * `j - k <= c <= j + k`, and * `(r, c)` is a valid position in the matrix. **Example 1:** **Input:** mat = \[\[1,2,3\],\[4,5,6\],\[7,8...
null
null
Medium
null
1,041
That this controversy, today we introduce a new list of problems, the problem is that by setting up a robot wedding in advance, what is there in this, that they gave us a robot, whatever zero this above is the president, in the back of the plane and then we got a string. Have you seen the instruction, friends, how to f...
Robot Bounded In Circle
available-captures-for-rook
On an infinite plane, a robot initially stands at `(0, 0)` and faces north. Note that: * The **north direction** is the positive direction of the y-axis. * The **south direction** is the negative direction of the y-axis. * The **east direction** is the positive direction of the x-axis. * The **west direction**...
null
Array,Matrix,Simulation
Easy
null
237
hey how's it going guys today uh we are going to have a quick tutorial about how to recode the delete notes in a linked list in python so um the question itself is pretty straightforward you are given a linked list for 519 the note to be deleted is also given is five and your output should be on the four one nine so if...
Delete Node in a Linked List
delete-node-in-a-linked-list
There is a singly-linked list `head` and we want to delete a node `node` in it. You are given the node to be deleted `node`. You will **not be given access** to the first node of `head`. All the values of the linked list are **unique**, and it is guaranteed that the given node `node` is not the last node in the linke...
null
Linked List
Easy
203
1,503
hey everybody this is Larry this is q2 of the recent contest last moments before all ends for our of a prank these this problem descriptions are very funny straight to the point but yeah hit the like button hit the subscribe button join the discord but the there's only one observation that you have to make and I made t...
Last Moment Before All Ants Fall Out of a Plank
reducing-dishes
We have a wooden plank of the length `n` **units**. Some ants are walking on the plank, each ant moves with a speed of **1 unit per second**. Some of the ants move to the **left**, the other move to the **right**. When two ants moving in two **different** directions meet at some point, they change their directions and...
Use dynamic programming to find the optimal solution by saving the previous best like-time coefficient and its corresponding element sum. If adding the current element to the previous best like-time coefficient and its corresponding element sum would increase the best like-time coefficient, then go ahead and add it. Ot...
Array,Dynamic Programming,Greedy,Sorting
Hard
null
267
okay are we live hello i don't know how i'm doing in terms of the gain um i don't want to talk too loudly i don't remember what i did yesterday oh right now i recall i don't recall what i did yesterday i was kept my voice pretty low i don't know um i'm trying to keep my voice somewhat low today too so hello and welcome...
Palindrome Permutation II
palindrome-permutation-ii
Given a string s, return _all the palindromic permutations (without duplicates) of it_. You may return the answer in **any order**. If `s` has no palindromic permutation, return an empty list. **Example 1:** **Input:** s = "aabb" **Output:** \["abba","baab"\] **Example 2:** **Input:** s = "abc" **Output:** \[\] *...
If a palindromic permutation exists, we just need to generate the first half of the string. To generate all distinct permutations of a (half of) string, use a similar approach from: Permutations II or Next Permutation.
Hash Table,String,Backtracking
Medium
31,47,266
1,419
milk to Ajay, everyone welcome back, paper folding, Ayo point to Delhi, our serious ones, solve this no contact mon, follow them, you are solving them, keep giving like comments, do tractors, first try to give questions pipe contest and those who Period questions contact to we put their videos back them and try to read...
Minimum Number of Frogs Croaking
minimum-number-of-frogs-croaking
You are given the string `croakOfFrogs`, which represents a combination of the string `"croak "` from different frogs, that is, multiple frogs can croak at the same time, so multiple `"croak "` are mixed. _Return the minimum number of_ different _frogs to finish all the croaks in the given string._ A valid `"croak "`...
null
null
Medium
null
1,646
hey everybody this is larry this is me going with q1 of the recent eco weekly contest 214. this actually ended up being the most uh well the one that i made the most mistakes with during this contest get maximum and generate it away so basically you have this generated array and i think it's just really hard like i nee...
Get Maximum in Generated Array
kth-missing-positive-number
You are given an integer `n`. A **0-indexed** integer array `nums` of length `n + 1` is generated in the following way: * `nums[0] = 0` * `nums[1] = 1` * `nums[2 * i] = nums[i]` when `2 <= 2 * i <= n` * `nums[2 * i + 1] = nums[i] + nums[i + 1]` when `2 <= 2 * i + 1 <= n` Return _the **maximum** integer in the...
Keep track of how many positive numbers are missing as you scan the array.
Array,Binary Search
Easy
2305
142
hello everyone welcome or welcome back to my channel so today we are going to discuss another problem but before going forward if you have not liked the video please like it subscribe to my channel so that you get notified whenever i post a new video so without any further ado let's get started so the problem is linked...
Linked List Cycle II
linked-list-cycle-ii
Given the `head` of a linked list, return _the node where the cycle begins. If there is no cycle, return_ `null`. 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 ta...
null
Hash Table,Linked List,Two Pointers
Medium
141,287
745
hey what's up guys this is chung here again so this time uh today's daily challenge problem uh number 745 prefix and suffix search okay so you asked you're asked to design a special dictionary right which has like some words and allow you to search the words in it by both a freak fake a prefix and a suffix all right so...
Prefix and Suffix Search
find-smallest-letter-greater-than-target
Design a special dictionary that searches the words in it by a prefix and a suffix. Implement the `WordFilter` class: * `WordFilter(string[] words)` Initializes the object with the `words` in the dictionary. * `f(string pref, string suff)` Returns _the index of the word in the dictionary,_ which has the prefix `p...
Try to find whether each of 26 next letters are in the given string array.
Array,Binary Search
Easy
2269
1,835
hello everyone let's take a look at this problem find xor sum of all pure speed wise n okay so it's the last question in the weekly context although it's the last question uh it's not that hard this is a problem so um like if you haven't read this problem you can take some time to create it basically unfortunately impl...
Find XOR Sum of All Pairs Bitwise AND
decode-xored-permutation
The **XOR sum** of a list is the bitwise `XOR` of all its elements. If the list only contains one element, then its **XOR sum** will be equal to this element. * For example, the **XOR sum** of `[1,2,3,4]` is equal to `1 XOR 2 XOR 3 XOR 4 = 4`, and the **XOR sum** of `[3]` is equal to `3`. You are given two **0-inde...
Compute the XOR of the numbers between 1 and n, and think about how it can be used. Let it be x. Think why n is odd. perm[0] = x XOR encoded[1] XOR encoded[3] XOR encoded[5] ... perm[i] = perm[i-1] XOR encoded[i-1]
Array,Bit Manipulation
Medium
null
1,425
Hello everyone welcome to my channel Quote Story with Mike So today we are going to do video number 71 of our Dynamic Programming playlist. Okay and please make sure that you also follow my DP Concept and Questions playlist if you want to learn from core to basic. If you want to understand DP, then it is okay, the thin...
Constrained Subsequence Sum
weather-type-in-each-country
Given an integer array `nums` and an integer `k`, return the maximum sum of a **non-empty** subsequence of that array such that for every two **consecutive** integers in the subsequence, `nums[i]` and `nums[j]`, where `i < j`, the condition `j - i <= k` is satisfied. A _subsequence_ of an array is obtained by deleting...
null
Database
Easy
null
52
here's me 52 and Queens to the N Queens puzzle is the problem of placing and Queens on it and by and chess boys I've done no two queens attack each other coming in that your end we turned a number of distinct solutions to the end Queen puzzle oh there's huh this is one of those things where you do backpacking and or ba...
N-Queens II
n-queens-ii
The **n-queens** puzzle is the problem of placing `n` queens on an `n x n` chessboard such that no two queens attack each other. Given an integer `n`, return _the number of distinct solutions to the **n-queens puzzle**_. **Example 1:** **Input:** n = 4 **Output:** 2 **Explanation:** There are two distinct solutions ...
null
Backtracking
Hard
51
91
hey guys in today's video we're going to look at a lead code problem and the problem's name is decode ways so we are given a string is containing only digits we have to return the number of ways to decode it so to decode it we're going to use the letters in the alphabet to the digit mapping so a is 1 B is 2 through Z i...
Decode Ways
decode-ways
A message containing letters from `A-Z` can be **encoded** into numbers using the following mapping: 'A' -> "1 " 'B' -> "2 " ... 'Z' -> "26 " To **decode** an encoded message, all the digits must be grouped then mapped back into letters using the reverse of the mapping above (there may be multiple ways). For examp...
null
String,Dynamic Programming
Medium
639,2091
1,909
foreign so the problem is given that we need to make an array strictly increasing so we have given a zero index integer array and it will return true if the array is strictly increasing otherwise it will return false now they have also given one condition that we can remove exactly one element also to make it strictly ...
Remove One Element to Make the Array Strictly Increasing
buildings-with-an-ocean-view
Given a **0-indexed** integer array `nums`, return `true` _if it can be made **strictly increasing** after removing **exactly one** element, or_ `false` _otherwise. If the array is already strictly increasing, return_ `true`. The array `nums` is **strictly increasing** if `nums[i - 1] < nums[i]` for each index `(1 <= ...
You can traverse the buildings from the nearest to the ocean to the furthest. Keep with you the maximum to the right while traversing to determine if you can see the ocean or not.
Array,Stack,Monotonic Stack
Medium
1305
1,670
Hello Hi Everyone Welcome To My Channel It's All The Problem Design Front Middle And Back Why Soave Design Accurate Support And Cooperation In Front And Middle And Take Off The Give Some Wasted In This Class Front Neck Back Why This Constructor Festival Why Image Push Front Floral Middle And Pushed Back Soviet Russia P...
Design Front Middle Back Queue
patients-with-a-condition
Design a queue that supports `push` and `pop` operations in the front, middle, and back. Implement the `FrontMiddleBack` class: * `FrontMiddleBack()` Initializes the queue. * `void pushFront(int val)` Adds `val` to the **front** of the queue. * `void pushMiddle(int val)` Adds `val` to the **middle** of the queu...
null
Database
Easy
null
692
hi friends welcome back today we are going to solve lean code problem 471 top k frequent words so this is a medium complexity problem um so uh i often create lead code and lean code uh coding solution videos as well as java j2e related helpful uh videos for helping the uh interviews uh so you know please check out my p...
Top K Frequent Words
top-k-frequent-words
Given an array of strings `words` and an integer `k`, return _the_ `k` _most frequent strings_. Return the answer **sorted** by **the frequency** from highest to lowest. Sort the words with the same frequency by their **lexicographical order**. **Example 1:** **Input:** words = \[ "i ", "love ", "leetcode ", "i ", "...
null
Hash Table,String,Trie,Sorting,Heap (Priority Queue),Bucket Sort,Counting
Medium
347,1014,1919
87
oh you guys mess you daily table problem ASCII code can be straight given the string of one email isn't it a binary by partitioning it to two nonempty substance because if you know edge one possibility to the addition of last month so then they are we will enter in the creek bi-weekly now yeah they will the creek bi-we...
Scramble String
scramble-string
We can scramble a string s to get a string t using the following algorithm: 1. If the length of the string is 1, stop. 2. If the length of the string is > 1, do the following: * Split the string into two non-empty substrings at a random index, i.e., if the string is `s`, divide it to `x` and `y` where `s = x +...
null
String,Dynamic Programming
Hard
null
118
good afternoon friends this is hes from python Academy so today I will back with some another problem statement which is based on Python Programming okay so here is the first problem statement from lead code so this is a pascal triangle so we have to write a code where we have to print the Pascal triangle and in Pascal...
Pascal's Triangle
pascals-triangle
Given an integer `numRows`, return the first numRows of **Pascal's triangle**. In **Pascal's triangle**, each number is the sum of the two numbers directly above it as shown: **Example 1:** **Input:** numRows = 5 **Output:** \[\[1\],\[1,1\],\[1,2,1\],\[1,3,3,1\],\[1,4,6,4,1\]\] **Example 2:** **Input:** numRows = ...
null
Array,Dynamic Programming
Easy
119
937
Loot hello welcome to my channel also appoint Russian life is the problem the problems are seen from different energy lock subscribe in which of the first number on The link for detail view hai vivarvar aur digital de to absolut hadith 220 saaf lock pattern lock and digital of its Guaranteed Money Playlist One Word For...
Reorder Data in Log Files
online-stock-span
You are given an array of `logs`. Each log is a space-delimited string of words, where the first word is the **identifier**. There are two types of logs: * **Letter-logs**: All words (except the identifier) consist of lowercase English letters. * **Digit-logs**: All words (except the identifier) consist of digits...
null
Stack,Design,Monotonic Stack,Data Stream
Medium
739
1,470
hello friends welcome to coding interface channel hope you are doing great if you haven't subscribed to the channel yet please go ahead and subscribe I have created a bunch of playlists to cover various categories of the problem such as dynamic programming BFS DFS and also there are several playlists to cover basic dat...
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