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,857
Hello everyone welcome tu d channel today chala ki ksi note01 connect hai zero tu se connect hai tu three se hai 347 and this gives us a string named colors what is its significance zero is the color of one note is zero index The color that is on the zero indicates the color of one note. The color that is that index of...
Largest Color Value in a Directed Graph
largest-color-value-in-a-directed-graph
There is a **directed graph** of `n` colored nodes and `m` edges. The nodes are numbered from `0` to `n - 1`. You are given a string `colors` where `colors[i]` is a lowercase English letter representing the **color** of the `ith` node in this graph (**0-indexed**). You are also given a 2D array `edges` where `edges[j]...
null
null
Hard
null
1,022
Allah universe hop ivygel Slime body Justice ribbon Challenge usamo frutteto fiber program cold mu de soda you talk to Adana old man Nuri's 4reasons arranged and normal bread Sena prot a How do you have a A7 Samsung Galaxy ziro One Zira the actor and the other of my father ziros oy lo lo o friend Nur from different pla...
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
334
Hello gas, so how are you guys about the question number 334 of welcome back, which is increasing triplet sequence, okay, yes, the question of midi is good, special like, it is good, honey is okay, you will get to learn either, the question will be fair easy, like in the beginning. It will seem complicated, then it wil...
Increasing Triplet Subsequence
increasing-triplet-subsequence
Given an integer array `nums`, return `true` _if there exists a triple of indices_ `(i, j, k)` _such that_ `i < j < k` _and_ `nums[i] < nums[j] < nums[k]`. If no such indices exists, return `false`. **Example 1:** **Input:** nums = \[1,2,3,4,5\] **Output:** true **Explanation:** Any triplet where i < j < k is valid. ...
null
Array,Greedy
Medium
300,2122,2280
151
hey everybody this is Larry this is day 12 of delete code daily challenge hit the like button oh no extra points hit the like button hit the Subscribe button join me on Discord let me know what you think about today's contest or today's problem matter um reverse words on it reverse words on a string um I'm gonna take a...
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
43
hello everyone today we are going to solve read code problem 43 which is multiply strings so in this problem here we have been given two integers uh number one and number two which in which both are strings and we need to convert them to we need to multiply them and we need to return them back as a string so and also i...
Multiply Strings
multiply-strings
Given two non-negative integers `num1` and `num2` represented as strings, return the product of `num1` and `num2`, also represented as a string. **Note:** You must not use any built-in BigInteger library or convert the inputs to integer directly. **Example 1:** **Input:** num1 = "2", num2 = "3" **Output:** "6" **Ex...
null
Math,String,Simulation
Medium
2,66,67,415
378
um hello so today we are going to do this problem which is part of august theory challenge um so k smallest element in a sorted matrix the problem says we have an n by n matrix um and each of the rows and columns is sorted in ascending order right and we what we want is to return the kth smallest element in the matrix ...
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
415
okay let's talk about add string so you're given two string in nums one and nums two right and you're adding and you're going to return the sum of them so you're not allowed to convert to integer and let's talk about the idea so i'm going to start from the back and then to the front and when i you put a carry to the ch...
Add Strings
add-strings
Given two non-negative integers, `num1` and `num2` represented as string, return _the sum of_ `num1` _and_ `num2` _as a string_. You must solve the problem without using any built-in library for handling large integers (such as `BigInteger`). You must also not convert the inputs to integers directly. **Example 1:** ...
null
Math,String,Simulation
Easy
2,43,1031
1,963
hello everyone this is the lead code problem minimum number of swaps to make the string balanced you're given the strain of even length the string consists of exactly half opening brackets and half closing brackets a string is called balanced if and only if it is the empty string or it can be written as a b where both ...
Minimum Number of Swaps to Make the String Balanced
find-xor-sum-of-all-pairs-bitwise-and
You are given a **0-indexed** string `s` of **even** length `n`. The string consists of **exactly** `n / 2` opening brackets `'['` and `n / 2` closing brackets `']'`. A string is called **balanced** if and only if: * It is the empty string, or * It can be written as `AB`, where both `A` and `B` are **balanced** s...
Think about (a&b) ^ (a&c). Can you simplify this expression? It is equal to a&(b^c). Then, (arr1[i]&arr2[0])^(arr1[i]&arr2[1]).. = arr1[i]&(arr2[0]^arr2[1]^arr[2]...). Let arr2XorSum = (arr2[0]^arr2[1]^arr2[2]...), arr1XorSum = (arr1[0]^arr1[1]^arr1[2]...) so the final answer is (arr2XorSum&arr1[0]) ^ (arr2XorSum&arr1[...
Array,Math,Bit Manipulation
Hard
null
368
today we're gonna be working on read code question number 368 largest divisible subset okay given a set of testing positive integers nums are written the largest and a subset answer such that every pair answer of i and answer of j of elements in this subset satisfies this condition where one module modulus of another i...
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
78
in this problem we will see a very mathematical uh problem it's called finding the power set of a given set so what is meant by power set uh it means that if you are given a set of some numbers then you have to find all possible subsets that can be created from the elements of the given set and the set of all those sub...
Subsets
subsets
Given an integer array `nums` of **unique** elements, 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,3\] **Output:** \[\[\],\[1\],\[2\],\[1,2\],\[3\],\[1,3\],\[2,3\],\[1,2,3\]\] ...
null
Array,Backtracking,Bit Manipulation
Medium
90,320,800,2109,2170
264
Hello Everyone and Welcome Back to my Channel Algorithm Hq Today I am going to write the code and also explain to you all the algorithm to solve this next number two problem which is there in lead code it is a medium level problem and can be solved using A Priority Why and a Greedy Algorithm We are going to solve it us...
Ugly Number II
ugly-number-ii
An **ugly number** is a positive integer whose prime factors are limited to `2`, `3`, and `5`. Given an integer `n`, return _the_ `nth` _**ugly number**_. **Example 1:** **Input:** n = 10 **Output:** 12 **Explanation:** \[1, 2, 3, 4, 5, 6, 8, 9, 10, 12\] is the sequence of the first 10 ugly numbers. **Example 2:** ...
The naive approach is to call isUgly for every number until you reach the nth one. Most numbers are not ugly. Try to focus your effort on generating only the ugly ones. An ugly number must be multiplied by either 2, 3, or 5 from a smaller ugly number. The key is how to maintain the order of the ugly numbers. Try a simi...
Hash Table,Math,Dynamic Programming,Heap (Priority Queue)
Medium
23,204,263,279,313,1307
31
hey everyone welcome back to the channel I hope you guys are doing extremely well so this is another video from the stripers A to Z DSA course just in case here for the first time here this is world's most in-depth course when it world's most in-depth course when it world's most in-depth course when it comes to DSL tho...
Next Permutation
next-permutation
A **permutation** of an array of integers is an arrangement of its members into a sequence or linear order. * For example, for `arr = [1,2,3]`, the following are all the permutations of `arr`: `[1,2,3], [1,3,2], [2, 1, 3], [2, 3, 1], [3,1,2], [3,2,1]`. The **next permutation** of an array of integers is the next le...
null
Array,Two Pointers
Medium
46,47,60,267,1978
215
what's up everybody although here and welcome back to yet another youtube video in today's video we'll be solving another medium level lead code problem number 215 also called as eighth largest elements in an array now we'll be solving this with the help of two methods one is with the brute force that is sorting and ot...
Kth Largest Element in an Array
kth-largest-element-in-an-array
Given an integer array `nums` and an integer `k`, return _the_ `kth` _largest element in the array_. Note that it is the `kth` largest element in the sorted order, not the `kth` distinct element. You must solve it in `O(n)` time complexity. **Example 1:** **Input:** nums = \[3,2,1,5,6,4\], k = 2 **Output:** 5 **Ex...
null
Array,Divide and Conquer,Sorting,Heap (Priority Queue),Quickselect
Medium
324,347,414,789,1014,2113,2204,2250
1
this is Leap code question one the two sum problem now this is a classic problem and there's a reason why this is the first uh in the leak code list and that's because we can solve this intuitively firstly but then we'll come across a core approach which might not be obvious at first so given an array of integers nums ...
Two Sum
two-sum
Given an array of integers `nums` and an integer `target`, return _indices of the two numbers such that they add up to `target`_. You may assume that each input would have **_exactly_ one solution**, and you may not use the _same_ element twice. You can return the answer in any order. **Example 1:** **Input:** nums...
A really brute force way would be to search for all possible pairs of numbers but that would be too slow. Again, it's best to try out brute force solutions for just for completeness. It is from these brute force solutions that you can come up with optimizations. So, if we fix one of the numbers, say x, we have to scan ...
Array,Hash Table
Easy
15,18,167,170,560,653,1083,1798,1830,2116,2133,2320
1,094
Jhaal Hello Hi Guys Welcome To Dad Today's Question Is Car Pulling In This Question Or Driving Michael Phelps Easily Available For Passengers Divide Kar Lu Drives Us Towards East Subscribe And Content Information if you liked The Video then subscribe to the Video then subscribe to subscribe our Of all passenger is all ...
Car Pooling
matrix-cells-in-distance-order
There is a car with `capacity` empty seats. The vehicle only drives east (i.e., it cannot turn around and drive west). You are given the integer `capacity` and an array `trips` where `trips[i] = [numPassengersi, fromi, toi]` indicates that the `ith` trip has `numPassengersi` passengers and the locations to pick them u...
null
Array,Math,Geometry,Sorting,Matrix
Easy
2304
105
hey what's up guys uh this is chum here so this time today's daily challenge problem uh number 105 construct binary tree from pre-order 105 construct binary tree from pre-order 105 construct binary tree from pre-order a new other traversal very classic tree problem right i think everyone knows what is the pre-order and...
Construct Binary Tree from Preorder and Inorder Traversal
construct-binary-tree-from-preorder-and-inorder-traversal
Given two integer arrays `preorder` and `inorder` where `preorder` is the preorder traversal of a binary tree and `inorder` is the inorder traversal of the same tree, construct and return _the binary tree_. **Example 1:** **Input:** preorder = \[3,9,20,15,7\], inorder = \[9,3,15,20,7\] **Output:** \[3,9,20,null,null,...
null
Array,Hash Table,Divide and Conquer,Tree,Binary Tree
Medium
106
1,287
Hello friends welcome to a new video in this video I am going to discuss a array based problem okay it is a lead code problem okay so what is problem is saying to you let's see so we have to find out the element appearing more than 25 percent assorted array means a Aries given to us and the array is in sorted order oka...
Element Appearing More Than 25% In Sorted Array
distance-between-bus-stops
Given an integer array **sorted** in non-decreasing order, there is exactly one integer in the array that occurs more than 25% of the time, return that integer. **Example 1:** **Input:** arr = \[1,2,2,6,6,6,6,7,10\] **Output:** 6 **Example 2:** **Input:** arr = \[1,1\] **Output:** 1 **Constraints:** * `1 <= arr...
Find the distance between the two stops if the bus moved in clockwise or counterclockwise directions.
Array
Easy
null
116
okay hi everyone welcome to the solution of another lead code problem so today we are going to solve a problem related to binary trees the problem name is populating next right pointers in each node so let's go through the problem once so you are given a perfect binary tree where all the leaves are on the same level an...
Populating Next Right Pointers in Each Node
populating-next-right-pointers-in-each-node
You are given a **perfect binary tree** where all leaves are on the same level, and every parent has two children. The binary tree has the following definition: struct Node { int val; Node \*left; Node \*right; Node \*next; } Populate each next pointer to point to its next right node. If there is no next righ...
null
Linked List,Tree,Depth-First Search,Breadth-First Search,Binary Tree
Medium
117,199
1,630
lead code 1630 arithmetic subarrays 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 or formul a sequence is arithmetic if and only if s i + 1 - s i = s of 1 - if and only if s i + 1 - s i = s of 1 - if and only if s...
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
1,823
Hello Everyone Today By Solving Dil Weekly Contest Problem With This Cross Very Interesting Places Is For The Sharing Solution This Question Of Death Is The Winner Of Circular Game Play Revolving Chair And Subscribe 12345 Every Element Will Be Eliminated Waste Oil Filter Element Subscribe Don't forget the under-14 hydr...
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
997
hey guys welcome to a new video in today's video we're going to look at a leite code problem and the problem's name is find the town judge so in this question we are given n which represents the number of people and these people are labed from 1 through n and there is a rumor that one of these people is secretly the to...
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
114
hello friends welcome to tech grants today's problem is flattened binary tree to linked list so here we are given a binary tree and we need to flatten it to a linked list in space so we don't need to create a linked list here only thing we need to do is we need to put everything towards the right pointer of the tree so...
Flatten Binary Tree to Linked List
flatten-binary-tree-to-linked-list
Given the `root` of a binary tree, flatten the tree into a "linked list ": * The "linked list " should use the same `TreeNode` class where the `right` child pointer points to the next node in the list and the `left` child pointer is always `null`. * The "linked list " should be in the same order as a [**pre-order*...
If you notice carefully in the flattened tree, each node's right child points to the next node of a pre-order traversal.
Linked List,Stack,Tree,Depth-First Search,Binary Tree
Medium
766,1796
94
before starting this video i'd love to thank releval for sponsoring this entire tree series did you know that companies like google apple starbucks are now hiring people without any degree or experience why because they believe that skills are more important than anything else the top companies in india like the top st...
Binary Tree Inorder Traversal
binary-tree-inorder-traversal
Given the `root` of a binary tree, return _the inorder traversal of its nodes' values_. **Example 1:** **Input:** root = \[1,null,2,3\] **Output:** \[1,3,2\] **Example 2:** **Input:** root = \[\] **Output:** \[\] **Example 3:** **Input:** root = \[1\] **Output:** \[1\] **Constraints:** * The number of nodes i...
null
Stack,Tree,Depth-First Search,Binary Tree
Easy
98,144,145,173,230,272,285,758,799
336
thank you hey everybody this is Larry this is day 17 of the Lego day challenge hit the like button hit the Subscribe button drop me on Discord no extra coins really uh let me know what you think about today's form pattern drum appears hope you liked the intro I'm still in Dublin for maybe a day or two can't do the math...
Palindrome Pairs
palindrome-pairs
You are given a **0-indexed** array of **unique** strings `words`. A **palindrome pair** is a pair of integers `(i, j)` such that: * `0 <= i, j < words.length`, * `i != j`, and * `words[i] + words[j]` (the concatenation of the two strings) is a palindrome. Return _an array of all the **palindrome pairs** of_ `...
null
Array,Hash Table,String,Trie
Hard
5,214,2237
143
hello welcome to my channel i'm here to do my 100 lego challenge today we have leeco 143 reorder list let's take a look at that uh question giving a singly language else l zero one two all the way n minus one and l n so we order this to l zero and one n minus one two n minus 2 and go on you may not modify the value by ...
Reorder List
reorder-list
You are given the head of a singly linked-list. The list can be represented as: L0 -> L1 -> ... -> Ln - 1 -> Ln _Reorder the list to be on the following form:_ L0 -> Ln -> L1 -> Ln - 1 -> L2 -> Ln - 2 -> ... You may not modify the values in the list's nodes. Only nodes themselves may be changed. **Example 1:** **...
null
Linked List,Two Pointers,Stack,Recursion
Medium
2216
171
in this problem we have to convert a given excel column to a column number so here let's say if we are given a then we have to convert to 1 z then we have to convert to 26 then a comes so if a is given we will return 27 and so on so there was one another problem where we had done the reverse of this so we were given an...
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
380
welcome to in this video the problem insert random so let's look into the problem so we need to design a data structure that supports all following operations in or one time so we need to insert a value in one time we need to remove a value involve one time and there is also a method called get random and we need to ge...
Insert Delete GetRandom O(1)
insert-delete-getrandom-o1
Implement the `RandomizedSet` class: * `RandomizedSet()` Initializes the `RandomizedSet` object. * `bool insert(int val)` Inserts an item `val` into the set if not present. Returns `true` if the item was not present, `false` otherwise. * `bool remove(int val)` Removes an item `val` from the set if present. Retur...
null
Array,Hash Table,Math,Design,Randomized
Medium
381
459
hello everyone welcome back here is vanamsen with another live coding session so if you are into go and you love a good challenge stick around because today we are diving uh into enchanting string manipulation problem from Lady code repeated substring pattern and if you are new to the channel hit the Subscribe button a...
Repeated Substring Pattern
repeated-substring-pattern
Given a string `s`, check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. **Example 1:** **Input:** s = "abab " **Output:** true **Explanation:** It is the substring "ab " twice. **Example 2:** **Input:** s = "aba " **Output:** false **Example 3:** ...
null
String,String Matching
Easy
28,686
225
hey guys welcome back to helper function in this video we will discuss another popular interview question implement stack using queues so the problem statement says that we need to implement the following operations of a stack using queues push x that will push element x onto the stack pop that removes the element from...
Implement Stack using Queues
implement-stack-using-queues
Implement a last-in-first-out (LIFO) stack using only two queues. The implemented stack should support all the functions of a normal stack (`push`, `top`, `pop`, and `empty`). Implement the `MyStack` class: * `void push(int x)` Pushes element x to the top of the stack. * `int pop()` Removes the element on the top...
null
Stack,Design,Queue
Easy
232
73
hello everyone my name is alvro and in this video i will be solving another problem from the blind lead code 75 problems list today i will be doing problem number 73 which is called set matrix zeros and i think this is a fairly tricky problem in one of the approaches that we're going to discuss in this problem so yeah ...
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
88
Hi, so this is our first problem, it is sorted and this is the first question of 150 questions and it is marked easy. Okay, so basically, give us numbers in this, two, we have arranged in this. Okay Nav and Two both are sorted. Okay, in this we have to print the final result. We have to print the result of these which ...
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
1,180
uh so this questions come sub string with only one distinct letter so you giv str s and then basically um the option you have are consider same dat and then you want to count how many time it uh it occurs so uh let's look at this so a you can have I mean when you add this position you have a when you at this position y...
Count Substrings with Only One Distinct Letter
game-play-analysis-ii
Given a string `s`, return _the number of substrings that have only **one distinct** letter_. **Example 1:** **Input:** s = "aaaba " **Output:** 8 **Explanation:** The substrings with one distinct letter are "aaa ", "aa ", "a ", "b ". "aaa " occurs 1 time. "aa " occurs 2 times. "a " occurs 4 times. "b " occu...
null
Database
Easy
1179,1181
901
let's see the problem 901 unless talks and desire algorithm that clock collects daily price quotes for some stock and Returns the span of the Stock's price for the current day the span of the Stock's price in one day is the maximum number of the constructive days starting from that state and going backward for we re wh...
Online Stock Span
advantage-shuffle
Design an algorithm that collects daily price quotes for some stock and returns **the span** of that stock's price for the current day. The **span** of the stock's price in one day is the maximum number of consecutive days (starting from that day and going backward) for which the stock price was less than or equal to ...
null
Array,Greedy,Sorting
Medium
null
1,189
hello everyone in this lecture i am going to explain you about maximum number of balloons given a string text you want to use the characters of text to form as many instances of the word below as possible you can use each character in text at most once written the maximum number of instances that can be formed so here ...
Maximum Number of Balloons
encode-number
Given a string `text`, you want to use the characters of `text` to form as many instances of the word **"balloon "** as possible. You can use each character in `text` **at most once**. Return the maximum number of instances that can be formed. **Example 1:** **Input:** text = "nlaebolko " **Output:** 1 **Example 2...
Try to find the number of binary digits returned by the function. The pattern is to start counting from zero after determining the number of binary digits.
Math,String,Bit Manipulation
Medium
1070
258
hello guys welcome back today we are going to understand the lead code question right and so let's understand today question we have is uh add digits right 250 uh 258 right and we are going to understand this question so to understand this question give me one second right what do we have to do actually okay so to unde...
Add Digits
add-digits
Given an integer `num`, repeatedly add all its digits until the result has only one digit, and return it. **Example 1:** **Input:** num = 38 **Output:** 2 **Explanation:** The process is 38 --> 3 + 8 --> 11 11 --> 1 + 1 --> 2 Since 2 has only one digit, return it. **Example 2:** **Input:** num = 0 **Output:** 0 *...
A naive implementation of the above process is trivial. Could you come up with other methods? What are all the possible results? How do they occur, periodically or randomly? You may find this Wikipedia article useful.
Math,Simulation,Number Theory
Easy
202,1082,2076,2264
994
to do is um you can think of these directions as starting from the point of origin right so this will be negative one will be um a displacement to the left uh this would be right this will be down and this will be up so basically that is the idea i should think about right so the next thing we need to do is we need to ...
Rotting Oranges
prison-cells-after-n-days
You are given an `m x n` `grid` where each cell can have one of three values: * `0` representing an empty cell, * `1` representing a fresh orange, or * `2` representing a rotten orange. Every minute, any fresh orange that is **4-directionally adjacent** to a rotten orange becomes rotten. Return _the minimum nu...
null
Array,Hash Table,Math,Bit Manipulation
Medium
null
687
hello and welcome back to the cracking Fang YouTube channel today we're solving lead code problem 687 longest uni value path given the root of a binary tree return the length of the longest path where each node in the path has the same value this path may or may not pass through the root the length of the path between ...
Longest Univalue Path
longest-univalue-path
Given the `root` of a binary tree, return _the length of the longest path, where each node in the path has the same value_. This path may or may not pass through the root. **The length of the path** between two nodes is represented by the number of edges between them. **Example 1:** **Input:** root = \[5,4,5,1,1,nul...
null
Tree,Depth-First Search,Binary Tree
Medium
124,250,437
368
The question of Largest divisible subset lead code is, first of all read its problem statement, before that those who want to see only quick solution can go to quick solution according to time stamp and I explained the solution quickly within two minutes or three minutes there. But you can go and see it and for those w...
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
138
hey guys welcome back to this video now we're going to solve a coding interview problem copy list with random pointer this is going to be linked list problem a linked list is given such that each node contains an additional random pointer which could point to any node in the list or null we have to written a deep copy ...
Copy List with Random Pointer
copy-list-with-random-pointer
A linked list of length `n` is given such that each node contains an additional random pointer, which could point to any node in the list, or `null`. Construct a [**deep copy**](https://en.wikipedia.org/wiki/Object_copying#Deep_copy) of the list. The deep copy should consist of exactly `n` **brand new** nodes, where e...
Just iterate the linked list and create copies of the nodes on the go. Since a node can be referenced from multiple nodes due to the random pointers, make sure you are not making multiple copies of the same node. You may want to use extra space to keep old node ---> new node mapping to prevent creating multiples copies...
Hash Table,Linked List
Medium
133,1624,1634
341
welcome to april's leeco challenge today's problem is flatten nested list iterator you are given a nested list of integers nested list each element is either an integer or list whose elements may also be integers or other lists implement an iterator to flatten it so to implement this iterator nested iterator class we'r...
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
1,494
difference today let's show parallel coses 2. we are given integer and which indicates there are n courses labeled from 1 2 and we also given array relations where relations i equal to pre-course i equal to pre-course i equal to pre-course i next course i representing a prerequisite relationship between course pre-cour...
Parallel Courses II
activity-participants
You are given an integer `n`, which indicates that there are `n` courses labeled from `1` to `n`. You are also given an array `relations` where `relations[i] = [prevCoursei, nextCoursei]`, representing a prerequisite relationship between course `prevCoursei` and course `nextCoursei`: course `prevCoursei` has to be take...
null
Database
Medium
null
81
hello everyone let's take a look at the code 81 switching on rotating starter route 2. so it's a follow-up of on so it's a follow-up of on so it's a follow-up of on the code 63 rotated started everyone and for this problem um if you haven't finished the coasters way you can practice that first then do this problem okay...
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
207
The The The next question that we're going to see is the course schedule you number one okay what is the numbering of the courses from zero or are there 10 courses so from zero to nine are the courses you're going in other periods where prequels it's I a I B I INDICATE DATE YOU MUST TECH COURSE B FIRST IF YOU WANT YOU ...
Course Schedule
course-schedule
There are a total of `numCourses` courses you have to take, labeled from `0` to `numCourses - 1`. You are given an array `prerequisites` where `prerequisites[i] = [ai, bi]` indicates that you **must** take course `bi` first if you want to take course `ai`. * For example, the pair `[0, 1]`, indicates that to take cou...
This problem is equivalent to finding if a cycle exists in a directed graph. If a cycle exists, no topological ordering exists and therefore it will be impossible to take all courses. Topological Sort via DFS - A great video tutorial (21 minutes) on Coursera explaining the basic concepts of Topological Sort. Topologica...
Depth-First Search,Breadth-First Search,Graph,Topological Sort
Medium
210,261,310,630
332
hello everyone welcome to i'll go pundit uh today we are going to take a look at the lead called question number 332 reconstruct right now so this question is a very famous question and it's been asked in multiple companies like uber facebook amazon microsoft and twitter so let's take a look at this given a list of ire...
Reconstruct Itinerary
reconstruct-itinerary
You are given a list of airline `tickets` where `tickets[i] = [fromi, toi]` represent the departure and the arrival airports of one flight. Reconstruct the itinerary in order and return it. All of the tickets belong to a man who departs from `"JFK "`, thus, the itinerary must begin with `"JFK "`. If there are multiple...
null
Depth-First Search,Graph,Eulerian Circuit
Hard
2051,2201
10
hello friends my name is Tushar and today I'm going to talk about how to do regular expression matching using dynamic programming in another video I talked about how to do wildcard matching using dynamic programming today we're going to talk about a regex matching so the question is you're given a pattern consisting of...
Regular Expression Matching
regular-expression-matching
Given an input string `s` and a pattern `p`, implement regular expression matching with support for `'.'` and `'*'` where: * `'.'` Matches any single character.​​​​ * `'*'` Matches zero or more of the preceding element. The matching should cover the **entire** input string (not partial). **Example 1:** **Input:...
null
String,Dynamic Programming,Recursion
Hard
44
91
which look like a magazine me model before you question right flexing like a pogo how's it going guys today you don't want to go over a question called decode ways this is a question that's being asked by Facebook right now so a good question to know it says a message containing letters from A to Z is being encoded to ...
Decode Ways
decode-ways
A message containing letters from `A-Z` can be **encoded** into numbers using the following mapping: 'A' -> "1 " 'B' -> "2 " ... 'Z' -> "26 " To **decode** an encoded message, all the digits must be grouped then mapped back into letters using the reverse of the mapping above (there may be multiple ways). For examp...
null
String,Dynamic Programming
Medium
639,2091
98
hey what's up guys nobody right technically stuff on Twitter in YouTube check description for all my information we're gonna be doing valid binary search tree my grandma's house but I did not want to miss a day of uploading so a medium problem given a binary search given a binary tree determine if it's a valid binary s...
Validate Binary Search Tree
validate-binary-search-tree
Given the `root` of a binary tree, _determine if it is a valid binary search tree (BST)_. A **valid BST** is defined as follows: * The left subtree of a node contains only nodes with keys **less than** the node's key. * The right subtree of a node contains only nodes with keys **greater than** the node's key. * ...
null
Tree,Depth-First Search,Binary Search Tree,Binary Tree
Medium
94,501
493
Find employment in solve problem on device only code fennel is big problem he sees first life interiors name do the number of river in the rate and condition was one to three condition on the side and our which main condition of that one meaning from name will be Gare In which the meaning of age will be eye number inde...
Reverse Pairs
reverse-pairs
Given an integer array `nums`, return _the number of **reverse pairs** in the array_. A **reverse pair** is a pair `(i, j)` where: * `0 <= i < j < nums.length` and * `nums[i] > 2 * nums[j]`. **Example 1:** **Input:** nums = \[1,3,2,3,1\] **Output:** 2 **Explanation:** The reverse pairs are: (1, 4) --> nums\[1\]...
null
Array,Binary Search,Divide and Conquer,Binary Indexed Tree,Segment Tree,Merge Sort,Ordered Set
Hard
315,327
878
ass problem for today from the hot pocket and magical number so concerned magical divisible by either a or P okay and we have to determine a magical number and it has to be in the model of tennis to connect the seven so taking the example if n is 1 and we have two numbers given what is the first magical number which is...
Nth Magical Number
shifting-letters
A positive integer is _magical_ if it is divisible by either `a` or `b`. Given the three integers `n`, `a`, and `b`, return the `nth` magical number. Since the answer may be very large, **return it modulo** `109 + 7`. **Example 1:** **Input:** n = 1, a = 2, b = 3 **Output:** 2 **Example 2:** **Input:** n = 4, a = ...
null
Array,String
Medium
1954
1,685
Hello friends, today's problem is Sum of Absolute Differences in the Sorted Array. In this problem, we have been given a sorted array. We have to return an array of the same length in which what will each element represent, the absolute difference of that element from all the other elements and Their sum like if we tak...
Sum of Absolute Differences in a Sorted Array
stone-game-v
You are given an integer array `nums` sorted in **non-decreasing** order. Build and return _an integer array_ `result` _with the same length as_ `nums` _such that_ `result[i]` _is equal to the **summation of absolute differences** between_ `nums[i]` _and all the other elements in the array._ In other words, `result[i...
We need to try all possible divisions for the current row to get the max score. As calculating all possible divisions will lead us to calculate some sub-problems more than once, we need to think of dynamic programming.
Array,Math,Dynamic Programming,Game Theory
Hard
909,1240,1522,1617,1788,1808,2002,2156
474
hey everyone nintendo said hope you are doing good so let's start with the question so the question is one and zeros okay so what is given to us we have given an array of binary strings str's and we have also given two integer m and n so what we have to do we have to return the size of the largest subset of str such th...
Ones and Zeroes
ones-and-zeroes
You are given an array of binary strings `strs` and two integers `m` and `n`. Return _the size of the largest subset of `strs` such that there are **at most**_ `m` `0`_'s and_ `n` `1`_'s in the subset_. A set `x` is a **subset** of a set `y` if all elements of `x` are also elements of `y`. **Example 1:** **Input:**...
null
Array,String,Dynamic Programming
Medium
510,600,2261
451
Hi gas welcome back tu my channel so today our problem is short characters by frequency so in this problem statement what have we given here we have got a sting s and we have to sort this sting in descending order based on The frequency of the characters. Okay, so here your answer can be multiple, so if you turn even o...
Sort Characters By Frequency
sort-characters-by-frequency
Given a string `s`, sort it in **decreasing order** based on the **frequency** of the characters. The **frequency** of a character is the number of times it appears in the string. Return _the sorted string_. If there are multiple answers, return _any of them_. **Example 1:** **Input:** s = "tree " **Output:** "eer...
null
Hash Table,String,Sorting,Heap (Priority Queue),Bucket Sort,Counting
Medium
347,387,1741
1,530
prediction from weekly contest 199 from read code so let's start the first question is very simple it states that you are given a string s and an integer array indices of the same length so as you can see you are given a string and some corresponding indices okay so let's assume that four corresponding to c five first ...
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
1,732
all right hello welcome to a new video we're going to this problem called find the highest altitude number 1732 it is an easy problem Le code so let's go and get into it um yeah so um there is a biker going on a road trip the road trip consists of n plus one points wait the road the B there's a biker going on a road tr...
Find the Highest Altitude
minimum-one-bit-operations-to-make-integers-zero
There is a biker going on a road trip. The road trip consists of `n + 1` points at different altitudes. The biker starts his trip on point `0` with altitude equal `0`. You are given an integer array `gain` of length `n` where `gain[i]` is the **net gain in altitude** between points `i`​​​​​​ and `i + 1` for all (`0 <=...
The fastest way to convert n to zero is to remove all set bits starting from the leftmost one. Try some simple examples to learn the rule of how many steps are needed to remove one set bit. consider n=2^k case first, then solve for all n.
Dynamic Programming,Bit Manipulation,Memoization
Hard
2119
5
hello everyone welcome to another video of programming problem Solutions in this video we are going to look at lead code question 5 longest P dring substring so let's get started let's first cover the problem statement it says given a string s return the longest pelring substring in s just to revise a Pome is a string ...
Longest Palindromic Substring
longest-palindromic-substring
Given a string `s`, return _the longest_ _palindromic_ _substring_ in `s`. **Example 1:** **Input:** s = "babad " **Output:** "bab " **Explanation:** "aba " is also a valid answer. **Example 2:** **Input:** s = "cbbd " **Output:** "bb " **Constraints:** * `1 <= s.length <= 1000` * `s` consist of only dig...
How can we reuse a previously computed palindrome to compute a larger palindrome? If “aba” is a palindrome, is “xabax” a palindrome? Similarly is “xabay” a palindrome? Complexity based hint: If we use brute-force and check whether for every start and end position a substring is a palindrome we have O(n^2) start - end ...
String,Dynamic Programming
Medium
214,266,336,516,647
1,678
hello quick introduction to the video my name is Cameron I'm a graduate Apprentice software engineer currently studying at Glasgow University and I'm using this video as a way to sort of rubber ducky debug a Le code problem just attempt to solve it h talk through my thought process H hopefully solve it and hopefully it...
Goal Parser Interpretation
number-of-ways-to-split-a-string
You own a **Goal Parser** that can interpret a string `command`. The `command` consists of an alphabet of `"G "`, `"() "` and/or `"(al) "` in some order. The Goal Parser will interpret `"G "` as the string `"G "`, `"() "` as the string `"o "`, and `"(al) "` as the string `"al "`. The interpreted strings are then concat...
There is no way if the sum (number of '1's) is not divisible by the number of splits. So sum%3 should be 0. Preffix s1 , and suffix s3 should have sum/3 characters '1'. Follow up: Can you generalize the problem with numbers between [-10^9, 10^9] such the sum between subarrays s1, s2, s3 are the same?
Math,String
Medium
548
5
hey everyone today we are going to solve thetical equation longest paric subing okay so first of all um we need to understand paric subring so when I think about a solution I usually start with small and simple input because it's easy to understand and find a solution but this times let's start with like a big input li...
Longest Palindromic Substring
longest-palindromic-substring
Given a string `s`, return _the longest_ _palindromic_ _substring_ in `s`. **Example 1:** **Input:** s = "babad " **Output:** "bab " **Explanation:** "aba " is also a valid answer. **Example 2:** **Input:** s = "cbbd " **Output:** "bb " **Constraints:** * `1 <= s.length <= 1000` * `s` consist of only dig...
How can we reuse a previously computed palindrome to compute a larger palindrome? If “aba” is a palindrome, is “xabax” a palindrome? Similarly is “xabay” a palindrome? Complexity based hint: If we use brute-force and check whether for every start and end position a substring is a palindrome we have O(n^2) start - end ...
String,Dynamic Programming
Medium
214,266,336,516,647
913
hey what's up guys this is chung so today uh let's take a look at this one number 913 cat and mouse um so this one is a very interesting problem because you know i think recently this week we just had like another cat and mouse number two as a weekly in the weekly contest so but so i would like to try to explain this o...
Cat and Mouse
random-flip-matrix
A game on an **undirected** graph is played by two players, Mouse and Cat, who alternate turns. The graph is given as follows: `graph[a]` is a list of all nodes `b` such that `ab` is an edge of the graph. The mouse starts at node `1` and goes first, the cat starts at node `2` and goes second, and there is a hole at n...
null
Hash Table,Math,Reservoir Sampling,Randomized
Medium
null
389
Hello Hi Friends Welcome Back Today We Are Going To Solve List Of Problems Create A Knife And Different Species Among The Frequently Asked Questions By Google So Let's Go Through The Description And We Will See How We Are Going To Solve This Question Solve Of A Person Like You Are You Want To Springs Such Team Sprint I...
Find the Difference
find-the-difference
You are given two strings `s` and `t`. String `t` is generated by random shuffling string `s` and then add one more letter at a random position. Return the letter that was added to `t`. **Example 1:** **Input:** s = "abcd ", t = "abcde " **Output:** "e " **Explanation:** 'e' is the letter that was added. **Exam...
null
Hash Table,String,Bit Manipulation,Sorting
Easy
136
289
hi everyone today we're going to talk about legal problem 289 game of life let's take a look at the problem first according to Wikipedia article the game of life also known as life is a cellular automation devised by a British mathematician John Tivoli bought with em by EM cells each cell has an initial state either li...
Game of Life
game-of-life
According to [Wikipedia's article](https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life): "The **Game of Life**, also known simply as **Life**, is a cellular automaton devised by the British mathematician John Horton Conway in 1970. " The board is made up of an `m x n` grid of cells, where each cell has an initial st...
null
Array,Matrix,Simulation
Medium
73
787
hello everyone welcome to algo simplified let's solve today's lead chord challenge that is cheapest flights Within k-stops cheapest flights Within k-stops cheapest flights Within k-stops in this problem there are ncts connected by some number of flights you are given an array flights where flights I is equal to from I ...
Cheapest Flights Within K Stops
sliding-puzzle
There are `n` cities connected by some number of flights. You are given an array `flights` where `flights[i] = [fromi, toi, pricei]` indicates that there is a flight from city `fromi` to city `toi` with cost `pricei`. You are also given three integers `src`, `dst`, and `k`, return _**the cheapest price** from_ `src` _...
Perform a breadth-first-search, where the nodes are the puzzle boards and edges are if two puzzle boards can be transformed into one another with one move.
Array,Breadth-First Search,Matrix
Hard
null
329
Matrix containing positive integers including zero and from this Matrix we need to find out the longest strictly increasing path by moving in any four directions that is we can move up down left or right from each cell of this Matrix for example this path of length 7 is the longest strictly increasing path in this Matr...
Longest Increasing Path in a Matrix
longest-increasing-path-in-a-matrix
Given an `m x n` integers `matrix`, return _the length of the longest increasing path in_ `matrix`. From each cell, you can either move in four directions: left, right, up, or down. You **may not** move **diagonally** or move **outside the boundary** (i.e., wrap-around is not allowed). **Example 1:** **Input:** matr...
null
Dynamic Programming,Depth-First Search,Breadth-First Search,Graph,Topological Sort,Memoization
Hard
null
129
hey everybody this is Larry this is day 14 of the lead 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 um is it like three week or something okay yeah uh anyway today's bottom is 129 some route to Leaf numbers hit the like button hit th...
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
1,601
hello everyone welcome back here is when I'm saying today we will tackle a challenging problem that results around employee transfer so request among a set of buildings so now a problem goes like this we have and buildings each having some number of employees and some of these employees want to transfer from one buildi...
Maximum Number of Achievable Transfer Requests
maximum-number-of-achievable-transfer-requests
We have `n` buildings numbered from `0` to `n - 1`. Each building has a number of employees. It's transfer season, and some employees want to change the building they reside in. You are given an array `requests` where `requests[i] = [fromi, toi]` represents an employee's request to transfer from building `fromi` to bu...
null
null
Hard
null
1,732
hey everyone today we are going to celebrate for the question finds the highest altitude so there is a vital going on a road trip the road trip consists of n plus one points at different altitude the biker starts his trip on point zero with altitude equals zero so you are given the integer array gain over links n where...
Find the Highest Altitude
minimum-one-bit-operations-to-make-integers-zero
There is a biker going on a road trip. The road trip consists of `n + 1` points at different altitudes. The biker starts his trip on point `0` with altitude equal `0`. You are given an integer array `gain` of length `n` where `gain[i]` is the **net gain in altitude** between points `i`​​​​​​ and `i + 1` for all (`0 <=...
The fastest way to convert n to zero is to remove all set bits starting from the leftmost one. Try some simple examples to learn the rule of how many steps are needed to remove one set bit. consider n=2^k case first, then solve for all n.
Dynamic Programming,Bit Manipulation,Memoization
Hard
2119
906
hello everyone welcome to coders camp so we are today at the eighth day of may lead code challenge and the problem we are going to cover is super palin ropes so the input given here is the two integer values left and right and we have to return the number of super palindromes within this range left and right that's inc...
Super Palindromes
walking-robot-simulation
Let's say a positive integer is a **super-palindrome** if it is a palindrome, and it is also the square of a palindrome. Given two positive integers `left` and `right` represented as strings, return _the number of **super-palindromes** integers in the inclusive range_ `[left, right]`. **Example 1:** **Input:** left ...
null
Array,Simulation
Medium
2178
284
everyone welcome to my channel so in this video i'm going to try to uh solve this problem do some left coding work at the same time i'm going to try to follow the general interview steps while trying to solve this problem so first of all let's read through this question and get a good understanding about it so design a...
Peeking Iterator
peeking-iterator
Design an iterator that supports the `peek` operation on an existing iterator in addition to the `hasNext` and the `next` operations. Implement the `PeekingIterator` class: * `PeekingIterator(Iterator nums)` Initializes the object with the given integer iterator `iterator`. * `int next()` Returns the next element...
Think of "looking ahead". You want to cache the next element. Is one variable sufficient? Why or why not? Test your design with call order of peek() before next() vs next() before peek(). For a clean implementation, check out Google's guava library source code.
Array,Design,Iterator
Medium
173,251,281
1,696
hey everybody this is larry just me going with q3 of the weekly contest 220 on neat code jump game six uh hit the like button hit the subscribe button join me on lead code let me know what you think about this problem uh okay so during the so i stopped this problem during the contest i'm going over my thought process i...
Jump Game VI
strange-printer-ii
You are given a **0-indexed** integer array `nums` and an integer `k`. You are initially standing at index `0`. In one move, you can jump at most `k` steps forward without going outside the boundaries of the array. That is, you can jump from index `i` to any index in the range `[i + 1, min(n - 1, i + k)]` **inclusive*...
Try thinking in reverse. Given the grid, how can you tell if a colour was painted last?
Array,Graph,Topological Sort,Matrix
Hard
664
319
Hello friends today I'm going to solve liquid problem number 319 bulb switcher in this problem we are given n pulps all of them are initially off and now in our first round we turn all the bulbs on and then in second round we turn off every single pulp and then in third round we toggle every third bulb and then in the ...
Bulb Switcher
bulb-switcher
There are `n` bulbs that are initially off. You first turn on all the bulbs, then you turn off every second bulb. On the third round, you toggle every third bulb (turning on if it's off or turning off if it's on). For the `ith` round, you toggle every `i` bulb. For the `nth` round, you only toggle the last bulb. Retu...
null
Math,Brainteaser
Medium
672,1037,1491
1,489
hey everybody this is Larry this is day 19. of the legal daily challenge what is this early access stuff I don't want to try it uh hit the like button hit the Subscribe button join me on Discord let me know what you think about today's Farm uh 1489 find critical and pseudo critical edges in minimum spanning tree uh it'...
Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree
pizza-with-3n-slices
Given a weighted undirected connected graph with `n` vertices numbered from `0` to `n - 1`, and an array `edges` where `edges[i] = [ai, bi, weighti]` represents a bidirectional and weighted edge between nodes `ai` and `bi`. A minimum spanning tree (MST) is a subset of the graph's edges that connects all vertices withou...
By studying the pattern of the operations, we can find out that the problem is equivalent to: Given an integer array with size 3N, select N integers with maximum sum and any selected integers are not next to each other in the array. The first one in the array is considered next to the last one in the array. Use Dynamic...
Array,Dynamic Programming,Greedy,Heap (Priority Queue)
Hard
null
189
hello everyone so today we will be solving lead code problem 189 rotate array so we are given an integer array nums and we have to rotate the array to the right by K steps where K is non-negative so let's head over to our non-negative so let's head over to our non-negative so let's head over to our drawing explanation ...
Rotate Array
rotate-array
Given an integer array `nums`, rotate the array to the right by `k` steps, where `k` is non-negative. **Example 1:** **Input:** nums = \[1,2,3,4,5,6,7\], k = 3 **Output:** \[5,6,7,1,2,3,4\] **Explanation:** rotate 1 steps to the right: \[7,1,2,3,4,5,6\] rotate 2 steps to the right: \[6,7,1,2,3,4,5\] rotate 3 steps to...
The easiest solution would use additional memory and that is perfectly fine. The actual trick comes when trying to solve this problem without using any additional memory. This means you need to use the original array somehow to move the elements around. Now, we can place each element in its original location and shift ...
Array,Math,Two Pointers
Medium
61,186
1,071
hello today I am solving lead code problem number one zero seven one greatest common divisor of strings um so now let's look at the question um for two strings s and t we say t divides as if and only if s can be represent s can be represented in some form of T that is T is conc concatenated with itself one or more time...
Greatest Common Divisor of Strings
binary-prefix-divisible-by-5
For two strings `s` and `t`, we say "`t` divides `s` " if and only if `s = t + ... + t` (i.e., `t` is concatenated with itself one or more times). Given two strings `str1` and `str2`, return _the largest string_ `x` _such that_ `x` _divides both_ `str1` _and_ `str2`. **Example 1:** **Input:** str1 = "ABCABC ", str2...
If X is the first i digits of the array as a binary number, then 2X + A[i] is the first i+1 digits.
Array
Easy
null
915
hello friends in this video we are going to solve a problem where we have an array and we have to partition it into two halves so this is the left half this is the right half and the condition is that all the elements in the left half of this partition should be less than or equal to all the elements in the right hand ...
Partition Array into Disjoint Intervals
generate-random-point-in-a-circle
Given an integer array `nums`, partition it into two (contiguous) subarrays `left` and `right` so that: * Every element in `left` is less than or equal to every element in `right`. * `left` and `right` are non-empty. * `left` has the smallest possible size. Return _the length of_ `left` _after such a partitioni...
null
Math,Geometry,Rejection Sampling,Randomized
Medium
914
1,941
Hello Gas, in today's lecture I am going to solve the questions, check if the character which is equal is given, now a string has to be told whether it is a good string or not, now how to identify a good string if the frequency of each letter in it is If A is coming from A then it is a good string. If A is not coming w...
Check if All Characters Have Equal Number of Occurrences
minimum-number-of-operations-to-make-string-sorted
Given a string `s`, return `true` _if_ `s` _is a **good** string, or_ `false` _otherwise_. A string `s` is **good** if **all** the characters that appear in `s` have the **same** number of occurrences (i.e., the same frequency). **Example 1:** **Input:** s = "abacbc " **Output:** true **Explanation:** The character...
Note that the operations given describe getting the previous permutation of s To solve this problem you need to solve every suffix separately
Math,String,Combinatorics
Hard
null
880
hey everybody this is Larry this is day 27 from delico day challenge hit the like button hit the Subscribe button join me on Discord let me know what you think about today's Farm uh decode decoded string at index ah 880. uh before I get started I'm gonna give a heads up because I feel like the last couple of time I did...
Decoded String at Index
rectangle-area-ii
You are given an encoded string `s`. To decode the string to a tape, the encoded string is read one character at a time and the following steps are taken: * If the character read is a letter, that letter is written onto the tape. * If the character read is a digit `d`, the entire current tape is repeatedly written...
null
Array,Segment Tree,Line Sweep,Ordered Set
Hard
null
799
hello everyone welcome to our channel cody with sunny and in this video we will be talking about the problem champion tavo you can see its index is 799 and it is the medium problem of the lead code okay so yeah before moving on let us talk about the prerequisites required to solve this problem efficiently so basically ...
Champagne Tower
minimum-distance-between-bst-nodes
We stack glasses in a pyramid, where the **first** row has `1` glass, the **second** row has `2` glasses, and so on until the 100th row. Each glass holds one cup of champagne. Then, some champagne is poured into the first glass at the top. When the topmost glass is full, any excess liquid poured will fall equally to t...
null
Tree,Depth-First Search,Breadth-First Search,Binary Search Tree,Binary Tree
Easy
94
1,727
hello everyone this is anne fijo sando welcome to the series for preparation for coding interview today i'm going through a little code 1727 logic sub metrics with rearrangement if you like these videos you can support me by subscribing my channel or click likes buttons in video below you can find the complete video li...
Largest Submatrix With Rearrangements
cat-and-mouse-ii
You are given a binary matrix `matrix` of size `m x n`, and you are allowed to rearrange the **columns** of the `matrix` in any order. Return _the area of the largest submatrix within_ `matrix` _where **every** element of the submatrix is_ `1` _after reordering the columns optimally._ **Example 1:** **Input:** matri...
Try working backward: consider all trivial states you know to be winning or losing, and work backward to determine which other states can be labeled as winning or losing.
Math,Dynamic Programming,Breadth-First Search,Graph,Memoization,Game Theory
Hard
805,949
1,687
hey what's up guys this is john here so today let's take a look uh it's called problem 1687 delivering boxes from storage to ports so i mean this is a really difficult problem okay so let's take a look at the problem description so you have a the task of delivering some boxes from storage to their ports and you only ha...
Delivering Boxes from Storage to Ports
the-most-similar-path-in-a-graph
You have the task of delivering some boxes from storage to their ports using only one ship. However, this ship has a **limit** on the **number of boxes** and the **total weight** that it can carry. You are given an array `boxes`, where `boxes[i] = [ports​​i​, weighti]`, and three integers `portsCount`, `maxBoxes`, and...
Create an array dp where dp[i][j] is the min edit distance for the path starting at node i and compared to index j of the targetPath. Traverse the dp array to obtain a valid answer.
Dynamic Programming,Graph
Hard
null
1,572
Hello hello everyone welcome to my channel it's all the best problem metric join them for giving on that metric ton in directions only in 10 of all elements of obscurism do subscribe my channel like 102 and finally Bigg Boss ko security fiber se 10 - 151 - 1090 for security fiber se 10 - 151 - 1090 for security fiber s...
Matrix Diagonal Sum
subrectangle-queries
Given a square matrix `mat`, return the sum of the matrix diagonals. Only include the sum of all the elements on the primary diagonal and all the elements on the secondary diagonal that are not part of the primary diagonal. **Example 1:** **Input:** mat = \[\[**1**,2,**3**\], \[4,**5**,6\], ...
Use brute force to update a rectangle and, response to the queries in O(1).
Array,Design,Matrix
Medium
null
1,519
Hello friends, the name of the problem which we are going to solve today is Number of Notes Hindi Sub Tree with the Same Level as a Possible. If we first understand the problem statement, then in this problem statement we have been told that a tree has been given to you with And it's number from CO2 end minus one Okay ...
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
1,832
See, we are going to question in this video, check IF D sentence of 1832 code, this 10 gram pen gram is this sentence in which all the letters of English alphabets i.e. of English alphabets i.e. of English alphabets i.e. from A B C D to S are present in this sentence. Okay, so what is it? It is very good in pen graph. ...
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
310
in this problem we have a graph which is also a tree and we have to find minimum height trees so let's say you are given this graph or this tree so what is the property of tree all the nodes are connected and there is no cycle so between any two nodes there will be a unique path and also if it has n nodes it will have ...
Minimum Height Trees
minimum-height-trees
A tree is an undirected graph in which any two vertices are connected by _exactly_ one path. In other words, any connected graph without simple cycles is a tree. Given a tree of `n` nodes labelled from `0` to `n - 1`, and an array of `n - 1` `edges` where `edges[i] = [ai, bi]` indicates that there is an undirected edg...
How many MHTs can a graph have at most?
Depth-First Search,Breadth-First Search,Graph,Topological Sort
Medium
207,210
17
in this video we're going to take a look at a legal problem called letter combinations of a phone number so we're given a string containing digits from two to nine uh return all possible letter combinations that the number could represent so return the answer in any order a mapping of digits uh digit two letters just l...
Letter Combinations of a Phone Number
letter-combinations-of-a-phone-number
Given a string containing digits from `2-9` inclusive, return all possible letter combinations that the number could represent. Return the answer in **any order**. A mapping of digits to letters (just like on the telephone buttons) is given below. Note that 1 does not map to any letters. **Example 1:** **Input:** di...
null
Hash Table,String,Backtracking
Medium
22,39,401
834
reference today that's the sum of distance entry province an underactive that connected a tree with a North labeled zero to a minus one and amongst one ages are given the ice age connects no two edges either and ages I want gather we needed to return least her answer we're also I is a sum of the distance between node I...
Sum of Distances in Tree
ambiguous-coordinates
There is an undirected connected tree with `n` nodes labeled from `0` to `n - 1` and `n - 1` edges. You are given the integer `n` and the array `edges` where `edges[i] = [ai, bi]` indicates that there is an edge between nodes `ai` and `bi` in the tree. Return an array `answer` of length `n` where `answer[i]` is the s...
null
String,Backtracking
Medium
null
897
That them guys welcome back to my channel english video where go into small increasing order search tree to what is given statement here biography root of binary search tree and tree in order to deal left no dea is now the root of the tree and every now have Not left side and only right side, what is the problem? Kallu...
Increasing Order Search Tree
prime-palindrome
Given the `root` of a binary search tree, rearrange the tree in **in-order** so that the leftmost node in the tree is now the root of the tree, and every node has no left child and only one right child. **Example 1:** **Input:** root = \[5,3,6,2,4,null,8,1,null,null,null,7,9\] **Output:** \[1,null,2,null,3,null,4,nul...
null
Math
Medium
2202
50
hey what's up guys John here so today let's take a look at this classic encoded binary search or recursion with memoization problem number 50 power xn so just simply ask you to implement the power of X to the N right basically given like two integers sorry two numbers if two parameters here first one is a float second ...
Pow(x, n)
powx-n
Implement [pow(x, n)](http://www.cplusplus.com/reference/valarray/pow/), which calculates `x` raised to the power `n` (i.e., `xn`). **Example 1:** **Input:** x = 2.00000, n = 10 **Output:** 1024.00000 **Example 2:** **Input:** x = 2.10000, n = 3 **Output:** 9.26100 **Example 3:** **Input:** x = 2.00000, n = -2 **...
null
Math,Recursion
Medium
69,372
743
hello and welcome back to another problem today we're going to be doing problem number 743 Network delay time it's a pretty popular graph problem in it so I'd encourage you to know it and so pretty much I'll just explain it an easier word so let's say you have this two you have a graph of nodes and then you have direct...
Network Delay Time
closest-leaf-in-a-binary-tree
You are given a network of `n` nodes, labeled from `1` to `n`. You are also given `times`, a list of travel times as directed edges `times[i] = (ui, vi, wi)`, where `ui` is the source node, `vi` is the target node, and `wi` is the time it takes for a signal to travel from source to target. We will send a signal from a...
Convert the tree to a general graph, and do a breadth-first search. Alternatively, find the closest leaf for every node on the path from root to target.
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Medium
null
383
Hello hello brother welcome and welcome back to my channel so what is our problem today tension note is available here see here we are roasting tension 9 end magazine what do we have to do na ransom note has to be set tomorrow magazine It is okay by using the latest version of the press note, if you get all the details...
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
448
hi guys hope you're doing great at today's question is find all disappeared numbers in an array so the question says given an array of integers where what a of i every integer in the array is in the range of 1 to n including 1 and n where n is the size of the array some elements appear twice and others appear once find...
Find All Numbers Disappeared in an Array
find-all-numbers-disappeared-in-an-array
Given an array `nums` of `n` integers where `nums[i]` is in the range `[1, n]`, return _an array of all the integers in the range_ `[1, n]` _that do not appear in_ `nums`. **Example 1:** **Input:** nums = \[4,3,2,7,8,2,3,1\] **Output:** \[5,6\] **Example 2:** **Input:** nums = \[1,1\] **Output:** \[2\] **Constrain...
This is a really easy problem if you decide to use additional memory. For those trying to write an initial solution using additional memory, think counters! However, the trick really is to not use any additional space than what is already available to use. Sometimes, multiple passes over the input array help find the s...
Array,Hash Table
Easy
41,442,2107,2305
136
hey what's up guys Nick white here I do tech encoding stuff on Twitch in YouTube and this is a pretty cool easy problem called single number just because this one solution is cool I thought it says given a non-empty array of integers so given a non-empty array of integers so given a non-empty array of integers so an ar...
Single Number
single-number
Given a **non-empty** array of integers `nums`, every element appears _twice_ except for one. Find that single one. You must implement a solution with a linear runtime complexity and use only constant extra space. **Example 1:** **Input:** nums = \[2,2,1\] **Output:** 1 **Example 2:** **Input:** nums = \[4,1,2,1,2...
null
Array,Bit Manipulation
Easy
137,260,268,287,389
126
all right guys welcome to our channel code with sunny and in this video i will be talking about a series of problems called word ladder and now we are going to discuss the second problem right its index is 126 and it is a hard problem of the lead code okay so i don't think that this problem should be categorized into a...
Word Ladder II
word-ladder-ii
A **transformation sequence** from word `beginWord` to word `endWord` using a dictionary `wordList` is a sequence of words `beginWord -> s1 -> s2 -> ... -> sk` such that: * Every adjacent pair of words differs by a single letter. * Every `si` for `1 <= i <= k` is in `wordList`. Note that `beginWord` does not need ...
null
Hash Table,String,Backtracking,Breadth-First Search
Hard
127,2276
402
That Sohail Bhavan Today Dwipushkar Andar Lee Ko Medium Problem and 402 Removed Deposit This Problem Ho Saka Usaan Ki [ __ ] Deposit This Problem Ho Saka Usaan Ki [ __ ] Deposit This Problem Ho Saka Usaan Ki [ __ ] Please Like Mission Goodbye and Imprisoned for Six Pack Abs Khuli Not Talk But I Think You Are Not Them N...
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
263
Hello welcome back to Anonymous Data Scientist channel, today we will do lead code problem 263, what is the next number, how is the next number defined, if it is a positive integer, whose prime factors are limited to 25, now we should know what are prime factors. For this, as if six is ​​six, For this, as if six is ​​s...
Ugly Number
ugly-number
An **ugly number** is a positive integer whose prime factors are limited to `2`, `3`, and `5`. Given an integer `n`, return `true` _if_ `n` _is an **ugly number**_. **Example 1:** **Input:** n = 6 **Output:** true **Explanation:** 6 = 2 \* 3 **Example 2:** **Input:** n = 1 **Output:** true **Explanation:** 1 has n...
null
Math
Easy
202,204,264
1,396
Hello everyone welcome to my channel it will be very easy story is simple and will convert the story into code and this is one of the solid question where the story helps a lot the name of the question is Design Underground System and it has been asked by This has been asked multiple times in Amazon and Bloomberg. Okay...
Design Underground System
count-servers-that-communicate
An underground railway system is keeping track of customer travel times between different stations. They are using this data to calculate the average time it takes to travel from one station to another. Implement the `UndergroundSystem` class: * `void checkIn(int id, string stationName, int t)` * A customer w...
Store number of computer in each row and column. Count all servers that are not isolated.
Array,Depth-First Search,Breadth-First Search,Union Find,Matrix,Counting
Medium
null
816
hello viewers welcome back to my channel I hope you are enjoying all the videos and back with another problem from lead code today ambiguous coordinates we had some two-dimensional coordinates like 1 some two-dimensional coordinates like 1 some two-dimensional coordinates like 1 3 or 2.5 then we removed all the commas ...
Ambiguous Coordinates
design-hashset
We had some 2-dimensional coordinates, like `"(1, 3) "` or `"(2, 0.5) "`. Then, we removed all commas, decimal points, and spaces and ended up with the string s. * For example, `"(1, 3) "` becomes `s = "(13) "` and `"(2, 0.5) "` becomes `s = "(205) "`. Return _a list of strings representing all possibilities for wh...
null
Array,Hash Table,Linked List,Design,Hash Function
Easy
817,1337
217
is a collaboration with programming knowledge in this video we'll solve contains duplicate the 217 lead code problem so let's start with the question given an array of integers find if the array contains any duplicates your function should return true if any value appears at least twice in the array and it should retur...
Contains Duplicate
contains-duplicate
Given an integer array `nums`, return `true` if any value appears **at least twice** in the array, and return `false` if every element is distinct. **Example 1:** **Input:** nums = \[1,2,3,1\] **Output:** true **Example 2:** **Input:** nums = \[1,2,3,4\] **Output:** false **Example 3:** **Input:** nums = \[1,1,1,...
null
Array,Hash Table,Sorting
Easy
219,220
15
hello and welcome back to the cracking vein YouTube channel today we're going to be solving lead code problem number 15 threesome given an integer array nums return all the triplets nums of I nums of J and nums of K such that I does not equal j i does not equal to K and J does not equal to K and the nums of I plus nums...
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
648
hello friends so today in this video we will be going through a problem from lead code problem name replace words so i'll tell you in simple terms what the form statement states it's not too difficult problem but still if you want to learn hashmaps and hash techniques then like why hashing is required why set hash map ...
Replace Words
replace-words
In English, we have a concept called **root**, which can be followed by some other word to form another longer word - let's call this word **successor**. For example, when the **root** `"an "` is followed by the **successor** word `"other "`, we can form a new word `"another "`. Given a `dictionary` consisting of many...
null
Array,Hash Table,String,Trie
Medium
208
1,015
hello this is wagga we're going to do another legal question the question in question is 10 15 smallest integer divisible by k right so we are given um you're given a positive integer k and you are supposed to find the length of the smallest positive integer n such that n is divisible by k and n only contains the digit...
Smallest Integer Divisible by K
smallest-integer-divisible-by-k
Given a positive integer `k`, you need to find the **length** of the **smallest** positive integer `n` such that `n` is divisible by `k`, and `n` only contains the digit `1`. Return _the **length** of_ `n`. If there is no such `n`, return -1. **Note:** `n` may not fit in a 64-bit signed integer. **Example 1:** **In...
null
null
Medium
null
743
Hello hello guys welcome back to take admission in this video you will see the network delete problem Vishram customers alarms and this problem can dissolve very easily but this free mode driving direction of only one-third interviewer direction of only one-third interviewer direction of only one-third interviewer intu...
Network Delay Time
closest-leaf-in-a-binary-tree
You are given a network of `n` nodes, labeled from `1` to `n`. You are also given `times`, a list of travel times as directed edges `times[i] = (ui, vi, wi)`, where `ui` is the source node, `vi` is the target node, and `wi` is the time it takes for a signal to travel from source to target. We will send a signal from a...
Convert the tree to a general graph, and do a breadth-first search. Alternatively, find the closest leaf for every node on the path from root to target.
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Medium
null