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
946
hello hi everyone welcome to my channel its all the problem valid sequence is given to sequences post end for which distic feel returns through this end only used is cold have been the result of sequence after cost and mod on lamp stand for example 1ghz sequences 12345 end Points Pe Vo 500 What Will Happen Will Push Va...
Validate Stack Sequences
smallest-range-ii
Given two integer arrays `pushed` and `popped` each with distinct values, return `true` _if this could have been the result of a sequence of push and pop operations on an initially empty stack, or_ `false` _otherwise._ **Example 1:** **Input:** pushed = \[1,2,3,4,5\], popped = \[4,5,3,2,1\] **Output:** true **Explana...
null
Array,Math,Greedy,Sorting
Medium
null
201
yo what is up youtube today i'm going to be going over bitwise and of numbers range it's a medium problem on leak code i just started a slack channel where i post daily legal problems that i solve and eventually post videos of i'm not going to be posting easy problems anymore or posting videos to them they're just too ...
Bitwise AND of Numbers Range
bitwise-and-of-numbers-range
Given two integers `left` and `right` that represent the range `[left, right]`, return _the bitwise AND of all numbers in this range, inclusive_. **Example 1:** **Input:** left = 5, right = 7 **Output:** 4 **Example 2:** **Input:** left = 0, right = 0 **Output:** 0 **Example 3:** **Input:** left = 1, right = 2147...
null
Bit Manipulation
Medium
null
188
hey what's up guys this is john here again so uh actually today i also want to briefly talk about today's daily challenge problem uh which is number 100 188 best time to buy and sell stock number four you know i think this is a great problem you know this is like basically the last one this is the last one probably not...
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
53
welcome to leak codes blind curate 75 where I'll be solving the top 75 legal questions this question is called maximum sub-array and it's a classic one you sub-array and it's a classic one you sub-array and it's a classic one you definitely need to know here's the question given an energy rating nums find the contiguou...
Maximum Subarray
maximum-subarray
Given an integer array `nums`, find the subarray with the largest sum, and return _its sum_. **Example 1:** **Input:** nums = \[-2,1,-3,4,-1,2,1,-5,4\] **Output:** 6 **Explanation:** The subarray \[4,-1,2,1\] has the largest sum 6. **Example 2:** **Input:** nums = \[1\] **Output:** 1 **Explanation:** The subarray \...
null
Array,Divide and Conquer,Dynamic Programming
Easy
121,152,697,1020,1849,1893
1,962
Hello hi friends welcome back today we are going to solid co problem 1962 reduced to minimize the total so let's go through the description yagya 101 text interior files fear files for a representative number and stone singer of oil and interior you should apply the calling operation In Delhi Times Juice Benefits Of It...
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
1,756
Hello friends welcome back to my Channel today we're going to do a Leal problem together I've been doing some Leal problems recently just uh for the fin it um lead code 1756 design most recently used Q This is taged as the medium problem so the idea is that we want to design a queue like data structure that moves the m...
Design Most Recently Used Queue
minimum-deletions-to-make-string-balanced
Design a queue-like data structure that moves the most recently used element to the end of the queue. Implement the `MRUQueue` class: * `MRUQueue(int n)` constructs the `MRUQueue` with `n` elements: `[1,2,3,...,n]`. * `int fetch(int k)` moves the `kth` element **(1-indexed)** to the end of the queue and returns i...
You need to find for every index the number of Bs before it and the number of A's after it You can speed up the finding of A's and B's in suffix and prefix using preprocessing
String,Dynamic Programming,Stack
Medium
2243
503
my channel so in this video there to go the first goal of course is to solve this problem and do some live coding here and the second goal is to see how you should behave in a recording interview so before we start the real content for today i would really appreciate that if you can help subscribe this channel because ...
Next Greater Element II
next-greater-element-ii
Given a circular integer array `nums` (i.e., the next element of `nums[nums.length - 1]` is `nums[0]`), return _the **next greater number** for every element in_ `nums`. The **next greater number** of a number `x` is the first greater number to its traversing-order next in the array, which means you could search circu...
null
Array,Stack,Monotonic Stack
Medium
496,556
345
ladies and gentlemen welcome to today's lead code daily number 345 reverse wealth of a string we know that when we are reversing a list we find the left Mouse one and the right motor one and we switch their values secondly we'll find the one next to the leftmost and the second rightmost and we switch their values and t...
Reverse Vowels of a String
reverse-vowels-of-a-string
Given a string `s`, reverse only all the vowels in the string and return it. The vowels are `'a'`, `'e'`, `'i'`, `'o'`, and `'u'`, and they can appear in both lower and upper cases, more than once. **Example 1:** **Input:** s = "hello" **Output:** "holle" **Example 2:** **Input:** s = "leetcode" **Output:** "leotc...
null
Two Pointers,String
Easy
344,1089
376
so hello everyone today i am going to discuss the daily lead code practice challenge which is the wiggle subsequence it is the 376th problem in the lead code so a wiggle sequence is a sequence where the differences between successive numbers strictly alternate between positive and negative and the first difference if o...
Wiggle Subsequence
wiggle-subsequence
A **wiggle sequence** is a sequence where the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either positive or negative. A sequence with one element and a sequence with two non-equal elements are trivially wiggle sequences. * For ...
null
Array,Dynamic Programming,Greedy
Medium
2271
729
Loot ke guys welcome and welcome back to my channel and this video we are going to solve mycalendar one such problems 2021 kya hai here we have given you a mic calendar class which has a function book function what do we have to do implement the nice book function Now what is this book function doing? Now this is doing...
My Calendar I
my-calendar-i
You are implementing a program to use as your calendar. We can add a new event if adding the event will not cause a **double booking**. A **double booking** happens when two events have some non-empty intersection (i.e., some moment is common to both events.). The event can be represented as a pair of integers `start...
Store the events as a sorted list of intervals. If none of the events conflict, then the new event can be added.
Design,Segment Tree,Ordered Set
Medium
731,732
729
hello everyone welcome to learn about in this video we'll discuss about today's little problem that is my calendar one this is a medium level problem and we understand what this question is asking us to do and how we easily we can think of finding a solution to questions like this okay so first of all the question says...
My Calendar I
my-calendar-i
You are implementing a program to use as your calendar. We can add a new event if adding the event will not cause a **double booking**. A **double booking** happens when two events have some non-empty intersection (i.e., some moment is common to both events.). The event can be represented as a pair of integers `start...
Store the events as a sorted list of intervals. If none of the events conflict, then the new event can be added.
Design,Segment Tree,Ordered Set
Medium
731,732
60
Hua Hai Hello Everyone Welcome Back To Back Or Man To Day Problems Permission Sequence So In This Problem Will Try To Understand Problem Description And Will Provide You Hello Everyone Welcome Back To The Government Today This Problem Is Permit Action Sequence In This Problem Will Tried To Explain Problem And Will Draw...
Permutation Sequence
permutation-sequence
The set `[1, 2, 3, ..., n]` contains a total of `n!` unique permutations. By listing and labeling all of the permutations in order, we get the following sequence for `n = 3`: 1. `"123 "` 2. `"132 "` 3. `"213 "` 4. `"231 "` 5. `"312 "` 6. `"321 "` Given `n` and `k`, return the `kth` permutation sequence. **Exa...
null
Math,Recursion
Hard
31,46
1,834
Right meaning what are we doing today is daily need for problem single thread CPU let's start d problem basically you have bin given an 2D vector you can say on r of a where are any particular elements you no take out d vector from this you earn four Dot represents something like this a particular task date is starting...
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
1,953
hey everybody this is larry this is me going with q2 of the weekly contest 252 maximum number of weeks for which you can work hit the like button hit the subscribe button join me on discord especially if you like these contests i me and so a lot of uh smart people usually join the discord to kind of talk about the cont...
Maximum Number of Weeks for Which You Can Work
finding-mk-average
There are `n` projects numbered from `0` to `n - 1`. You are given an integer array `milestones` where each `milestones[i]` denotes the number of milestones the `ith` project has. You can work on the projects following these two rules: * Every week, you will finish **exactly one** milestone of **one** project. You ...
At each query, try to save and update the sum of the elements needed to calculate MKAverage. You can use BSTs for fast insertion and deletion of the elements.
Design,Queue,Heap (Priority Queue),Ordered Set
Hard
295,789,2207
92
hi guys welcome to tech geek so today we are back with daily lead code channels problem that's reverse linked list2 so this problem is elite code median level question and it's a record medium 92 now you guys have gone through the question that says reversing a linked list so it's kind of a modification to this where y...
Reverse Linked List II
reverse-linked-list-ii
Given the `head` of a singly linked list and two integers `left` and `right` where `left <= right`, reverse the nodes of the list from position `left` to position `right`, and return _the reversed list_. **Example 1:** **Input:** head = \[1,2,3,4,5\], left = 2, right = 4 **Output:** \[1,4,3,2,5\] **Example 2:** **I...
null
Linked List
Medium
206
341
hey everyone this is side hope you're doing good so let's start with the question so the question is flatten nested list iterator so you are given a nested list of integer nested list each element is either an integer or a list okay so there is a nested list class that is given to you and in that so it's a interface so...
Flatten Nested List Iterator
flatten-nested-list-iterator
You are given a nested list of integers `nestedList`. Each element is either an integer or a list whose elements may also be integers or other lists. Implement an iterator to flatten it. Implement the `NestedIterator` class: * `NestedIterator(List nestedList)` Initializes the iterator with the nested list `nestedLi...
null
Stack,Tree,Depth-First Search,Design,Queue,Iterator
Medium
251,281,385,565
90
hi everyone welcome back to lead coding so in the last video we solved the question subsets if you haven't watched that video make sure to watch it now we are moving to another problem that is subsets 2. now in this problem there is just a slight difference we are given duplicates in the previous problem we were not gi...
Subsets II
subsets-ii
Given an integer array `nums` that may contain duplicates, return _all possible_ _subsets_ _(the power set)_. The solution set **must not** contain duplicate subsets. Return the solution in **any order**. **Example 1:** **Input:** nums = \[1,2,2\] **Output:** \[\[\],\[1\],\[1,2\],\[1,2,2\],\[2\],\[2,2\]\] **Example...
null
Array,Backtracking,Bit Manipulation
Medium
78,2109
338
Hello Hi Guys Welcome To Algorithm Smart Easy Will Go Through 3028 Problem Middling Challenge Give No Negative Interior Number No For Every Number 102 Calculate Number Of Representation And Toys Example Of Representation Of Numbers From 200 To Hai Here Multiple Ways You Can Solve This Problem Will Go Through each of th...
Counting Bits
counting-bits
Given an integer `n`, return _an array_ `ans` _of length_ `n + 1` _such that for each_ `i` (`0 <= i <= n`)_,_ `ans[i]` _is the **number of**_ `1`_**'s** in the binary representation of_ `i`. **Example 1:** **Input:** n = 2 **Output:** \[0,1,1\] **Explanation:** 0 --> 0 1 --> 1 2 --> 10 **Example 2:** **Input:** n =...
You should make use of what you have produced already. Divide the numbers in ranges like [2-3], [4-7], [8-15] and so on. And try to generate new range from previous. Or does the odd/even status of the number help you in calculating the number of 1s?
Dynamic Programming,Bit Manipulation
Easy
191
1,620
A Hello Everyone Welcome To Record Programming Roaming Open According To Police Problems From The Relationship Between Promise Day 6 Minutes Less Quantity Lucknow 209 Most Used And You Will Also Be Given Credit Meeting Comet Person Mission Incomplete 500 1000 Death Tower This Controversy December Edison Katori Notice M...
Coordinate With Maximum Network Quality
check-if-array-pairs-are-divisible-by-k
You are given an array of network towers `towers`, where `towers[i] = [xi, yi, qi]` denotes the `ith` network tower with location `(xi, yi)` and quality factor `qi`. All the coordinates are **integral coordinates** on the X-Y plane, and the distance between the two coordinates is the **Euclidean distance**. You are al...
Keep an array of the frequencies of ((x % k) + k) % k for each x in arr. for each i in [0, k - 1] we need to check if freq[k] == freq[k - i] Take care of the case when i == k - i and when i == 0
Array,Hash Table,Counting
Medium
2301
449
Sohe gas is 70 third day today serial is in dc release binary search history so let's move on to that question and before that let me tell you one thing that there is also a question called serial agent dc release binary search tree on let code. So this will be done automatically, meaning binary, it is a type of binary...
Serialize and Deserialize BST
serialize-and-deserialize-bst
Serialization is converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection link to be reconstructed later in the same or another computer environment. Design an algorithm to serialize and deserialize a **binary search t...
null
String,Tree,Depth-First Search,Breadth-First Search,Design,Binary Search Tree,Binary Tree
Medium
297,652,765
87
Hey everyone, today we will be given a string S which is given here as S1, okay you get a string, okay and we have to make it equal using the following algorithm, here we have been given some algorithm, okay first. So if the length of d string is one stop means here then they said if the length of the string becomes on...
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
700
Hello hello guys welcome back to tech to join this video will see how to search and key given in this poetry which is also known as best solar system code 15th june channel lotus no problem give way to find the se request to search for key three idiot Problem of Thursday Subscribe Now Latest Research From This Point To...
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
1,996
That today be loot number to complain problem you are play and director attend Bluetooth come attack I think so this problem is that China chapter's trick or and properties any festival about China that were attended qualification graduation half hour subscribe chief selector is Let us assume at this moment that we sub...
The Number of Weak Characters in the Game
number-of-ways-to-rearrange-sticks-with-k-sticks-visible
You are playing a game that contains multiple characters, and each of the characters has **two** main properties: **attack** and **defense**. You are given a 2D integer array `properties` where `properties[i] = [attacki, defensei]` represents the properties of the `ith` character in the game. A character is said to be...
Is there a way to build the solution from a base case? How many ways are there if we fix the position of one stick?
Math,Dynamic Programming,Combinatorics
Hard
null
521
Hey friends, so in this video we will talk about the longest uncommon sub-sequence longest uncommon sub-sequence longest uncommon sub-sequence one, so this is an easy level problem, so let's directly go to the screen and understand through and example, so suppose that we have a string, now what will be its sub sequence...
Longest Uncommon Subsequence I
longest-uncommon-subsequence-i
Given two strings `a` and `b`, return _the length of the **longest uncommon subsequence** between_ `a` _and_ `b`. If the longest uncommon subsequence does not exist, return `-1`. An **uncommon subsequence** between two strings is a string that is a **subsequence of one but not the other**. A **subsequence** of a stri...
null
String
Easy
522
44
Let's talk about the next coding challenge Doctor's wildcard matching is problem number four on liquid since it is also one of the most popular problems that frequently sets alarm of companies today so let's see how to solve this question and beauty questions about that all Aryan Vaidya now breaks down on pattern sprin...
Wildcard Matching
wildcard-matching
Given an input string (`s`) and a pattern (`p`), implement wildcard pattern matching with support for `'?'` and `'*'` where: * `'?'` Matches any single character. * `'*'` Matches any sequence of characters (including the empty sequence). The matching should cover the **entire** input string (not partial). **Exam...
null
String,Dynamic Programming,Greedy,Recursion
Hard
10
1,284
hi friends welcome back today we are going to solve lead code problem 1284 minimum number of lips to convert binary Matrix to zero Matrix this is one of those hard problems on lead code and you can see from last like dislike ratio that this is a very likable problem so in today's session we will go through this problem...
Minimum Number of Flips to Convert Binary Matrix to Zero Matrix
four-divisors
Given a `m x n` binary matrix `mat`. In one step, you can choose one cell and flip it and all the four neighbors of it if they exist (Flip is changing `1` to `0` and `0` to `1`). A pair of cells are called neighbors if they share one edge. Return the _minimum number of steps_ required to convert `mat` to a zero matrix...
Find the divisors of each element in the array. You only need to loop to the square root of a number to find its divisors.
Array,Math
Medium
null
1,630
hello everyone welcome to another video in this video we are going to look at another Aries medium level question although it is it says it is medium but it is really easy and we'll see how so let's jump into the question what it says and then we'll understand how we are going to solve this so basically I've written it...
Arithmetic Subarrays
count-odd-numbers-in-an-interval-range
A sequence of numbers is called **arithmetic** if it consists of at least two elements, and the difference between every two consecutive elements is the same. More formally, a sequence `s` is arithmetic if and only if `s[i+1] - s[i] == s[1] - s[0]` for all valid `i`. For example, these are **arithmetic** sequences: 1...
If the range (high - low + 1) is even, the number of even and odd numbers in this range will be the same. If the range (high - low + 1) is odd, the solution will depend on the parity of high and low.
Math
Easy
null
283
hi everyone in this video i will be covering the solution to lee code number 238 which is also called move zeros so let's begin by looking at the problem statement given an integer array nums we want to move all zeros to the end of it while maintaining the relative order of the non-zero elements the non-zero elements t...
Move Zeroes
move-zeroes
Given an integer array `nums`, move all `0`'s to the end of it while maintaining the relative order of the non-zero elements. **Note** that you must do this in-place without making a copy of the array. **Example 1:** **Input:** nums = \[0,1,0,3,12\] **Output:** \[1,3,12,0,0\] **Example 2:** **Input:** nums = \[0\]...
In-place means we should not be allocating any space for extra array. But we are allowed to modify the existing array. However, as a first step, try coming up with a solution that makes use of additional space. For this problem as well, first apply the idea discussed using an additional array and the in-place solution ...
Array,Two Pointers
Easy
27
1,823
hey everybody this is larry this is me going over q2 of the weekly contest 236 find the winner of the circular game so yeah so this one there are a couple of ways to do it um i think you can actually i don't know i did this in a very funky way but uh and that's why it took a little bit of a long time but i think you ca...
Find the Winner of the Circular Game
determine-if-string-halves-are-alike
There are `n` friends that are playing a game. The friends are sitting in a circle and are numbered from `1` to `n` in **clockwise order**. More formally, moving clockwise from the `ith` friend brings you to the `(i+1)th` friend for `1 <= i < n`, and moving clockwise from the `nth` friend brings you to the `1st` friend...
Create a function that checks if a character is a vowel, either uppercase or lowercase.
String,Counting
Easy
null
692
um hello so today we are going to do this problem which is part of lead code daily challenge um top K frequent words um so the problem says we get an array of strings words and we get an integer k and what we want to do is return the K most frequent strings so for example for this list words we have I occurring twice a...
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
1,921
challenge21 promotion eliminate maximum number of monster basically we have given a question in which we have playing a video game where we defending our city from n number of most monsters and there is distance with size n and distance I is donate to the initial distance in kilometer of the I monster from the city the...
Eliminate Maximum Number of Monsters
eliminate-maximum-number-of-monsters
You are playing a video game where you are defending your city from a group of `n` monsters. You are given a **0-indexed** integer array `dist` of size `n`, where `dist[i]` is the **initial distance** in kilometers of the `ith` monster from the city. The monsters walk toward the city at a **constant** speed. The speed...
null
null
Medium
null
383
hello everyone welcome back here is vamson and if you're new here hit that subscribe button for more coding Adventure so today we are cracking uh open the uh classic problem so uh can you construct a ransom note so this problem uh from L code is uh not just intriguing but also fantastic way to master hashmap so without...
Ransom Note
ransom-note
Given two strings `ransomNote` and `magazine`, return `true` _if_ `ransomNote` _can be constructed by using the letters from_ `magazine` _and_ `false` _otherwise_. Each letter in `magazine` can only be used once in `ransomNote`. **Example 1:** **Input:** ransomNote = "a", magazine = "b" **Output:** false **Example ...
null
Hash Table,String,Counting
Easy
691
1,840
hey what's up guys uh this is chung here so today uh it's called number 1840 maximum building height okay so you're given like uh um buildings in the cities labeled uh from one to end right then however there are some restrictions so when we build these buildings so first you know the building the first building must b...
Maximum Building Height
minimize-hamming-distance-after-swap-operations
You want to build `n` new buildings in a city. The new buildings will be built in a line and are labeled from `1` to `n`. However, there are city restrictions on the heights of the new buildings: * The height of each building must be a non-negative integer. * The height of the first building **must** be `0`. * ...
The source array can be imagined as a graph where each index is a node and each allowedSwaps[i] is an edge. Nodes within the same component can be freely swapped with each other. For each component, find the number of common elements. The elements that are not in common will contribute to the total Hamming distance.
Array,Depth-First Search,Union Find
Medium
1308
1,624
hello and welcome to another video in this video we're going to be working on largest substring between two equal characters and in the problem you're given a string s and you want to return the length of the longest substring between two equal characters excluding the two characters if there's no such substring is tur...
Largest Substring Between Two Equal Characters
clone-binary-tree-with-random-pointer
Given a string `s`, return _the length of the longest substring between two equal characters, excluding the two characters._ If there is no such substring return `-1`. A **substring** is a contiguous sequence of characters within a string. **Example 1:** **Input:** s = "aa " **Output:** 0 **Explanation:** The optim...
Traverse the tree, keep a hashtable with you and create a nodecopy for each node in the tree. Start traversing the original tree again and connect the left, right and random pointers in the cloned tree the same way as the original tree with the help of the hashtable.
Hash Table,Tree,Depth-First Search,Breadth-First Search,Binary Tree
Medium
133,138,1634
1,802
hello everyone welcome back here is Ben Hampton and today we will tackle another daily challenge from this code maximum value at a given index in a bounded RI and let's dive in the problem asks us to find the maximum value at a given index while also adhering to some specific condition the goal is to construct an array...
Maximum Value at a Given Index in a Bounded Array
number-of-students-unable-to-eat-lunch
You are given three positive integers: `n`, `index`, and `maxSum`. You want to construct an array `nums` (**0-indexed**) that satisfies the following conditions: * `nums.length == n` * `nums[i]` is a **positive** integer where `0 <= i < n`. * `abs(nums[i] - nums[i+1]) <= 1` where `0 <= i < n-1`. * The sum of a...
Simulate the given in the statement Calculate those who will eat instead of those who will not.
Array,Stack,Queue,Simulation
Easy
2195
783
Hi gas welcome and welcome back to my channel so today our problem is minimum distance between BST notes so let us see what has been given to us in this problem statement, here what has been given to you, root node has been given without one. OK, so what we have to do is to return the minimum difference between the val...
Minimum Distance Between BST Nodes
search-in-a-binary-search-tree
Given the `root` of a Binary Search Tree (BST), return _the minimum difference between the values of any two different nodes in the tree_. **Example 1:** **Input:** root = \[4,2,6,1,3\] **Output:** 1 **Example 2:** **Input:** root = \[1,0,48,null,null,12,49\] **Output:** 1 **Constraints:** * The number of nodes...
null
Tree,Binary Search Tree,Binary Tree
Easy
270,784
974
hello everyone welcome to question coder so in this video we will see question 974 that is sub array sums divisible by k so this question is a really popular question and it can be asked in an interview for coding interviews for like big tech giants like google amazon facebook so let's see so it's a medium question and...
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
454
Ajay has been robbed, so today we are with aapke hain kaun question and the name of the question is for sometime list court question number four, emphasis is 1 medium sized question. Well, if I use it regularly then maybe it is not at the top but Chief, you will learn a lot of things in this question, if you understand...
4Sum II
4sum-ii
Given four integer arrays `nums1`, `nums2`, `nums3`, and `nums4` all of length `n`, return the number of tuples `(i, j, k, l)` such that: * `0 <= i, j, k, l < n` * `nums1[i] + nums2[j] + nums3[k] + nums4[l] == 0` **Example 1:** **Input:** nums1 = \[1,2\], nums2 = \[-2,-1\], nums3 = \[-1,2\], nums4 = \[0,2\] **Ou...
null
Array,Hash Table
Medium
18
427
hi everyone in this video we are going to solve a new problem the problem name is construct quartery and the problem number is four to seven fine first of all we are going to clearly understand what this poem says after that we are going to move to the logic part and after that we are going to implement our logic is fi...
Construct Quad Tree
construct-quad-tree
Given a `n * n` matrix `grid` of `0's` and `1's` only. We want to represent `grid` with a Quad-Tree. Return _the root of the Quad-Tree representing_ `grid`. A Quad-Tree is a tree data structure in which each internal node has exactly four children. Besides, each node has two attributes: * `val`: True if the node r...
null
null
Medium
null
1,975
Loot Hello and Welcome Back to Way Tunnel Vision English Video Scientist Now Half Hour 50 Numbers Maximum Matrix 125 subscribe The Channel Please Click on the link for detail view Quantum In Sold It's Very Difficult To Approve Like Subscribe 232 Miles 302 201 9 4 Madam Positive And Which Can Address Inside - - 5 Possib...
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
1,722
hey what's up guys this is june so this time uh 1722 minimize hamming distance after swap operations um so you're given like two integer arrays source and target and they have the same length and you're also given like an array of a lot swaps so the swaps has like this two indices which means that you can swap those tw...
Minimize Hamming Distance After Swap Operations
throne-inheritance
You are given two integer arrays, `source` and `target`, both of length `n`. You are also given an array `allowedSwaps` where each `allowedSwaps[i] = [ai, bi]` indicates that you are allowed to swap the elements at index `ai` and index `bi` **(0-indexed)** of array `source`. Note that you can swap elements at a specifi...
Create a tree structure of the family. Without deaths, the order of inheritance is simply a pre-order traversal of the tree. Mark the dead family members tree nodes and don't include them in the final order.
Hash Table,Tree,Depth-First Search,Design
Medium
2104
796
Hey gas welcome back tu de video so we are going to discuss in this video crying string is fine and is a very popular question and is a very good question and I would say it is not easy but it is medium level of question it is fine and Basically we will see how we will do this and friend you will see all over YouTube t...
Rotate String
reaching-points
Given two strings `s` and `goal`, return `true` _if and only if_ `s` _can become_ `goal` _after some number of **shifts** on_ `s`. A **shift** on `s` consists of moving the leftmost character of `s` to the rightmost position. * For example, if `s = "abcde "`, then it will be `"bcdea "` after one shift. **Example 1...
null
Math
Hard
null
1,961
all right so let's talk about the check if string is a prefix of array so give me the string s and then string array and basically you want to and is equal to the sh so basically you can create stream Builder and then append every single stream and just make sure that this the pattern the order is a prefix of the shess...
Check If String Is a Prefix of Array
maximum-ice-cream-bars
Given a string `s` and an array of strings `words`, determine whether `s` is a **prefix string** of `words`. A string `s` is a **prefix string** of `words` if `s` can be made by concatenating the first `k` strings in `words` for some **positive** `k` no larger than `words.length`. Return `true` _if_ `s` _is a **prefi...
It is always optimal to buy the least expensive ice cream bar first. Sort the prices so that the cheapest ice cream bar comes first.
Array,Greedy,Sorting
Medium
null
588
okay so a lead code practice question uh in this video there are two goals the first goal is to see how to solve this problem so you're going to find the solution and do some coding work and the second goal is to see how we should behave in a real interview so let's get started so remember in our interview the first st...
Design In-Memory File System
design-in-memory-file-system
Design a data structure that simulates an in-memory file system. Implement the FileSystem class: * `FileSystem()` Initializes the object of the system. * `List ls(String path)` * If `path` is a file path, returns a list that only contains this file's name. * If `path` is a directory path, returns...
null
Hash Table,String,Design,Trie
Hard
146,460,635
1,078
all right ten seven area currents just after a big wham given words first and second consider occurrence oh that's a greedy solution I mean that I would be surprised maybe that's why is easy if I try to do too much trying to be right but still greedy you shouldn't or you can't do big I mean that would make the difficul...
Occurrences After Bigram
remove-outermost-parentheses
Given two strings `first` and `second`, consider occurrences in some text of the form `"first second third "`, where `second` comes immediately after `first`, and `third` comes immediately after `second`. Return _an array of all the words_ `third` _for each occurrence of_ `"first second third "`. **Example 1:** **In...
Can you find the primitive decomposition? The number of ( and ) characters must be equal.
String,Stack
Easy
null
84
hey guys how's everything going I'm Jay sir this has been a long time since I last uploaded my videos there's a huge yeah every door the whole world is about the coronavirus and hope you're doing well please stay at home and stay healthy hope this coronavirus will be gone soon and yeah this is a very good time for a sy...
Largest Rectangle in Histogram
largest-rectangle-in-histogram
Given an array of integers `heights` representing the histogram's bar height where the width of each bar is `1`, return _the area of the largest rectangle in the histogram_. **Example 1:** **Input:** heights = \[2,1,5,6,2,3\] **Output:** 10 **Explanation:** The above is a histogram where width of each bar is 1. The l...
null
Array,Stack,Monotonic Stack
Hard
85,1918
68
given an array of strings words and a width Max width format the text such that each line is exactly Max with characters and is fully left and right Justified you should pack your words in a greedy approach that is pack as many words as you can in each line add Extra Spaces when necessary so that each line has exactly ...
Text Justification
text-justification
Given an array of strings `words` and a width `maxWidth`, format the text such that each line has exactly `maxWidth` characters and is fully (left and right) justified. You should pack your words in a greedy approach; that is, pack as many words as you can in each line. Pad extra spaces `' '` when necessary so that ea...
null
Array,String,Simulation
Hard
1714,2260
1,360
yeahyeah Hi everyone, I'm a programmer. Today I will introduce to you the problem of the number of days between two dates in the year. We will have the details of the problem as follows. Write a question. The program to calculate the number of days between two dates in the year according to this is the flash format Thu...
Number of Days Between Two Dates
maximum-length-of-a-concatenated-string-with-unique-characters
Write a program to count the number of days between two dates. The two dates are given as strings, their format is `YYYY-MM-DD` as shown in the examples. **Example 1:** **Input:** date1 = "2019-06-29", date2 = "2019-06-30" **Output:** 1 **Example 2:** **Input:** date1 = "2020-01-15", date2 = "2019-12-31" **Output:...
You can try all combinations and keep mask of characters you have. You can use DP.
Array,String,Backtracking,Bit Manipulation
Medium
null
117
hi everyone so today we are here with a new problem this is a lead code uh medium problem which is populating next right pointer in each node two so the way we are going to solve this problem is first we understand the approach sorry the problem and then we see two approach to solve it stay tuned and let's see what is ...
Populating Next Right Pointers in Each Node II
populating-next-right-pointers-in-each-node-ii
Given a binary tree struct Node { int val; Node \*left; Node \*right; Node \*next; } Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set to `NULL`. Initially, all next pointers are set to `NULL`. **Example 1:** **Input:** root = \[1,2,3...
null
Linked List,Tree,Depth-First Search,Breadth-First Search,Binary Tree
Medium
116
242
even to strengths s1 and s2 write a function to determine if s2 is an anagram of s1 so what is anagram two strings are said to be ni grams of each other if it contains the same characters only the order of character in both these string is different for example if you see the example 1 s1 and s2 both contains the same ...
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
1,356
hey guys today we're going to sell leak on number 1356 sort integers by the number of one bits so we're given an array r and we have to sort it by the number of one digits in their binary representation and if they have the same amount of ones in their binary presentation then we need to sort them in ascending order an...
Sort Integers by The Number of 1 Bits
minimum-number-of-moves-to-make-palindrome
You are given an integer array `arr`. Sort the integers in the array in ascending order by the number of `1`'s in their binary representation and in case of two or more integers have the same number of `1`'s you have to sort them in ascending order. Return _the array after sorting it_. **Example 1:** **Input:** arr ...
Consider a greedy strategy. Let’s start by making the leftmost and rightmost characters match with some number of swaps. If we figure out how to do that using the minimum number of swaps, then we can delete the leftmost and rightmost characters and solve the problem recursively.
Two Pointers,String,Greedy,Binary Indexed Tree
Hard
1437
1,568
hello earthlings welcome yet again to see predict in this video we are going to see the third problem from today's lead code weekly contest 204 and it is called minimum number of days to disconnect island yeah we have a we have been given a grid we have one the one uh if we have a one in particular one in any particula...
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
103
hey everyone welcome to Tech white in this video we are going to solve problem number 103 binary treat zigzag level order traversal so given the root of a binary tree we need to return the zigzag level or the traversal of its notes values so we just need to print the nodes in alternating directions at each level now we...
Binary Tree Zigzag Level Order Traversal
binary-tree-zigzag-level-order-traversal
Given the `root` of a binary tree, return _the zigzag level order traversal of its nodes' values_. (i.e., from left to right, then right to left for the next level and alternate between). **Example 1:** **Input:** root = \[3,9,20,null,null,15,7\] **Output:** \[\[3\],\[20,9\],\[15,7\]\] **Example 2:** **Input:** roo...
null
Tree,Breadth-First Search,Binary Tree
Medium
102
654
going to see the LOD question 654 that is the maximum binary Tre we are given the integer LS with no duplicates a maximum binary tree can be built recursively from nums using the following algorithm create a node whose value is in the maximum value in nums is a vector given to us in which all the elements are stored we...
Maximum Binary Tree
maximum-binary-tree
You are given an integer array `nums` with no duplicates. A **maximum binary tree** can be built recursively from `nums` using the following algorithm: 1. Create a root node whose value is the maximum value in `nums`. 2. Recursively build the left subtree on the **subarray prefix** to the **left** of the maximum val...
null
Array,Divide and Conquer,Stack,Tree,Monotonic Stack,Binary Tree
Medium
1040
1,042
all right let's talk about the flower planting with no json so you're giving an ungarden label from one to n and then there's a red path so the path is going to be from x to y but the path is by direction or path so if you can go from x to y right you definitely can go from y to x all right so all the garden has more t...
Flower Planting With No Adjacent
minimum-cost-to-merge-stones
You have `n` gardens, labeled from `1` to `n`, and an array `paths` where `paths[i] = [xi, yi]` describes a bidirectional path between garden `xi` to garden `yi`. In each garden, you want to plant one of 4 types of flowers. All gardens have **at most 3** paths coming into or leaving it. Your task is to choose a flowe...
null
Array,Dynamic Programming
Hard
312,1126
1,710
hello everyone welcome to learn workflow in this video we will discuss about another liquid problem that is the maximum units on a truck we will understand what this question is exactly saying and how we can approach this particular question to solve okay so before starting this video uh if make sure to subscribe this ...
Maximum Units on a Truck
find-servers-that-handled-most-number-of-requests
You are assigned to put some amount of boxes onto **one truck**. You are given a 2D array `boxTypes`, where `boxTypes[i] = [numberOfBoxesi, numberOfUnitsPerBoxi]`: * `numberOfBoxesi` is the number of boxes of type `i`. * `numberOfUnitsPerBoxi` is the number of units in each box of the type `i`. You are also given...
To speed up the next available server search, keep track of the available servers in a sorted structure such as an ordered set. To determine if a server is available, keep track of the end times for each task in a heap and add the server to the available set once the soonest task ending time is less than or equal to th...
Array,Greedy,Heap (Priority Queue),Ordered Set
Hard
null
84
welcome to december's leco challenge today's problem is largest rectangle in histogram given n non-negative integers given n non-negative integers given n non-negative integers representing the histogram's bar height where the width of each bar is one find the area of the largest rectangle in the histogram here's some ...
Largest Rectangle in Histogram
largest-rectangle-in-histogram
Given an array of integers `heights` representing the histogram's bar height where the width of each bar is `1`, return _the area of the largest rectangle in the histogram_. **Example 1:** **Input:** heights = \[2,1,5,6,2,3\] **Output:** 10 **Explanation:** The above is a histogram where width of each bar is 1. The l...
null
Array,Stack,Monotonic Stack
Hard
85,1918
111
welcome to this video now we're going to solve a coding interview equation minimum depth of binary tree here's the problem statement given a binary tree find its minimum depth the minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node note that a leaf is a node wit...
Minimum Depth of Binary Tree
minimum-depth-of-binary-tree
Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. **Note:** A leaf is a node with no children. **Example 1:** **Input:** root = \[3,9,20,null,null,15,7\] **Output:** 2 **Example 2:** **Input:** root = \[2...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Easy
102,104
531
students will be discussing a lead code problem 531 a lonely pixel this is a medium problem so let's get into the problem so what it says given an MX and picture consisting of a black B and white W pixels it's done the number of black lonely pixel and a black lonely pixel is a character B that located at a specific loo...
Lonely Pixel I
lonely-pixel-i
Given an `m x n` `picture` consisting of black `'B'` and white `'W'` pixels, return _the number of **black** lonely pixels_. A black lonely pixel is a character `'B'` that located at a specific position where the same row and same column don't have **any other** black pixels. **Example 1:** **Input:** picture = \[\[...
null
Array,Hash Table,Matrix
Medium
533
252
welcome back to algojs today's question is leak code 252 meeting rooms so given an array of meeting time intervals where intervals I is equal to start I and I determine if a person could attend all meetings so here in the first example we have an output of false and the reason for that is our first interval start is ze...
Meeting Rooms
meeting-rooms
Given an array of meeting time `intervals` where `intervals[i] = [starti, endi]`, determine if a person could attend all meetings. **Example 1:** **Input:** intervals = \[\[0,30\],\[5,10\],\[15,20\]\] **Output:** false **Example 2:** **Input:** intervals = \[\[7,10\],\[2,4\]\] **Output:** true **Constraints:** * ...
null
Array,Sorting
Easy
56,253
1,765
hello welcome back let's try another lyrical problem 1765 map of highest peak so this is another BFS problem actually it is a multi-source BFS multi-source BFS multi-source BFS let me explain a little bit about the example and then go to the Whiteboard to explain my uploads for solving the problem after that I will go ...
Map of Highest Peak
merge-in-between-linked-lists
You are given an integer matrix `isWater` of size `m x n` that represents a map of **land** and **water** cells. * If `isWater[i][j] == 0`, cell `(i, j)` is a **land** cell. * If `isWater[i][j] == 1`, cell `(i, j)` is a **water** cell. You must assign each cell a height in a way that follows these rules: * The...
Check which edges need to be changed. Let the next node of the (a-1)th node of list1 be the 0-th node in list 2. Let the next node of the last node of list2 be the (b+1)-th node in list 1.
Linked List
Medium
null
1,897
hey everybody this is Larry this is day 30th of the legal day challenge only two more problems for the end of the year and today we get a easy one a problem to kind of rest the end of the year on I suppose we distribute characters to make all strings equal what does that mean uh okay so you given away of string words a...
Redistribute Characters to Make All Strings Equal
maximize-palindrome-length-from-subsequences
You are given an array of strings `words` (**0-indexed**). In one operation, pick two **distinct** indices `i` and `j`, where `words[i]` is a non-empty string, and move **any** character from `words[i]` to **any** position in `words[j]`. Return `true` _if you can make **every** string in_ `words` _**equal** using **a...
Let's ignore the non-empty subsequence constraint. We can concatenate the two strings and find the largest palindromic subsequence with dynamic programming. Iterate through every pair of characters word1[i] and word2[j], and see if some palindrome begins with word1[i] and ends with word2[j]. This ensures that the subse...
String,Dynamic Programming
Hard
516
81
Loot Guys Welcome Back to My Channel English Video We're Going to Solve Sachin Rotated Edit You Saw This Gives Statement Hair Dyes and Interior James Todd in Decreasing Order Not Necessarily with Distinct Values ​​Before Being Order Not Necessarily with Distinct Values ​​Before Being Order Not Necessarily with Distinct...
Search in Rotated Sorted Array II
search-in-rotated-sorted-array-ii
There is an integer array `nums` sorted in non-decreasing order (not necessarily with **distinct** values). Before being passed to your function, `nums` is **rotated** at an unknown pivot index `k` (`0 <= k < nums.length`) such that the resulting array is `[nums[k], nums[k+1], ..., nums[n-1], nums[0], nums[1], ..., nu...
null
Array,Binary Search
Medium
33
815
hello hi guys good morning welcome back to the new video sub Changi I hope that you guys are doing good just let me know uh in this video we're going to see the problem bus routs another lecture of our series now you will see that this has been asked most frequently by Uber Tik Tok and phone pay no matter it is the rec...
Bus Routes
champagne-tower
You are given an array `routes` representing bus routes where `routes[i]` is a bus route that the `ith` bus repeats forever. * For example, if `routes[0] = [1, 5, 7]`, this means that the `0th` bus travels in the sequence `1 -> 5 -> 7 -> 1 -> 5 -> 7 -> 1 -> ...` forever. You will start at the bus stop `source` (You...
null
Dynamic Programming
Medium
1385
88
hello everybody today we're going to go through lead code problem number 88 which is merge sorted array so this says you are given two integer arrays nums one and nums two sorted in non decreasing order or increasing order I like to call it and two integers M and N representing the number of elements in nums one and nu...
Merge Sorted Array
merge-sorted-array
You are given two integer arrays `nums1` and `nums2`, sorted in **non-decreasing order**, and two integers `m` and `n`, representing the number of elements in `nums1` and `nums2` respectively. **Merge** `nums1` and `nums2` into a single array sorted in **non-decreasing order**. The final sorted array should not be re...
You can easily solve this problem if you simply think about two elements at a time rather than two arrays. We know that each of the individual arrays is sorted. What we don't know is how they will intertwine. Can we take a local decision and arrive at an optimal solution? If you simply consider one element each at a ti...
Array,Two Pointers,Sorting
Easy
21,1019,1028
80
so Elite code has this top interview 150 questions list I have done the first three so let's continue and see if we can go through all of them within a few months all right I've recently started to Learn Python so I'll be putting python this is a medium problem it's so similar to this except that now we're keeping each...
Remove Duplicates from Sorted Array II
remove-duplicates-from-sorted-array-ii
Given an integer array `nums` sorted in **non-decreasing order**, remove some duplicates [**in-place**](https://en.wikipedia.org/wiki/In-place_algorithm) such that each unique element appears **at most twice**. The **relative order** of the elements should be kept the **same**. Since it is impossible to change the len...
null
Array,Two Pointers
Medium
26
374
Hello friends, in today's video we are going to discuss the list of problem, gas number, higher oil, what is the problem, Egypt, you are in such a situation, that is why I and you are playing a game, what should I do, I will do it on a number which Bansi should write and enter. Someone number one Now I will tell you Wh...
Guess Number Higher or Lower
guess-number-higher-or-lower
We are playing the Guess Game. The game is as follows: I pick a number from `1` to `n`. You have to guess which number I picked. Every time you guess wrong, I will tell you whether the number I picked is higher or lower than your guess. You call a pre-defined API `int guess(int num)`, which returns three possible re...
null
Binary Search,Interactive
Easy
278,375,658
206
ladies and gentlemen welcome to another elad code question today is question 206 reverse linked list given the head of a singly linked list reverse the list and return the Reversed list so this question can be solved by just using pointers and how we can do it is just iterate through the nodes and as we iterate through...
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
148
welcome to october's leco challenge today's problem is sort list given the head of a linked list we turn the list after sorting it can you sort the linked list in n log n time and o of one memory so the way i know to do that with sorting is generally quick sort but unfortunately we can't use quicksort with linked lists...
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
338
such that for each I that I is lesser than equal to 0 greater than equal to 0 and less than equal to n answer Alpha is the number of ones in the binary representation of I so the question what they have given is because they are given an integer called let's say three and you have to written an array answer of length i...
Counting Bits
counting-bits
Given an integer `n`, return _an array_ `ans` _of length_ `n + 1` _such that for each_ `i` (`0 <= i <= n`)_,_ `ans[i]` _is the **number of**_ `1`_**'s** in the binary representation of_ `i`. **Example 1:** **Input:** n = 2 **Output:** \[0,1,1\] **Explanation:** 0 --> 0 1 --> 1 2 --> 10 **Example 2:** **Input:** n =...
You should make use of what you have produced already. Divide the numbers in ranges like [2-3], [4-7], [8-15] and so on. And try to generate new range from previous. Or does the odd/even status of the number help you in calculating the number of 1s?
Dynamic Programming,Bit Manipulation
Easy
191
894
everyone welcome back and let's write some more neat code today so today let's solve the problem all possible full binary trees this is a pretty challenging problem for a medium because it's definitely different than a lot of tree questions you might have because it's definitely different than a lot of tree questions t...
All Possible Full Binary Trees
random-pick-with-blacklist
Given an integer `n`, return _a list of all possible **full binary trees** with_ `n` _nodes_. Each node of each tree in the answer must have `Node.val == 0`. Each element of the answer is the root node of one possible tree. You may return the final list of trees in **any order**. A **full binary tree** is a binary tr...
null
Hash Table,Math,Binary Search,Sorting,Randomized
Hard
398,912,2107
56
huh okay let's do this hey what's up guys knee right here I didn't groaning stuff on twitch and YouTube check the description for all my information you could support me on if you sub to me on Twitch patreon whatever even just liking and subscribing or discord or whatever is awesome so I am streaming again I did this o...
Merge Intervals
merge-intervals
Given an array of `intervals` where `intervals[i] = [starti, endi]`, merge all overlapping intervals, and return _an array of the non-overlapping intervals that cover all the intervals in the input_. **Example 1:** **Input:** intervals = \[\[1,3\],\[2,6\],\[8,10\],\[15,18\]\] **Output:** \[\[1,6\],\[8,10\],\[15,18\]\...
null
Array,Sorting
Medium
57,252,253,495,616,715,761,768,1028,2297,2319
212
in this problem we have to search for words in a 2d board and uh for example you are given a 2d word where each cell will have a character in it and it will be from small a to small g and you are also given a list of words so you have to find which of these words in the dictionary are present in this board so what we w...
Word Search II
word-search-ii
Given an `m x n` `board` of characters and a list of strings `words`, return _all words on the board_. Each word must be constructed from letters of sequentially adjacent cells, where **adjacent cells** are horizontally or vertically neighboring. The same letter cell may not be used more than once in a word. **Exampl...
You would need to optimize your backtracking to pass the larger test. Could you stop backtracking earlier? If the current candidate does not exist in all words' prefix, you could stop backtracking immediately. What kind of data structure could answer such query efficiently? Does a hash table work? Why or why not? How a...
Array,String,Backtracking,Trie,Matrix
Hard
79,1022,1433
862
hey Chum here so again today we're going to talk about this it's called problem eight six to shortest sub-array with some at least K shortest sub-array with some at least K shortest sub-array with some at least K this is my first heart problem video so I will try to explain this as clean I mean it alright it's clear as...
Shortest Subarray with Sum at Least K
find-and-replace-in-string
Given an integer array `nums` and an integer `k`, return _the length of the shortest non-empty **subarray** of_ `nums` _with a sum of at least_ `k`. If there is no such **subarray**, return `-1`. A **subarray** is a **contiguous** part of an array. **Example 1:** **Input:** nums = \[1\], k = 1 **Output:** 1 **Examp...
null
Array,String,Sorting
Medium
null
378
Hello friends welcome to my YouTube channel Tier-3 to Jhal Ajay, in today's video I have channel Tier-3 to Jhal Ajay, in today's video I have channel Tier-3 to Jhal Ajay, in today's video I have brought another question whose name is Cat Smallest Element in Sorted Matrix, so basically the question is of medium category...
Kth Smallest Element in a Sorted Matrix
kth-smallest-element-in-a-sorted-matrix
Given an `n x n` `matrix` where each of the rows and columns is sorted in ascending order, return _the_ `kth` _smallest element in the matrix_. Note that it is the `kth` smallest element **in the sorted order**, not the `kth` **distinct** element. You must find a solution with a memory complexity better than `O(n2)`....
null
Array,Binary Search,Sorting,Heap (Priority Queue),Matrix
Medium
373,668,719,802
1,510
The range has come back and we are being disturbed. One of the problems in the list is number 15. This is the problem of stone game. What is there in this? The total has given us an end stone and two free Delhi wholesale prices. What is to be done by these two, that we take something out of that injury. There has to be...
Stone Game IV
find-lucky-integer-in-an-array
Alice and Bob take turns playing a game, with Alice starting first. Initially, there are `n` stones in a pile. On each player's turn, that player makes a _move_ consisting of removing **any** non-zero **square number** of stones in the pile. Also, if a player cannot make a move, he/she loses the game. Given a positi...
Count the frequency of each integer in the array. Get all lucky numbers and return the largest of them.
Array,Hash Table,Counting
Easy
null
368
today we'll be going over largest divisible subset so this question is basically asking you to find the largest group of numbers in the provided input such that every number can meet this condition so the larger number mod the smallest number is equal to 0 so that means when you divide by this smaller number the remain...
Largest Divisible Subset
largest-divisible-subset
Given a set of **distinct** positive integers `nums`, return the largest subset `answer` such that every pair `(answer[i], answer[j])` of elements in this subset satisfies: * `answer[i] % answer[j] == 0`, or * `answer[j] % answer[i] == 0` If there are multiple solutions, return any of them. **Example 1:** **Inp...
null
Array,Math,Dynamic Programming,Sorting
Medium
null
130
welcome to june's leeco challenge today's problem is surrounded regions given a 2d board containing x's and o's capture all regions surrounded by x a region is captured by flipping all o's into x's in that surrounding region if we're given a board like this we can see that these zeros this island here is all surrounded...
Surrounded Regions
surrounded-regions
Given an `m x n` matrix `board` containing `'X'` and `'O'`, _capture all regions that are 4-directionally surrounded by_ `'X'`. A region is **captured** by flipping all `'O'`s into `'X'`s in that surrounded region. **Example 1:** **Input:** board = \[\[ "X ", "X ", "X ", "X "\],\[ "X ", "O ", "O ", "X "\],\[ "X ", "...
null
Array,Depth-First Search,Breadth-First Search,Union Find,Matrix
Medium
200,286
430
That Ajay Ko Hello Everyone Welcome Back to the video The question that we are going to solve today is an English question, a question on Delhi, a question on flight number, develop play list, a question, which is an intuition, before understanding it. After looking at the beautiful, the question says, then we will go ...
Flatten a Multilevel Doubly Linked List
flatten-a-multilevel-doubly-linked-list
You are given a doubly linked list, which contains nodes that have a next pointer, a previous pointer, and an additional **child pointer**. This child pointer may or may not point to a separate doubly linked list, also containing these special nodes. These child lists may have one or more children of their own, and so ...
null
null
Medium
null
1,619
hey guys what's up this is steve today let's go through another legal problem 1619 mean of array after removing some elements let's take a look at the problem first given an integer array return the mean of the remaining integers after removing the smallest five percent and the largest five percent of the elements answ...
Mean of Array After Removing Some Elements
path-crossing
Given an integer array `arr`, return _the mean of the remaining integers after removing the smallest `5%` and the largest `5%` of the elements._ Answers within `10-5` of the **actual answer** will be considered accepted. **Example 1:** **Input:** arr = \[1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3\] **Output:** 2.00000 ...
Simulate the process while keeping track of visited points. Use a set to store previously visited points.
Hash Table,String
Easy
null
79
hey guys welcome back to another video and today we're going to be solving the lead code question word search all right so we're going to be given a 2d board and we need to find whether a word exists so the word can be constructed from letters of sequentially adjacent cells and adjacent is only horizontal or vertically...
Word Search
word-search
Given an `m x n` grid of characters `board` and a string `word`, return `true` _if_ `word` _exists in the grid_. The word can be constructed from letters of sequentially adjacent cells, where adjacent cells are horizontally or vertically neighboring. The same letter cell may not be used more than once. **Example 1:**...
null
Array,Backtracking,Matrix
Medium
212
988
hey everybody this is Larry it is January 23rd uh of 2023 hit the like button to subscribe button drop me a Discord let me know what you think about today's part so this is not the bonus question yet or this is not the uh the daily question uh because I'm just it's a little bit before the time release I think there's l...
Smallest String Starting From Leaf
flip-equivalent-binary-trees
You are given the `root` of a binary tree where each node has a value in the range `[0, 25]` representing the letters `'a'` to `'z'`. Return _the **lexicographically smallest** string that starts at a leaf of this tree and ends at the root_. As a reminder, any shorter prefix of a string is **lexicographically smaller...
null
Tree,Depth-First Search,Binary Tree
Medium
null
744
all right so we're going to do number 744 find smallest letter greater than target so given a character's array letters that are sorted in non-decreasing order that are sorted in non-decreasing order that are sorted in non-decreasing order and a character target return the smallest character in the array that is larger...
Find Smallest Letter Greater Than Target
network-delay-time
You are given an array of characters `letters` that is sorted in **non-decreasing order**, and a character `target`. There are **at least two different** characters in `letters`. Return _the smallest character in_ `letters` _that is lexicographically greater than_ `target`. If such a character does not exist, return t...
We visit each node at some time, and if that time is better than the fastest time we've reached this node, we travel along outgoing edges in sorted order. Alternatively, we could use Dijkstra's algorithm.
Depth-First Search,Breadth-First Search,Graph,Heap (Priority Queue),Shortest Path
Medium
2151,2171
1,834
hey everybody this is larry this is me calling over q3 of the weekly contest 237 um and it seems like this was the one that i wish i had back because and probably the hardest problem of the contest not just by me but for other people um and it is single directed cpu so it's i think the hardest part at least for me abou...
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
1,641
welcome to joey's dynamic programming tutorial in this video of joystick you are going to learn one very interesting dynamic programming problem which is count sorted vowel strings this dynamic programming example problem is from the word of strings and i have taken it from the website of lead code count sorted vowel s...
Count Sorted Vowel Strings
countries-you-can-safely-invest-in
Given an integer `n`, return _the number of strings of length_ `n` _that consist only of vowels (_`a`_,_ `e`_,_ `i`_,_ `o`_,_ `u`_) and are **lexicographically sorted**._ A string `s` is **lexicographically sorted** if for all valid `i`, `s[i]` is the same as or comes before `s[i+1]` in the alphabet. **Example 1:** ...
null
Database
Medium
615
375
today we're gonna be working on your code question number 375 guess number higher or lower part two uh we are playing a guessing game here and the game will work as follows you're gonna be picking up a number from one to n you guess a number and then you win the game if you get the right number but if it is if i tell y...
Guess Number Higher or Lower II
guess-number-higher-or-lower-ii
We are playing the Guessing Game. The game will work as follows: 1. I pick a number between `1` and `n`. 2. You guess a number. 3. If you guess the right number, **you win the game**. 4. If you guess the wrong number, then I will tell you whether the number I picked is **higher or lower**, and you will continue gu...
The best strategy to play the game is to minimize the maximum loss you could possibly face. Another strategy is to minimize the expected loss. Here, we are interested in the first scenario. Take a small example (n = 3). What do you end up paying in the worst case? Check out this article if you're still stuck. The purel...
Math,Dynamic Programming,Game Theory
Medium
294,374,464,658
52
okay lit code number 52 and queens 2 and it is exactly the same problem as the previous problem in queens and this problem is actually less than the other problem as far as the complexity is concerned well the same problem but the output type is different and is less so pretty much the same problem n queens a chess boa...
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
1,977
welcome to another video on the coding the present let's start with the joke of the day welcome to another video on coding depressant let's start with the joke of the day so i had my first kiss when i was 14 years old it was just a second before my last case okay let's start with the question so the question is this nu...
Number of Ways to Separate Numbers
minimum-interval-to-include-each-query
You wrote down many **positive** integers in a string called `num`. However, you realized that you forgot to add commas to seperate the different numbers. You remember that the list of integers was **non-decreasing** and that **no** integer had leading zeros. Return _the **number of possible lists of integers** that y...
Is there a way to order the intervals and queries such that it takes less time to query? Is there a way to add and remove intervals by going from the smallest query to the largest query to find the minimum size?
Array,Binary Search,Line Sweep,Sorting,Heap (Priority Queue)
Hard
null
11
how to find out the container with most water so there are vertical lines drawn in the two endpoints of height and I 0 to I height so basically we have given one graph okay so this is one graph in this way so we have a vertical line which is drawn something like this so we have to check that container each of the verti...
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,672
today we will try to solve this problem of lead code which is problem 1672 reaches customer wealth if you haven't seen my previous video go and see my previous video where i've solved the challenges before this so we'll try to solve this challenge in javascript and so what we have to do is basically we have to find and...
Richest Customer Wealth
find-the-index-of-the-large-integer
You are given an `m x n` integer grid `accounts` where `accounts[i][j]` is the amount of money the `i​​​​​​​​​​​th​​​​` customer has in the `j​​​​​​​​​​​th`​​​​ bank. Return _the **wealth** that the richest customer has._ A customer's **wealth** is the amount of money they have in all their bank accounts. The richest ...
Do a binary search over the array, exclude the half of the array that doesn't contain the largest number. Keep shrinking the search space till it reaches the size of 2 where you can easily determine which one has the largest integer.
Array,Binary Search,Interactive
Medium
786
1,431
welcome to this video now we have according interview question kid with the greatest number of candies here's the problem statement you're given the array can and the integer extra candies where candice i represent the number of candies that the eighth kid had for his kid check if there is a way to distribute extra can...
Kids With the Greatest Number of Candies
all-ancestors-of-a-node-in-a-directed-acyclic-graph
There are `n` kids with candies. You are given an integer array `candies`, where each `candies[i]` represents the number of candies the `ith` kid has, and an integer `extraCandies`, denoting the number of extra candies that you have. Return _a boolean array_ `result` _of length_ `n`_, where_ `result[i]` _is_ `true` _i...
Consider how reversing each edge of the graph can help us. How can performing BFS/DFS on the reversed graph help us find the ancestors of every node?
Depth-First Search,Breadth-First Search,Graph,Topological Sort
Medium
1912
729
hello everyone welcome to coder's camp we are 10th day of june lead code challenge and the problem we are going to cover in this video is my calendar one so we have to implement a my calendar class to store our events so it has two methods my calendar is used to declare your data structures and the other method is book...
My Calendar I
my-calendar-i
You are implementing a program to use as your calendar. We can add a new event if adding the event will not cause a **double booking**. A **double booking** happens when two events have some non-empty intersection (i.e., some moment is common to both events.). The event can be represented as a pair of integers `start...
Store the events as a sorted list of intervals. If none of the events conflict, then the new event can be added.
Design,Segment Tree,Ordered Set
Medium
731,732
935
hello guys and welcome back to lead Logics this is the night dialer problem from lead code it is a lead code medium and the number for this is 935 so many of you might be finding this problem a bit difficult to solve but I'm going to tell you a way that will make this problem super easy for you so watch the video till ...
Knight Dialer
orderly-queue
The chess knight has a **unique movement**, it may move two squares vertically and one square horizontally, or two squares horizontally and one square vertically (with both forming the shape of an **L**). The possible movements of chess knight are shown in this diagaram: A chess knight can move as indicated in the che...
null
Math,String,Sorting
Hard
null
347
hey everyone welcome back today we are going to solve problem number three four seven top K frequent elements first we will see the explanation of the problem statement then the logic and the code now let's dive into the solution so here I've taken the first example from the lake website so in this problem we are given...
Top K Frequent Elements
top-k-frequent-elements
Given an integer array `nums` and an integer `k`, return _the_ `k` _most frequent elements_. You may return the answer in **any order**. **Example 1:** **Input:** nums = \[1,1,1,2,2,3\], k = 2 **Output:** \[1,2\] **Example 2:** **Input:** nums = \[1\], k = 1 **Output:** \[1\] **Constraints:** * `1 <= nums.lengt...
null
Array,Hash Table,Divide and Conquer,Sorting,Heap (Priority Queue),Bucket Sort,Counting,Quickselect
Medium
192,215,451,659,692,1014,1919
1,822
hello guys I hope you're doing great today I will be explaining the lead code challenge which is called sign of the product of an array so here to task is to multiply the elements of a list and return one if it is positive minus one if it is negative and zero if it is zero it is very easy actually but uh you don't need...
Sign of the Product of an Array
longest-palindromic-subsequence-ii
There is a function `signFunc(x)` that returns: * `1` if `x` is positive. * `-1` if `x` is negative. * `0` if `x` is equal to `0`. You are given an integer array `nums`. Let `product` be the product of all values in the array `nums`. Return `signFunc(product)`. **Example 1:** **Input:** nums = \[-1,-2,-3,-4,...
As with any good dp problem that uses palindromes, try building the palindrome from the edges The prime point is to check that no two adjacent characters are equal, so save the past character while building the palindrome.
String,Dynamic Programming
Medium
516
137
Hello gas welcome you my YouTube channel so today we are going to solve link road problem 137 single number you so this question is what is this sir number in this is what is in this sir number is thrive except one number. So I have to find that same number, this is the question in simple words, so as in this question,...
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,491
um hello so today we are going to do this problem which is part of Fleet code daily challenge average salary excluding the minimum and maximum salary so pretty uh it's an easy problem today um we have an array of integers salary and the salary at position I is basically the salary of the ith employee and want to return...
Average Salary Excluding the Minimum and Maximum Salary
number-of-times-binary-string-is-prefix-aligned
You are given an array of **unique** integers `salary` where `salary[i]` is the salary of the `ith` employee. Return _the average salary of employees excluding the minimum and maximum salary_. Answers within `10-5` of the actual answer will be accepted. **Example 1:** **Input:** salary = \[4000,3000,1000,2000\] **Ou...
If in the step x all bulb shines then bulbs 1,2,3,..,x should shines too.
Array
Medium
319,672
702
everyone so today we're looking at lead code number 702 search in a sorted array of unknown size okay so this question is basically we have a sorted array and but we don't know what the upper bound is we don't know how big this array is and so we need to search through this array and see if the target is in there and i...
Search in a Sorted Array of Unknown Size
search-in-a-sorted-array-of-unknown-size
This is an **_interactive problem_**. You have a sorted array of **unique** elements and an **unknown size**. You do not have an access to the array but you can use the `ArrayReader` interface to access it. You can call `ArrayReader.get(i)` that: * returns the value at the `ith` index (**0-indexed**) of the secret ...
null
null
Medium
null
950
hey what's good guys it's ilya bella here i recorded stuff on youtube chat description for all my information i do all lit good problems uh make sure you subscribe to your channel give me a big thumbs up to support it and this is called reveal cards in increasing order in a deck of cards every card has a unique integer...
Reveal Cards In Increasing Order
x-of-a-kind-in-a-deck-of-cards
You are given an integer array `deck`. There is a deck of cards where every card has a unique integer. The integer on the `ith` card is `deck[i]`. You can order the deck in any order you want. Initially, all the cards start face down (unrevealed) in one deck. You will do the following steps repeatedly until all cards...
null
Array,Hash Table,Math,Counting,Number Theory
Easy
null
486
hello everyone so today's problem in the predict the winner okay so here you are given an integer array norms and two players are playing a game with this Adder player one and player 2. and player one will start first both players play optimally and both let's start the game with a score of zero at each turn the player...
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