id
int64
1
2k
content
stringlengths
272
88.9k
title
stringlengths
3
77
title_slug
stringlengths
3
79
question_content
stringlengths
230
5k
question_hints
stringclasses
695 values
tag
stringclasses
618 values
level
stringclasses
3 values
similar_question_ids
stringclasses
822 values
1,697
hello friends welcome to my channel let's have a look at problem 1697 together checking existence of edge lens limited path so in this video we're going to share a solution based on this joint set data structure also known as disjoint set forest or unified so this problem is marked hard in ditch code however if we anal...
Checking Existence of Edge Length Limited Paths
strings-differ-by-one-character
An undirected graph of `n` nodes is defined by `edgeList`, where `edgeList[i] = [ui, vi, disi]` denotes an edge between nodes `ui` and `vi` with distance `disi`. Note that there may be **multiple** edges between two nodes. Given an array `queries`, where `queries[j] = [pj, qj, limitj]`, your task is to determine for e...
BruteForce, check all pairs and verify if they differ in one character. O(n^2 * m) where n is the number of words and m is the length of each string. O(m^2 * n), Use hashset, to insert all possible combinations adding a character "*". For example: If dict[i] = "abc", insert ("*bc", "a*c" and "ab*").
Hash Table,String,Rolling Hash,Hash Function
Medium
2256
15
hey guys Greg here and let's solve three sum so we're given integer array of nums and we need to return all the triplets nums at I nums at J and nums at K such that I is not j i is not K and J is not K so basically they're all three different positions and we also must have that the three numbers of the array they are ...
3Sum
3sum
Given an integer array nums, return all the triplets `[nums[i], nums[j], nums[k]]` such that `i != j`, `i != k`, and `j != k`, and `nums[i] + nums[j] + nums[k] == 0`. Notice that the solution set must not contain duplicate triplets. **Example 1:** **Input:** nums = \[-1,0,1,2,-1,-4\] **Output:** \[\[-1,-1,2\],\[-1,0...
So, we essentially need to find three numbers x, y, and z such that they add up to the given value. If we fix one of the numbers say x, we are left with the two-sum problem at hand! For the two-sum problem, if we fix one of the numbers, say x, we have to scan the entire array to find the next numbery which is value - x...
Array,Two Pointers,Sorting
Medium
1,16,18,259
759
well so this question is employee free time so you are given a list of intervals and basically you just have to find out the gap in between if they have a free time so just for example and this is going to be like one two so you take this powerful one two and then you take this spot for five six and then you take this ...
Employee Free Time
set-intersection-size-at-least-two
We are given a list `schedule` of employees, which represents the working time for each employee. Each employee has a list of non-overlapping `Intervals`, and these intervals are in sorted order. Return the list of finite intervals representing **common, positive-length free time** for _all_ employees, also in sorted...
null
Array,Greedy,Sorting
Hard
null
1,530
hello and welcome back to the cracking fang youtube channel today we're going to be solving lead code problem 1530 number of good leaf nodes pairs let's read the question prompt you are given the root of a binary tree and an integer distance a pair of two different leaf nodes of a binary tree is said to be good if the ...
Number of Good Leaf Nodes Pairs
check-if-a-string-can-break-another-string
You are given the `root` of a binary tree and an integer `distance`. A pair of two different **leaf** nodes of a binary tree is said to be good if the length of **the shortest path** between them is less than or equal to `distance`. Return _the number of good leaf node pairs_ in the tree. **Example 1:** **Input:** r...
Sort both strings and then check if one of them can break the other.
String,Greedy,Sorting
Medium
null
316
hey everybody this is Larry this is Day 26 of uh Delete code daily challenge hit the like button hit the Subscribe button join me on Discord let me know what you think about today's forum is removed to because letters uh didn't we do that yet oh wait no we did not well definitely did not do it yesterday but I guess it ...
Remove Duplicate Letters
remove-duplicate-letters
Given a string `s`, remove duplicate letters so that every letter appears once and only once. You must make sure your result is **the smallest in lexicographical order** among all possible results. **Example 1:** **Input:** s = "bcabc " **Output:** "abc " **Example 2:** **Input:** s = "cbacdcbc " **Output:** "a...
Greedily try to add one missing character. How to check if adding some character will not cause problems ? Use bit-masks to check whether you will be able to complete the sub-sequence if you add the character at some index i.
String,Stack,Greedy,Monotonic Stack
Medium
2157
257
hello everyone so in this video let us talk about one no easy problem from lead code the problem name is binary tree parts so you're given a root of a binary tree you have to return all the roots to leave paths in any order as possible your leaf is a node with no children okay so as you can see that for this particular...
Binary Tree Paths
binary-tree-paths
Given the `root` of a binary tree, return _all root-to-leaf paths in **any order**_. A **leaf** is a node with no children. **Example 1:** **Input:** root = \[1,2,3,null,5\] **Output:** \[ "1->2->5 ", "1->3 "\] **Example 2:** **Input:** root = \[1\] **Output:** \[ "1 "\] **Constraints:** * The number of nodes ...
null
String,Backtracking,Tree,Depth-First Search,Binary Tree
Easy
113,1030,2217
76
hello and welcome to my next self study session today we're going to be looking at lead code number 76 minimum window substring and so with this problem we're given two strings s and t of lengths m and n respectively and our task is to return the minimum window substring of s such that every character in t including du...
Minimum Window Substring
minimum-window-substring
Given two strings `s` and `t` of lengths `m` and `n` respectively, return _the **minimum window**_ **_substring_** _of_ `s` _such that every character in_ `t` _(**including duplicates**) is included in the window_. If there is no such substring, return _the empty string_ `" "`. The testcases will be generated such tha...
Use two pointers to create a window of letters in S, which would have all the characters from T. Since you have to find the minimum window in S which has all the characters from T, you need to expand and contract the window using the two pointers and keep checking the window for all the characters. This approach is als...
Hash Table,String,Sliding Window
Hard
30,209,239,567,632,727
134
hi everyone in this video we are going to solve the problem name is gas station and the question number is 134 first of all we will understand this problem after that we will see the logic to solve this problem and after that we will implement the logic so let quickly see what this problem say there are n gas station a...
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
1,351
hey guys hi and welcome to the video this video we are gonna solve a lead code problem uh that is problem number one three five one count negative numbers in a sorted matrix very interesting problem uh i'll essentially try to explain you i have a visualization that i'll try to explain right so what we are essentially d...
Count Negative Numbers in a Sorted Matrix
replace-the-substring-for-balanced-string
Given a `m x n` matrix `grid` which is sorted in non-increasing order both row-wise and column-wise, return _the number of **negative** numbers in_ `grid`. **Example 1:** **Input:** grid = \[\[4,3,2,-1\],\[3,2,1,-1\],\[1,1,-1,-2\],\[-1,-1,-2,-3\]\] **Output:** 8 **Explanation:** There are 8 negatives number in the ma...
Use 2-pointers algorithm to make sure all amount of characters outside the 2 pointers are smaller or equal to n/4. That means you need to count the amount of each letter and make sure the amount is enough.
String,Sliding Window
Medium
null
1,897
hey yo what's up my little coders let me show you in this tutorial how to solve the lethal question number 1897 redistribute characters to make all strings equal basically we are given an array of some strings and we need to return boolean which will say if it's possible to redistribute the characters in such a way so ...
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
347
how's it going ladies and gentlemen so today we are going to solve another coolest problem which is lead code 347 which is top k frequent elements so what the problem statement is saying we have given an uh integer error numbers and integer k so we have to return k most frequent elements i will get to the point where t...
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,832
foreign problem and the problems name is check if the sentence is pan gram so by definition a sentence is a panoram when every letter of the English alphabet is appearing at least once inside the sentence so we are given a sentence which contains only lowercase English letters and we have to return true if a sentence i...
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
491
hello guys my name is vishwa saitat I hope you all are doing fine so today's problem for lead code is non-decreasing problem for lead code is non-decreasing problem for lead code is non-decreasing subsequence okay so problem says given an integer array written all the different possible non-decreasing different possibl...
Non-decreasing Subsequences
increasing-subsequences
Given an integer array `nums`, return _all the different possible non-decreasing subsequences of the given array with at least two elements_. You may return the answer in **any order**. **Example 1:** **Input:** nums = \[4,6,7,7\] **Output:** \[\[4,6\],\[4,6,7\],\[4,6,7,7\],\[4,7\],\[4,7,7\],\[6,7\],\[6,7,7\],\[7,7\]...
null
Array,Hash Table,Backtracking,Bit Manipulation
Medium
646
72
they are there so today is the final day for the Meili coding challenge question that is the Telus question as editor distance we have two words word one there were two when you find the minimum number of operations required to convert old one - word - there are three old one - word - there are three old one - word - t...
Edit Distance
edit-distance
Given two strings `word1` and `word2`, return _the minimum number of operations required to convert `word1` to `word2`_. You have the following three operations permitted on a word: * Insert a character * Delete a character * Replace a character **Example 1:** **Input:** word1 = "horse ", word2 = "ros " **O...
null
String,Dynamic Programming
Hard
161,583,712,1105,2311
71
Hello friends today I'm going to solve liquid problem number 71 simplify path in this problem we are given an absolute path so absolute path means the path starts from the root directory and um it is a unique style file system path and we need to convert it into simplified canonical path so in Unix style file system pa...
Simplify Path
simplify-path
Given a string `path`, which is an **absolute path** (starting with a slash `'/'`) to a file or directory in a Unix-style file system, convert it to the simplified **canonical path**. In a Unix-style file system, a period `'.'` refers to the current directory, a double period `'..'` refers to the directory up a level,...
null
String,Stack
Medium
null
160
hey and welcome today we will solve intersection of two linked list interview questions which mostly asked by Apple as well as other companies like so we will explore two solutions for this problem so without further Ado let's Dive In here is first example as you can see we have two linked lists amb first one a is shor...
Intersection of Two Linked Lists
intersection-of-two-linked-lists
Given the heads of two singly linked-lists `headA` and `headB`, return _the node at which the two lists intersect_. If the two linked lists have no intersection at all, return `null`. For example, the following two linked lists begin to intersect at node `c1`: The test cases are generated such that there are no cycle...
null
Hash Table,Linked List,Two Pointers
Easy
599
128
in this video we'll go over lead code question number 128 longest consecutive sequence given an unsorted array of integers called nums we must return the length of the longest sequence of consecutive elements for example if this is the array of integers given then the longest consecutive sequence starts at one then goe...
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
40
this is the 40th liquid Challenge and it is called combination sum 2. given a collection of candidate numbers candidates and a target number Target find all unique combinations and candidates where the candidate numbers sum to Target each number in candidates may only be used once in the combination so if you have 10 1...
Combination Sum II
combination-sum-ii
Given a collection of candidate numbers (`candidates`) and a target number (`target`), find all unique combinations in `candidates` where the candidate numbers sum to `target`. Each number in `candidates` may only be used **once** in the combination. **Note:** The solution set must not contain duplicate combinations....
null
Array,Backtracking
Medium
39
151
hey guys welcome back to another video and today we're going to be solving the lead code question reverse where it's in a string so this question is pretty simple so we're given an input of a string and all we got to do is reverse it so if we're given the sky is blue we new output blue sky duh let's say we're given hel...
Reverse Words in a String
reverse-words-in-a-string
Given an input string `s`, reverse the order of the **words**. A **word** is defined as a sequence of non-space characters. The **words** in `s` will be separated by at least one space. Return _a string of the words in reverse order concatenated by a single space._ **Note** that `s` may contain leading or trailing s...
null
Two Pointers,String
Medium
186
139
Border will solve the question in high speed. One is fine. What do you see from the back side, then by showing you the like pad, WhatsApp loading in it, Amazon app coding, this garlic and words on ice cream together, man who loves, then you subscribe. Can make back PCOD feeling crush has been declared lbw Can make this...
Word Break
word-break
Given a string `s` and a dictionary of strings `wordDict`, return `true` if `s` can be segmented into a space-separated sequence of one or more dictionary words. **Note** that the same word in the dictionary may be reused multiple times in the segmentation. **Example 1:** **Input:** s = "leetcode ", wordDict = \[ "...
null
Hash Table,String,Dynamic Programming,Trie,Memoization
Medium
140
129
hello everyone welcome or welcome back to coding charms in today's video we are going to be solving the problem some route to Leaf numbers and in this problem we are given with a root of a binary tree containing digits from 0 to 9 only and each route to Leaf path is a you know in the tree represents a number for exampl...
Sum Root to Leaf Numbers
sum-root-to-leaf-numbers
You are given the `root` of a binary tree containing digits from `0` to `9` only. Each root-to-leaf path in the tree represents a number. * For example, the root-to-leaf path `1 -> 2 -> 3` represents the number `123`. Return _the total sum of all root-to-leaf numbers_. Test cases are generated so that the answer w...
null
Tree,Depth-First Search,Binary Tree
Medium
112,124,1030
438
hi everyone so let's talk about the final element in the stream so we're giving two string s and p so you have to return the array of all the starting indices of p and again in s so you can return any order so i'm going to as should i reform that and the pattern right so here's the solution you can use a container arra...
Find All Anagrams in a String
find-all-anagrams-in-a-string
Given two strings `s` and `p`, return _an array of all the start indices of_ `p`_'s anagrams in_ `s`. You may return the answer in **any order**. An **Anagram** is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. **Example 1:** *...
null
Hash Table,String,Sliding Window
Medium
242,567
145
Hello friends, welcome, your name is youtube0, lead code of the challenge, so let's go straight to the screen and start today's question, so what have you told us? The number of today's question is 145 and the name of the question is binary. Tree pre order traversal Okay so basically there are three types of traversal ...
Binary Tree Postorder Traversal
binary-tree-postorder-traversal
Given the `root` of a binary tree, return _the postorder traversal of its nodes' values_. **Example 1:** **Input:** root = \[1,null,2,3\] **Output:** \[3,2,1\] **Example 2:** **Input:** root = \[\] **Output:** \[\] **Example 3:** **Input:** root = \[1\] **Output:** \[1\] **Constraints:** * The number of the n...
null
Stack,Tree,Depth-First Search,Binary Tree
Easy
94,776
739
hi in this video i will solve daily temperature from lead code basically it says given in given an array of integers temperature which represents the daily temperature return an array answer so just such that the answer is the number of days you have to wait okay return answer now we gotta figure out what do we have to...
Daily Temperatures
daily-temperatures
Given an array of integers `temperatures` represents the daily temperatures, return _an array_ `answer` _such that_ `answer[i]` _is the number of days you have to wait after the_ `ith` _day to get a warmer temperature_. If there is no future day for which this is possible, keep `answer[i] == 0` instead. **Example 1:**...
If the temperature is say, 70 today, then in the future a warmer temperature must be either 71, 72, 73, ..., 99, or 100. We could remember when all of them occur next.
Array,Stack,Monotonic Stack
Medium
496,937
1,011
hello friends so today we're gonna continue the series on binary search on which i have already uploaded three videos you can go and check that out so i uploaded three medium problems from lead code and now we're gonna talk about or i will upload five hard or like sorry medium problems and then i will like i will uploa...
Capacity To Ship Packages Within D Days
flip-binary-tree-to-match-preorder-traversal
A conveyor belt has packages that must be shipped from one port to another within `days` days. The `ith` package on the conveyor belt has a weight of `weights[i]`. Each day, we load the ship with packages on the conveyor belt (in the order given by `weights`). We may not load more weight than the maximum weight capaci...
null
Tree,Depth-First Search,Binary Tree
Medium
null
445
today we are going to solve lead code 445 that is add two numbers two so we are provided with two numbers in a form of linked list separate link list and we need to add these two numbers and we have to return the summation as a linked list so we can assume that the numbers are not having any leading zero and this is th...
Add Two Numbers II
add-two-numbers-ii
You are given two **non-empty** linked lists representing two non-negative integers. The most significant digit comes first and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list. You may assume the two numbers do not contain any leading zero, except the number 0 itsel...
null
Linked List,Math,Stack
Medium
2,1774
341
hello everyone welcome to day eight of my elite code challenge and i hope all of you are having a great time my name is sanchez i'm working a software developer for adobe and today i present day 677 of daily leader problem the question that we have in today's flatten nested list iterator it's a design level question an...
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
779
hello guys and welcome back to lead Logics today we'll be going to solve the question K symbol in grammar this is a lead code medium and the number for this is 779 so in this question we are uh we have to create a table of n rows and uh we can start using u a zero and we replace uh 0 and one every place in the subseque...
K-th Symbol in Grammar
max-chunks-to-make-sorted-ii
We build a table of `n` rows (**1-indexed**). We start by writing `0` in the `1st` row. Now in every subsequent row, we look at the previous row and replace each occurrence of `0` with `01`, and each occurrence of `1` with `10`. * For example, for `n = 3`, the `1st` row is `0`, the `2nd` row is `01`, and the `3rd` r...
Each k for which some permutation of arr[:k] is equal to sorted(arr)[:k] is where we should cut each chunk.
Array,Stack,Greedy,Sorting,Monotonic Stack
Hard
780
171
hello everyone so today we are going to do let go daily challenge excel sheet number so basically in this question we would be given with a column title which is like uh means simply a string would be given to us and we are required to return the output as an integer that is if a is given to us that is this thing if a ...
Excel Sheet Column Number
excel-sheet-column-number
Given a string `columnTitle` that represents the column title as appears in an Excel sheet, return _its corresponding column number_. For example: A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 AB -> 28 ... **Example 1:** **Input:** columnTitle = "A " **Output:** 1 **Example 2:** **Input:** columnTitle = "AB " **Ou...
null
Math,String
Easy
168,2304
309
hey what's up guys chung here again so this time let's take a look at another elite code problem here uh number 309 best time to buy and sell stock with cool down you know in lead code there are like a series of buy and sell stock problems there's like about buys and sell stock one two three four and then with transact...
Best Time to Buy and Sell Stock with Cooldown
best-time-to-buy-and-sell-stock-with-cooldown
You are given an array `prices` where `prices[i]` is the price of a given stock on the `ith` day. Find the maximum profit you can achieve. You may complete as many transactions as you like (i.e., buy one and sell one share of the stock multiple times) with the following restrictions: * After you sell your stock, yo...
null
Array,Dynamic Programming
Medium
121,122
416
hello everyone welcome to quartus camp we are at 12th day of dissemble eco challenge and the problem we are going to cover today in this video is partition equal substitute so the input given here is a non-empty integer array given here is a non-empty integer array given here is a non-empty integer array nums and we ha...
Partition Equal Subset Sum
partition-equal-subset-sum
Given an integer array `nums`, return `true` _if you can partition the array into two subsets such that the sum of the elements in both subsets is equal or_ `false` _otherwise_. **Example 1:** **Input:** nums = \[1,5,11,5\] **Output:** true **Explanation:** The array can be partitioned as \[1, 5, 5\] and \[11\]. **E...
null
Array,Dynamic Programming
Medium
698,2108,2135,2162
1,095
I all with Calvin here so today we will discuss about fine in Montana ray from weekly contests 142 so let's start so this question is basically asking us to find a failure and return index from an array so the array itself is having a sequence of Kipnis do ghosts ending and at one point it goes to standing and for form...
Find in Mountain Array
two-city-scheduling
_(This problem is an **interactive problem**.)_ You may recall that an array `arr` is a **mountain array** if and only if: * `arr.length >= 3` * There exists some `i` with `0 < i < arr.length - 1` such that: * `arr[0] < arr[1] < ... < arr[i - 1] < arr[i]` * `arr[i] > arr[i + 1] > ... > arr[arr.length ...
null
Array,Greedy,Sorting
Medium
null
1,022
That's Hello Hi Everyone, let's see today's question, this list is a question dated September 40, Azhar, I am trying it, I don't have a camera today, so I am thinking about motherboard, who knows, hurry up, Veer, it is taking some time, it is looking good, so cleaning work. Ready Given by Ministry 12021 Police has pick...
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
1,851
hey everybody this is larry this is me going for q4 of the weekly contest 239 uh minimum interval to encourage each query so i don't know if you did the bi-weekly i don't know if you did the bi-weekly i don't know if you did the bi-weekly maybe not if you did then i have the same idea there about thinking about backwar...
Minimum Interval to Include Each Query
maximum-number-of-events-that-can-be-attended-ii
You are given a 2D integer array `intervals`, where `intervals[i] = [lefti, righti]` describes the `ith` interval starting at `lefti` and ending at `righti` **(inclusive)**. The **size** of an interval is defined as the number of integers it contains, or more formally `righti - lefti + 1`. You are also given an intege...
Sort the events by its startTime. For every event, you can either choose it and consider the next event available, or you can ignore it. You can efficiently find the next event that is available using binary search.
Array,Binary Search,Dynamic Programming
Hard
1478,2118,2164
872
hey guys welcome or welcome back to my channel so today we are going to discuss another problem is leave similar trees so in this problem uh we have a binary tree so we have to consider all the leaves of the binary tree from left to right order so all the leaf nodes from left to right the value of those leaves forms a ...
Leaf-Similar Trees
split-array-into-fibonacci-sequence
Consider all the leaves of a binary tree, from left to right order, the values of those leaves form a **leaf value sequence**_._ For example, in the given tree above, the leaf value sequence is `(6, 7, 4, 9, 8)`. Two binary trees are considered _leaf-similar_ if their leaf value sequence is the same. Return `true` i...
null
String,Backtracking
Medium
306,1013
791
hi everyone so let's talk about custom short strings so you are given two strings order and x all the words of order are unique and were sorted in some custom order previously so premiere the characters of s so that match the order that order was sorted so much more specifically if a character x occurred before a chara...
Custom Sort String
split-bst
You are given two strings order and s. All the characters of `order` are **unique** and were sorted in some custom order previously. Permute the characters of `s` so that they match the order that `order` was sorted. More specifically, if a character `x` occurs before a character `y` in `order`, then `x` should occur ...
Use recursion. If root.val <= V, you split root.right into two halves, then join it's left half back on root.right.
Tree,Binary Search Tree,Recursion,Binary Tree
Medium
450
326
hey this is Topher with the lonely Dash and today we're going to be solving Elite code question 326 power of three which states given an integer n return true if it is a power of three otherwise return false an integer N is a power of three if there exists an integer X such that n is equal to 3 to that integer okay so ...
Power of Three
power-of-three
Given an integer `n`, return _`true` if it is a power of three. Otherwise, return `false`_. An integer `n` is a power of three, if there exists an integer `x` such that `n == 3x`. **Example 1:** **Input:** n = 27 **Output:** true **Explanation:** 27 = 33 **Example 2:** **Input:** n = 0 **Output:** false **Explanat...
null
Math,Recursion
Easy
231,342,1889
1,760
hi folks let's solve this little problem minimum limit of both in a bag so it's a very typical binary problem let's take a look at this problem if you haven't read the problem you can take one minute to read the specs about this problem so let's take a look at some examples the first examples if numbers is 9 and maximu...
Minimum Limit of Balls in a Bag
check-array-formation-through-concatenation
You are given an integer array `nums` where the `ith` bag contains `nums[i]` balls. You are also given an integer `maxOperations`. You can perform the following operation at most `maxOperations` times: * Take any bag of balls and divide it into two new bags with a **positive** number of balls. * For example, ...
Note that the distinct part means that every position in the array belongs to only one piece Note that you can get the piece every position belongs to naively
Array,Hash Table
Easy
null
63
hello everyone today we will discuss a medium hard level dynamic programming problem uh lead called algorithm problem 63 unique past two this problem is a fuller problem from previous uh 62 unit pass and then the difference between these two problems is in this new problem there is one more requirement on this one an o...
Unique Paths II
unique-paths-ii
You are given an `m x n` integer array `grid`. There is a robot initially located at the **top-left corner** (i.e., `grid[0][0]`). The robot tries to move to the **bottom-right corner** (i.e., `grid[m - 1][n - 1]`). The robot can only move either down or right at any point in time. An obstacle and space are marked as ...
The robot can only move either down or right. Hence any cell in the first row can only be reached from the cell left to it. However, if any cell has an obstacle, you don't let that cell contribute to any path. So, for the first row, the number of ways will simply be if obstacleGrid[i][j] is not an obstacle ...
Array,Dynamic Programming,Matrix
Medium
62,1022
108
Loot Soheb Everyone Welcome Back To Induce And Today's Problems Pade Converted Into Binary Search Tree Surya Given With Boys Are Names Where Elements Of Water In Ascending Order Subscribe Balance Points 151 Egg Subscribe And Subscribe - - You Can See Subscribe Balance - Subscribe Balance - Subscribe Balance - 100 Chann...
Convert Sorted Array to Binary Search Tree
convert-sorted-array-to-binary-search-tree
Given an integer array `nums` where the elements are sorted in **ascending order**, convert _it to a_ **_height-balanced_** _binary search tree_. **Example 1:** **Input:** nums = \[-10,-3,0,5,9\] **Output:** \[0,-3,9,-10,null,5\] **Explanation:** \[0,-10,5,null,-3,null,9\] is also accepted: **Example 2:** **Input...
null
Array,Divide and Conquer,Tree,Binary Search Tree,Binary Tree
Easy
109
515
Live Let Me Quickly Check If We Are In Fact Live So If You Started Joining Hello And If You Can Mention Yes In Chat If You Can Hear Me Properly And The Setup Is Visible Or Hi Rajit How Are You I Am Good To Write A Thc Everyone Else Was Also Start Joining In A Bit Okay Or So Yesterday We Couldn't Have This Session There...
Find Largest Value in Each Tree Row
find-largest-value-in-each-tree-row
Given the `root` of a binary tree, return _an array of the largest value in each row_ of the tree **(0-indexed)**. **Example 1:** **Input:** root = \[1,3,2,5,3,null,9\] **Output:** \[1,3,9\] **Example 2:** **Input:** root = \[1,2,3\] **Output:** \[1,3\] **Constraints:** * The number of nodes in the tree will be...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Medium
null
1,248
Hello Everyone and Welcome Back to My Channel Algorithm H K Today I am going to write the code and also explain you all the algorithm to solve this count number of nice sub are problem f is there in lead code it is also a part of words A very simple DSA course slush sheet and is present in the two pointer and sliding w...
Count Number of Nice Subarrays
binary-tree-coloring-game
Given an array of integers `nums` and an integer `k`. A continuous subarray is called **nice** if there are `k` odd numbers on it. Return _the number of **nice** sub-arrays_. **Example 1:** **Input:** nums = \[1,1,2,1,1\], k = 3 **Output:** 2 **Explanation:** The only sub-arrays with 3 odd numbers are \[1,1,2,1\] an...
The best move y must be immediately adjacent to x, since it locks out that subtree. Can you count each of (up to) 3 different subtrees neighboring x?
Tree,Depth-First Search,Binary Tree
Medium
null
1,930
hey everyone let's start the today's Cod Challenge which is unique three length palindromic sub subsequence so in this problem we are given a string and we have to return all the palindromic subsequences of this string which is uh of length three so for this example let's say we are given a string a b c a so we have to...
Unique Length-3 Palindromic Subsequences
maximum-number-of-consecutive-values-you-can-make
Given a string `s`, return _the number of **unique palindromes of length three** that are a **subsequence** of_ `s`. Note that even if there are multiple ways to obtain the same subsequence, it is still only counted **once**. A **palindrome** is a string that reads the same forwards and backwards. A **subsequence** ...
If you can make the first x values and you have a value v, then you can make all the values ≤ v + x Sort the array of coins. You can always make the value 0 so you can start with x = 0. Process the values starting from the smallest and stop when there is a value that cannot be achieved with the current x.
Array,Greedy
Medium
330
119
Hi Everyone, our lead code daily challenge today is Pascal's Triangle. This is an easy level question, so all we have to do is that we will be given a row index, then whatever our values ​​are in Pascal's Triangle on that index, then whatever our values ​​are in Pascal's Triangle on that index, then whatever our values...
Pascal's Triangle II
pascals-triangle-ii
Given an integer `rowIndex`, return the `rowIndexth` (**0-indexed**) row of the **Pascal's triangle**. In **Pascal's triangle**, each number is the sum of the two numbers directly above it as shown: **Example 1:** **Input:** rowIndex = 3 **Output:** \[1,3,3,1\] **Example 2:** **Input:** rowIndex = 0 **Output:** \[...
null
Array,Dynamic Programming
Easy
118,2324
1,887
okay so hello people so today we'll be solving need code daily equation 1887 that is reduction operations to make the are elements equal okay so in this we'll be given an integer nums and my goal is to make all the elements in nums equal okay and one operation is defined as we have to find the largest yeah sorry we hav...
Reduction Operations to Make the Array Elements Equal
minimum-degree-of-a-connected-trio-in-a-graph
Given an integer array `nums`, your goal is to make all elements in `nums` equal. To complete one operation, follow these steps: 1. Find the **largest** value in `nums`. Let its index be `i` (**0-indexed**) and its value be `largest`. If there are multiple elements with the largest value, pick the smallest `i`. 2. F...
Consider a trio with nodes u, v, and w. The degree of the trio is just degree(u) + degree(v) + degree(w) - 6. The -6 comes from subtracting the edges u-v, u-w, and v-w, which are counted twice each in the vertex degree calculation. To get the trios (u,v,w), you can iterate on u, then iterate on each w,v such that w and...
Graph
Hard
null
1,879
hello everyone today i'm going to actually um explain this question the lead code number is 1879 the minimize the minimum x or sum of two array okay so in this array we can say uh we are given two integer array numbers one and the numbers two the length is the same is n so we can see from here the constraints here uh n...
Minimum XOR Sum of Two Arrays
maximum-score-from-removing-stones
You are given two integer arrays `nums1` and `nums2` of length `n`. The **XOR sum** of the two integer arrays is `(nums1[0] XOR nums2[0]) + (nums1[1] XOR nums2[1]) + ... + (nums1[n - 1] XOR nums2[n - 1])` (**0-indexed**). * For example, the **XOR sum** of `[1,2,3]` and `[3,2,1]` is equal to `(1 XOR 3) + (2 XOR 2) +...
It's optimal to always remove one stone from the biggest 2 piles Note that the limits are small enough for simulation
Math,Greedy,Heap (Priority Queue)
Medium
null
156
hi everyone welcome to my channel and thanks for tuning in uh the question that I have picked up for today is from lithgold and it's called binary tree upside down this question has been mainly used in LinkedIn so that's good to know but what is the question let's go over the question prompt given the root of a binary ...
Binary Tree Upside Down
binary-tree-upside-down
Given the `root` of a binary tree, turn the tree upside down and return _the new root_. You can turn a binary tree upside down with the following steps: 1. The original left child becomes the new root. 2. The original root becomes the new right child. 3. The original right child becomes the new left child. The me...
null
Tree,Depth-First Search,Binary Tree
Medium
206
148
all right trying out this problem sort list even the head of a linked list return the list after sorting it in ascending order so this is the list you sorted and use it on the list the sorted list okay example to this again sorted list basically let's sort the down list okay constraints number of nodes in the list is b...
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
997
hey everybody this is Larry this is day 22 of the Leo day challenge hit the like button hit the Subscribe button join me in Discord let me know what you think about this problem uh and we have a premium problem later I just want to also say uh I think just a quick update before we start today's problem I should click o...
Find the Town Judge
find-the-town-judge
In a town, there are `n` people labeled from `1` to `n`. There is a rumor that one of these people is secretly the town judge. If the town judge exists, then: 1. The town judge trusts nobody. 2. Everybody (except for the town judge) trusts the town judge. 3. There is exactly one person that satisfies properties **...
null
null
Easy
null
896
hey guys how's everything going this is Jay sir who is not good at algorithms in this video I'm going to take a look at a 96 monotonic array an array is monotonic if it is either monotone increasing or monotone decreasing if an array is a monitor increasing if for all elements the latter one will be bigger than the pre...
Monotonic Array
smallest-subtree-with-all-the-deepest-nodes
An array is **monotonic** if it is either monotone increasing or monotone decreasing. An array `nums` is monotone increasing if for all `i <= j`, `nums[i] <= nums[j]`. An array `nums` is monotone decreasing if for all `i <= j`, `nums[i] >= nums[j]`. Given an integer array `nums`, return `true` _if the given array is ...
null
Hash Table,Tree,Depth-First Search,Breadth-First Search,Binary Tree
Medium
null
1,060
hello and welcome to another Elite code video today we're going to be working on missing element and assorted array and in this problem you're given an injury nums which is sorted in ascending order and all of its elements are unique and also ninja K return the K missing number starting from the leftmost of the array s...
Missing Element in Sorted Array
longest-repeating-substring
Given an integer array `nums` which is sorted in **ascending order** and all of its elements are **unique** and given also an integer `k`, return the `kth` missing number starting from the leftmost number of the array. **Example 1:** **Input:** nums = \[4,7,9,10\], k = 1 **Output:** 5 **Explanation:** The first missi...
Generate all substrings in O(N^2) time with hashing. Choose those hashing of strings with the largest length.
String,Binary Search,Dynamic Programming,Rolling Hash,Suffix Array,Hash Function
Medium
null
65
for you guys now we will do 60 this problem at least board valid numbers validate if a given string is numeric some example zero is still zero point one ABC is false a page a is false to eat nh3 okay so let's get right at it we are going to do this in four ends I'm going to here once to the strength to do this in the o...
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,673
hey guys today we have lead code 1673 find the most competitive subsequence we'll be given an array of integers nums and an integer k and we have to return the most competitive subsequence of size exactly k most competitive subsequence is just a fancy way of saying the lexicographically smallest subsequence or the lexi...
Find the Most Competitive Subsequence
find-the-most-competitive-subsequence
Given an integer array `nums` and a positive integer `k`, return _the most **competitive** subsequence of_ `nums` _of size_ `k`. An array's subsequence is a resulting sequence obtained by erasing some (possibly zero) elements from the array. We define that a subsequence `a` is more **competitive** than a subsequence ...
null
null
Medium
null
1,615
hello and welcome to another Elite code problem today we're going to be doing maximal Network rank so in this problem you have an infrastructure of ncds with some number of Roads connecting those cities each Road indicates that there is a bite of natural Road between cities A and B and then the network rank of two diff...
Maximal Network Rank
range-sum-of-sorted-subarray-sums
There is an infrastructure of `n` cities with some number of `roads` connecting these cities. Each `roads[i] = [ai, bi]` indicates that there is a bidirectional road between cities `ai` and `bi`. The **network rank** of **two different cities** is defined as the total number of **directly** connected roads to **either...
Compute all sums and save it in array. Then just go from LEFT to RIGHT index and calculate answer modulo 1e9 + 7.
Array,Two Pointers,Binary Search,Sorting
Medium
null
146
Hello friends welcome to code Sutra let's all lead code problem number 146 lru cage let's take a real word example and let's try to understand the concept let's take the example of chrome you re recently started using Chrome and the first website that you will be opening is so what will be there in the is so what will ...
LRU Cache
lru-cache
Design a data structure that follows the constraints of a **[Least Recently Used (LRU) cache](https://en.wikipedia.org/wiki/Cache_replacement_policies#LRU)**. Implement the `LRUCache` class: * `LRUCache(int capacity)` Initialize the LRU cache with **positive** size `capacity`. * `int get(int key)` Return the valu...
null
Hash Table,Linked List,Design,Doubly-Linked List
Medium
460,588,604,1903
997
hello hi guys good morning I hope that you guys are doing good in this we going to see the problem well no not this problem but we're going to see find the town judge but it is exactly same as that of this premium problem again uh we'll see this also but yeah no worri it has as for turning uh Amazon Adobe Apple Bloombe...
Find the Town Judge
find-the-town-judge
In a town, there are `n` people labeled from `1` to `n`. There is a rumor that one of these people is secretly the town judge. If the town judge exists, then: 1. The town judge trusts nobody. 2. Everybody (except for the town judge) trusts the town judge. 3. There is exactly one person that satisfies properties **...
null
null
Easy
null
1,007
hello everyone today we are going to solve minimum domino's rotation for equal row so in this problem uh we have a two rows top and bottom which represent the top and bottom half of our is domino and we can rotate top and bottom half okay so in this problem we need to return the minimum number of rotation so that all t...
Minimum Domino Rotations For Equal Row
numbers-with-same-consecutive-differences
In a row of dominoes, `tops[i]` and `bottoms[i]` represent the top and bottom halves of the `ith` domino. (A domino is a tile with two numbers from 1 to 6 - one on each half of the tile.) We may rotate the `ith` domino, so that `tops[i]` and `bottoms[i]` swap values. Return the minimum number of rotations so that all...
null
Backtracking,Breadth-First Search
Medium
null
952
this problem involves finding the largest connected component in an undirected graph so it is one of the harder problems and it has been asked in google so here we have to build a graph and we are given some numbers and that edges are based on the common factors among different numbers so we will be given a bunch of di...
Largest Component Size by Common Factor
word-subsets
You are given an integer array of unique positive integers `nums`. Consider the following graph: * There are `nums.length` nodes, labeled `nums[0]` to `nums[nums.length - 1]`, * There is an undirected edge between `nums[i]` and `nums[j]` if `nums[i]` and `nums[j]` share a common factor greater than `1`. Return _t...
null
Array,Hash Table,String
Medium
null
630
hey what's up guys uh this is chung here again so this time today's daily challenge problem number 630 course schedule number three so you're given like n courses right from one to n and so each course has like two properties the first one is the duration of the course and the second one is the last day basically the d...
Course Schedule III
course-schedule-iii
There are `n` different online courses numbered from `1` to `n`. You are given an array `courses` where `courses[i] = [durationi, lastDayi]` indicate that the `ith` course should be taken **continuously** for `durationi` days and must be finished before or on `lastDayi`. You will start on the `1st` day and you cannot ...
During iteration, say I want to add the current course, currentTotalTime being total time of all courses taken till now, but adding the current course might exceed my deadline or it doesn’t. 1. If it doesn’t, then I have added one new course. Increment the currentTotalTime with duration of current course. 2. If it e...
Array,Greedy,Heap (Priority Queue)
Hard
207,210,2176
392
Hello guys welcome back to tech division in this video you will see the subsequent problem wishes from list from day 9 news room so let's no problem statement subscribe and subscribe the Channel Please subscribe and subscribe the Channel subscribe this Video subscribe relative subscribe and subscribe the In this case I...
Is Subsequence
is-subsequence
Given two strings `s` and `t`, return `true` _if_ `s` _is a **subsequence** of_ `t`_, or_ `false` _otherwise_. A **subsequence** of a string is a new string that is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (i...
null
Two Pointers,String,Dynamic Programming
Easy
808,1051
1,519
hello everyone welcome to another one of my lead code videos and this one we'll do today's daily challenge one five one nine number of nodes in the subtree with the same label so this input format is quite similar to the yesterday's Daily challenge so it'll pop up on the top right if you haven't checked that out go che...
Number of Nodes in the Sub-Tree With the Same Label
minimum-subsequence-in-non-increasing-order
You are given a tree (i.e. a connected, undirected graph that has no cycles) consisting of `n` nodes numbered from `0` to `n - 1` and exactly `n - 1` `edges`. The **root** of the tree is the node `0`, and each node of the tree has **a label** which is a lower-case character given in the string `labels` (i.e. The node w...
Sort elements and take each element from the largest until accomplish the conditions.
Array,Greedy,Sorting
Easy
2316
965
You guys don't know about Loot or about your suji so friend this is the platform which repairs you old track if you are a working professional or you are a student here but what do you mean these days there is a lot of There are so many hot websites in one movie that you are afraid of losing a job. The cheese seller sa...
Univalued Binary Tree
unique-email-addresses
A binary tree is **uni-valued** if every node in the tree has the same value. Given the `root` of a binary tree, return `true` _if the given tree is **uni-valued**, or_ `false` _otherwise._ **Example 1:** **Input:** root = \[1,1,1,1,1,null,1\] **Output:** true **Example 2:** **Input:** root = \[2,2,2,5,2\] **Outpu...
null
Array,Hash Table,String
Easy
null
165
welcome to september's leeco challenge today's problem is compare version numbers compare two version numbers version one and version two if version one is greater than version two return one if version one is less than version two return negative one otherwise if they're equal to one another return zero you may assume...
Compare Version Numbers
compare-version-numbers
Given two version numbers, `version1` and `version2`, compare them. Version numbers consist of **one or more revisions** joined by a dot `'.'`. Each revision consists of **digits** and may contain leading **zeros**. Every revision contains **at least one character**. Revisions are **0-indexed from left to right**, wit...
null
Two Pointers,String
Medium
null
1,036
Hello hello and welcome to this problem number 106 alarms election commission hands free problem no problem subscribe the channel subscribe I have taken nine wickets and in this absolutely free download folder is appointed something subscribe and subscribe the Channel subscribe and subscribe pada toh 1968 Damle Sirvi O...
Escape a Large Maze
rotting-oranges
There is a 1 million by 1 million grid on an XY-plane, and the coordinates of each grid square are `(x, y)`. We start at the `source = [sx, sy]` square and want to reach the `target = [tx, ty]` square. There is also an array of `blocked` squares, where each `blocked[i] = [xi, yi]` represents a blocked square with coor...
null
Array,Breadth-First Search,Matrix
Medium
286,2206
740
please observe if you want to be a hero please take a seat and learn this is 740 delete and earn okay so you're given an integer array nums seems simple you want to maximize the number of points you get by performing The Following operation any number of times all right you're going to pick a number num's eye for examp...
Delete and Earn
delete-and-earn
You are given an integer array `nums`. You want to maximize the number of points you get by performing the following operation any number of times: * Pick any `nums[i]` and delete it to earn `nums[i]` points. Afterwards, you must delete **every** element equal to `nums[i] - 1` and **every** element equal to `nums[i]...
If you take a number, you might as well take them all. Keep track of what the value is of the subset of the input with maximum M when you either take or don't take M.
Array,Hash Table,Dynamic Programming
Medium
198
122
hello everyone welcome to tic this is koshal and today we will be taking the second problem from buy and sell stock series best time to buy and sell stock too so let's see what the question has to say so just like the previous question we will be given an integer array of prices of stocks on different days now we need ...
Best Time to Buy and Sell Stock II
best-time-to-buy-and-sell-stock-ii
You are given an integer array `prices` where `prices[i]` is the price of a given stock on the `ith` day. On each day, you may decide to buy and/or sell the stock. You can only hold **at most one** share of the stock at any time. However, you can buy it then immediately sell it on the **same day**. Find and return _t...
null
Array,Dynamic Programming,Greedy
Medium
121,123,188,309,714
232
let's solve lead code 232 Implement Q using Stacks so the questions is that you need to implement stag uh you need to implement q a q is first in first out okay so the element that goes in first will be retrieved first all right and the operations that you need to enable is push which means adding an element to the que...
Implement Queue using Stacks
implement-queue-using-stacks
Implement a first in first out (FIFO) queue using only two stacks. The implemented queue should support all the functions of a normal queue (`push`, `peek`, `pop`, and `empty`). Implement the `MyQueue` class: * `void push(int x)` Pushes element x to the back of the queue. * `int pop()` Removes the element from th...
null
Stack,Design,Queue
Easy
225
402
hey what's up guys so Nick why idea Tecna coding stuff on Twitch in YouTube I haven't done a video in a while cuz I actually passed my technicals already but people have been saying they like them so I'm just gonna keep going with them and I think it's interesting anyway so I found this problem removed k digits hopeful...
Remove K Digits
remove-k-digits
Given string num representing a non-negative integer `num`, and an integer `k`, return _the smallest possible integer after removing_ `k` _digits from_ `num`. **Example 1:** **Input:** num = "1432219 ", k = 3 **Output:** "1219 " **Explanation:** Remove the three digits 4, 3, and 2 to form the new number 1219 which ...
null
String,Stack,Greedy,Monotonic Stack
Medium
321,738,1792,2305
949
uh hey everybody this is larry this is september 1st so the first day of the september league uh challenge i'm going to do this for the rest of the month uh yeah so hit the like button to subscribe one join me on discord and let me know what you think about these farms uh so my format is that usually i just solve these...
Largest Time for Given Digits
cat-and-mouse
Given an array `arr` of 4 digits, find the latest 24-hour time that can be made using each digit **exactly once**. 24-hour times are formatted as `"HH:MM "`, where `HH` is between `00` and `23`, and `MM` is between `00` and `59`. The earliest 24-hour time is `00:00`, and the latest is `23:59`. Return _the latest 24-h...
null
Math,Dynamic Programming,Breadth-First Search,Graph,Memoization,Game Theory
Hard
1727
208
today we will study about a very fundamental data structure called tri it's also called prefix tree and why it's called prefix tree we will see in a minute first why this name try so from what i know i it comes from the word retrieval so if you add vl in the end and are in the beginning this makes the word retrieval an...
Implement Trie (Prefix Tree)
implement-trie-prefix-tree
A [**trie**](https://en.wikipedia.org/wiki/Trie) (pronounced as "try ") or **prefix tree** is a tree data structure used to efficiently store and retrieve keys in a dataset of strings. There are various applications of this data structure, such as autocomplete and spellchecker. Implement the Trie class: * `Trie()` ...
null
Hash Table,String,Design,Trie
Medium
211,642,648,676,1433,1949
163
hello and welcome to another Elite code video So today we're going to be doing the problem of the week for this week and it's going to be missing ranges so you're given an inclusive integer range lower to Upper and assorted unique uh integer array nums where all the elements are within the links of range number X is co...
Missing Ranges
missing-ranges
You are given an inclusive range `[lower, upper]` and a **sorted unique** integer array `nums`, where all elements are in the inclusive range. A number `x` is considered **missing** if `x` is in the range `[lower, upper]` and `x` is not in `nums`. Return _the **smallest sorted** list of ranges that **cover every miss...
null
Array
Easy
228
529
quite a tough one five two nine means mine sweeper medium invert and uh if anyone remembers the mindsuper game you press on squares tiles within a square game and then you have to use the feedback in order to decide whether the you want to press on an adjacent square so uh if i um press click on a square then it will s...
Minesweeper
minesweeper
Let's play the minesweeper game ([Wikipedia](https://en.wikipedia.org/wiki/Minesweeper_(video_game)), [online game](http://minesweeperonline.com))! You are given an `m x n` char matrix `board` representing the game board where: * `'M'` represents an unrevealed mine, * `'E'` represents an unrevealed empty square, ...
null
Array,Depth-First Search,Breadth-First Search,Matrix
Medium
2206
68
everyone today i'm going to do lead code hard question 68 text justification this question is asking you if you are given a list of words with random length of words and give you a maximum width of each line's length then you should just then you want to return output that each line is justified given this max width so...
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
489
and welcome back to the cracking fang youtube channel today we're going to be solving leak code problem 489 robot roon cleaner before we do i would just like to kindly ask you to subscribe this channel is growing quickly and i need your support to grow it even bigger that way i can make more videos and reach more peopl...
Robot Room Cleaner
kth-smallest-instructions
You are controlling a robot that is located somewhere in a room. The room is modeled as an `m x n` binary grid where `0` represents a wall and `1` represents an empty slot. The robot starts at an unknown location in the room that is guaranteed to be empty, and you do not have access to the grid, but you can move the r...
There are nCr(row + column, row) possible instructions to reach (row, column). Try building the instructions one step at a time. How many instructions start with "H", and how does this compare with k?
Array,Math,Dynamic Programming,Combinatorics
Hard
null
73
welcome to lee coats blind created 75 where i'll be solving the top 75 lead code questions this question is called set matrix zeros here's the question uh given an m times n matrix if an element is zero set its entire row and column to zero do it in place basically if anything inside here is a zero we want to make all ...
Set Matrix Zeroes
set-matrix-zeroes
Given an `m x n` integer matrix `matrix`, if an element is `0`, set its entire row and column to `0`'s. You must do it [in place](https://en.wikipedia.org/wiki/In-place_algorithm). **Example 1:** **Input:** matrix = \[\[1,1,1\],\[1,0,1\],\[1,1,1\]\] **Output:** \[\[1,0,1\],\[0,0,0\],\[1,0,1\]\] **Example 2:** **In...
If any cell of the matrix has a zero we can record its row and column number using additional memory. But if you don't want to use extra memory then you can manipulate the array instead. i.e. simulating exactly what the question says. Setting cell values to zero on the fly while iterating might lead to discrepancies. ...
Array,Hash Table,Matrix
Medium
289,2244,2259,2314
1,618
Lut Sunavai Worry Question From Quote For A Ride 768 Who Is The Equation Of The Contest And Win Adherent Problem Statement Boss Was For Us So They Are Of Positive And Tears And Need To Choose Any Positive Interior Dip A Knotted All The Elements Of Adventure Divisible Indian And world multiple of D that with red color a...
Maximum Font to Fit a Sentence in a Screen
delete-n-nodes-after-m-nodes-of-a-linked-list
You are given a string `text`. We want to display `text` on a screen of width `w` and height `h`. You can choose any font size from array `fonts`, which contains the available font sizes **in ascending order**. You can use the `FontInfo` interface to get the width and height of any character at any available font size...
Traverse the Linked List, each time you need to delete the next n nodes connect the nodes previous deleting with the next node after deleting.
Linked List
Easy
19,1267
74
Hello Everyone Welcome America Rest Channel Suggestion Or Their Discuss Drama Problem Research And Chin Matrix Right In Addition Algorithm Till Sources For Value Target In Impress Increase The Matrix 210 The Matrix Is The Calling Properties Subha See Amazing When And Where You Will Give Winners To Find The Value Is The...
Search a 2D Matrix
search-a-2d-matrix
You are given an `m x n` integer matrix `matrix` with the following two properties: * Each row is sorted in non-decreasing order. * The first integer of each row is greater than the last integer of the previous row. Given an integer `target`, return `true` _if_ `target` _is in_ `matrix` _or_ `false` _otherwise_. ...
null
Array,Binary Search,Matrix
Medium
240
886
Open it and wait in the morning. Possible by partition that we will get some number in it. We got it and it tells us that we will have 4% and we and it tells us that we will have 4% and we and it tells us that we will have 4% and we will get this one like share. So what do we have to do? We got some of your money. Diff...
Possible Bipartition
score-of-parentheses
We want to split a group of `n` people (labeled from `1` to `n`) into two groups of **any size**. Each person may dislike some other people, and they should not go into the same group. Given the integer `n` and the array `dislikes` where `dislikes[i] = [ai, bi]` indicates that the person labeled `ai` does not like the...
null
String,Stack
Medium
null
1,493
hello everyone today we're gonna be talking about liquor problem in 1493 longest submarines after deleting one element so this problem you know conceptually is I think pretty straightforward we have an array of ones and maybe other numbers and we need to find a position to delete such that we end up with the longest st...
Longest Subarray of 1's After Deleting One Element
frog-position-after-t-seconds
Given a binary array `nums`, you should delete one element from it. Return _the size of the longest non-empty subarray containing only_ `1`_'s in the resulting array_. Return `0` if there is no such subarray. **Example 1:** **Input:** nums = \[1,1,0,1\] **Output:** 3 **Explanation:** After deleting the number in pos...
Use a variation of DFS with parameters 'curent_vertex' and 'current_time'. Update the probability considering to jump to one of the children vertices.
Tree,Depth-First Search,Breadth-First Search,Graph
Hard
null
1,743
and let's solve the today's lead code challenge which is restore the array from adjacent pair so here in this problem we have to form an array from the adjacent pairs which are given to us let's try to understand this problem further so here uh let's say we are given all the pairs adjacent pair from an array so if we t...
Restore the Array From Adjacent Pairs
count-substrings-that-differ-by-one-character
There is an integer array `nums` that consists of `n` **unique** elements, but you have forgotten it. However, you do remember every pair of adjacent elements in `nums`. You are given a 2D integer array `adjacentPairs` of size `n - 1` where each `adjacentPairs[i] = [ui, vi]` indicates that the elements `ui` and `vi` a...
Take every substring of s, change a character, and see how many substrings of t match that substring. Use a Trie to store all substrings of t as a dictionary.
Hash Table,String,Dynamic Programming
Medium
2256
588
hello and welcome back to the cracking fang youtube channel today we're going to be solving lead code problem 588 design in memory file system design a data structure that simulates as an in memory file system you'll be implementing the file system class which the file system initializes the object of the system you'll...
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
3
hey everyone so today i'm going to be doing the codes uh problem number three longest substring without repeating characters um given a string s find the length of the longest substring without repeating characters pretty simple i think they give you an input string here and which has multiple duplicate characters um o...
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
109
hey folks welcome back to another video today we're looking at question 109 convert sorted list to my research tree the way we'll be approaching this problem is by using recursion so uh if you look at this example right here you know that the base case would be to find the head of that particular and particular binary ...
Convert Sorted List to Binary Search Tree
convert-sorted-list-to-binary-search-tree
Given the `head` of a singly linked list where elements are sorted in **ascending order**, convert _it to a_ **_height-balanced_** _binary search tree_. **Example 1:** **Input:** head = \[-10,-3,0,5,9\] **Output:** \[0,-3,9,-10,null,5\] **Explanation:** One possible answer is \[0,-3,9,-10,null,5\], which represents t...
null
Linked List,Divide and Conquer,Tree,Binary Search Tree,Binary Tree
Medium
108,2306
83
hey guys persistent programmer here and welcome to my channel so in this channel we solve a lot of algorithms so if you haven't subscribed already go ahead and hit the subscribe button below this video and give this video a thumbs up if you like it without any further ado let's go ahead and look at today's question awe...
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
203
Hello gas welcome to my youtube channel code question they have to remove link list elements and their information about the question is they have bin given d head of d link list and wait value of d link list date has no value and return d new head So what do we have to do in this Van Tu Six Three Four Five Six What do...
Remove Linked List Elements
remove-linked-list-elements
Given the `head` of a linked list and an integer `val`, remove all the nodes of the linked list that has `Node.val == val`, and return _the new head_. **Example 1:** **Input:** head = \[1,2,6,3,4,5,6\], val = 6 **Output:** \[1,2,3,4,5\] **Example 2:** **Input:** head = \[\], val = 1 **Output:** \[\] **Example 3:**...
null
Linked List,Recursion
Easy
27,237,2216
392
hi there welcome to my Channel today we're going to explore the lead code question is subsequence a subsequence of a string is a new string that is formed from the original string by deleting some of the characters without disturbing the relative positions of remaining characters in this problem we are given two string...
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
40
looking at lead code number 40. it's a question called combination sum2 and i highly recommend looking at the other videos combination sum and combination sum 3. my advice is to go from combination sum three to two to one we're gonna be using a template a backtracking template to solve this problem as well as all other...
Combination Sum II
combination-sum-ii
Given a collection of candidate numbers (`candidates`) and a target number (`target`), find all unique combinations in `candidates` where the candidate numbers sum to `target`. Each number in `candidates` may only be used **once** in the combination. **Note:** The solution set must not contain duplicate combinations....
null
Array,Backtracking
Medium
39
1,339
Hi gas welcome and welcome back to my channel so today our problem is maximum product of splitted mind return so what have we given in this problem statement, here we have been given a mind tree and what we have to do is split this binary tree. It is okay to do this in two sub trees so that we can find the sum of both ...
Maximum Product of Splitted Binary Tree
team-scores-in-football-tournament
Given the `root` of a binary tree, split the binary tree into two subtrees by removing one edge such that the product of the sums of the subtrees is maximized. Return _the maximum product of the sums of the two subtrees_. Since the answer may be too large, return it **modulo** `109 + 7`. **Note** that you need to max...
null
Database
Medium
null
1,642
That hey guys welcome back to my channel today going to discuss nad problem hai for this building you can e 119 problem this given and are hybrid present in the height of buildings some vriksha and mallas to vaikuntha problem this pimple setting Height Of Between Building And Bricks And Letters Busy You Start Your Jour...
Furthest Building You Can Reach
water-bottles
You are given an integer array `heights` representing the heights of buildings, some `bricks`, and some `ladders`. You start your journey from building `0` and move to the next building by possibly using bricks or ladders. While moving from building `i` to building `i+1` (**0-indexed**), * If the current building'...
Simulate the process until there are not enough empty bottles for even one full bottle of water.
Math,Simulation
Easy
null
1,675
hello everyone welcome to our channel code with sunny and in this video we will be talking about the problem minimize deviation in an array its index is one six seven five and it is the heart problem of the lead code right so yeah so before moving on let's discuss the concepts that is being involved in this problem lik...
Minimize Deviation in Array
magnetic-force-between-two-balls
You are given an array `nums` of `n` positive integers. You can perform two types of operations on any element of the array any number of times: * If the element is **even**, **divide** it by `2`. * For example, if the array is `[1,2,3,4]`, then you can do this operation on the last element, and the array wil...
If you can place balls such that the answer is x then you can do it for y where y < x. Similarly if you cannot place balls such that the answer is x then you can do it for y where y > x. Binary search on the answer and greedily see if it is possible.
Array,Binary Search,Sorting
Medium
2188
616
hello and welcome back to the cracking fan YouTube channel today we're going to be solving lead code problem 616 add bold tag in string before we get into the video just want to ask you guys to kindly like and comment on the video it helps me out a ton with the YouTube algorithm And subscribe to the channel so I keep g...
Add Bold Tag in String
add-bold-tag-in-string
You are given a string `s` and an array of strings `words`. You should add a closed pair of bold tag **and** to wrap the substrings in `s` that exist in `words`. * If two such substrings overlap, you should wrap them together with only one pair of closed bold-tag. * If two substrings wrapped by bold tags are cons...
null
Array,Hash Table,String,Trie,String Matching
Medium
56,591
125
another day another problem so let's Solve IT hello guys I hope everything is going well for you all in this video I will show you how to solve the valid palindrome problem I will try to solve it in as many different way as I can but keep in mind that there is no limit so let's read the problem and write down the impor...
Valid Palindrome
valid-palindrome
A phrase is a **palindrome** if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. Alphanumeric characters include letters and numbers. Given a string `s`, return `true` _if it is a **palindrome**, or_ `false` _otherwise_...
null
Two Pointers,String
Easy
234,680,2130,2231
1,647
hello everyone welcome back here is van damson and today we got a really interesting program from a little daily challenge uh that will uh going to help us understand algorithm and data structure so the problem we are tackling today is minimum deletion of uh yeah to make a character frequency unique and we are solving ...
Minimum Deletions to Make Character Frequencies Unique
can-convert-string-in-k-moves
A string `s` is called **good** if there are no two different characters in `s` that have the same **frequency**. Given a string `s`, return _the **minimum** number of characters you need to delete to make_ `s` _**good**._ The **frequency** of a character in a string is the number of times it appears in the string. F...
Observe that shifting a letter x times has the same effect of shifting the letter x + 26 times. You need to check whether k is large enough to cover all shifts with the same remainder after modulo 26.
Hash Table,String
Medium
null
1,436
See, in this video we are going to ask a question. Lead code is 1436. Ad Destination City Description. Whatever it is, we will see it later. Donkey is written. Let's skip it. Let me explain to you. This is a simple question, there is no rocket science in it. He is saying that you will be given an LED, or say a list of ...
Destination City
get-watched-videos-by-your-friends
You are given the array `paths`, where `paths[i] = [cityAi, cityBi]` means there exists a direct path going from `cityAi` to `cityBi`. _Return the destination city, that is, the city without any path outgoing to another city._ It is guaranteed that the graph of paths forms a line without any loop, therefore, there wil...
Do BFS to find the kth level friends. Then collect movies saw by kth level friends and sort them accordingly.
Array,Hash Table,Breadth-First Search,Sorting
Medium
null
46
if you're studying for coding interviews you've got to know backtracking we can use backtracking to solve the permutation problem where you have all possible orderings of a list of numbers let's generate all permutations of 1 2 3 the first number could be either 1 2 or three then if we picked one as the first number yo...
Permutations
permutations
Given an array `nums` of distinct integers, return _all the possible permutations_. You can return the answer in **any order**. **Example 1:** **Input:** nums = \[1,2,3\] **Output:** \[\[1,2,3\],\[1,3,2\],\[2,1,3\],\[2,3,1\],\[3,1,2\],\[3,2,1\]\] **Example 2:** **Input:** nums = \[0,1\] **Output:** \[\[0,1\],\[1,0\...
null
Array,Backtracking
Medium
31,47,60,77
741
my brain sprays like an AK carried in a stick up this is 741 Cherry pickup okay this is an extremely difficult problem um if you reach read some of the discussion posts and comments associated with this problem people argue there should be a different tier that this problem exclusively exists on right because right now...
Cherry Pickup
cherry-pickup
You are given an `n x n` `grid` representing a field of cherries, each cell is one of three possible integers. * `0` means the cell is empty, so you can pass through, * `1` means the cell contains a cherry that you can pick up and pass through, or * `-1` means the cell contains a thorn that blocks your way. Ret...
null
Array,Dynamic Programming,Matrix
Hard
64,174,2189
139
hey everyone welcome back and let's write some more neat code today so today let's solve the problem word break so we're given an input string and a dictionary of strings called word dict and we want to return true if and only if s can be broken up into separate strings such that every separate string in s is also foun...
Word Break
word-break
Given a string `s` and a dictionary of strings `wordDict`, return `true` if `s` can be segmented into a space-separated sequence of one or more dictionary words. **Note** that the same word in the dictionary may be reused multiple times in the segmentation. **Example 1:** **Input:** s = "leetcode ", wordDict = \[ "...
null
Hash Table,String,Dynamic Programming,Trie,Memoization
Medium
140
77
foreign School combinations we are given two integers n and K and we have to return all possible communication combinations of K so we can choose uh K elements K numbers from the range one to n and we can return the answer in any order so for example if we have n equal to 4 we can choose from elements starting from 1 u...
Combinations
combinations
Given two integers `n` and `k`, return _all possible combinations of_ `k` _numbers chosen from the range_ `[1, n]`. You may return the answer in **any order**. **Example 1:** **Input:** n = 4, k = 2 **Output:** \[\[1,2\],\[1,3\],\[1,4\],\[2,3\],\[2,4\],\[3,4\]\] **Explanation:** There are 4 choose 2 = 6 total combin...
null
Backtracking
Medium
39,46
6
hey what's up guys babybear4812 coming at you once again today we are going to be solving the zigzag conversion problem that's problem number six on leap code um if you haven't tried it yet pause the video give it a try come on right back but for those of you that have um this problem's got quite a few down votes i do ...
Zigzag Conversion
zigzag-conversion
The string `"PAYPALISHIRING "` is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N A P L S I I G Y I R And then read line by line: `"PAHNAPLSIIGYIR "` Write the code that will take a string and make this co...
null
String
Medium
null
2
so this is a medium leak code problem add two numbers so basically they're giving us two linked lists with integers non-negative linked lists with integers non-negative linked lists with integers non-negative and they both will be non-empty so we and they both will be non-empty so we and they both will be non-empty so ...
Add Two Numbers
add-two-numbers
You are given two **non-empty** linked lists representing two non-negative integers. The digits are stored in **reverse order**, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list. You may assume the two numbers do not contain any leading zero, except the number 0 ...
null
Linked List,Math,Recursion
Medium
43,67,371,415,445,1031,1774