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,832
let code pangam check if the sentence is a pangam what is a sentence that is a pankam is a sentence that contains all the English alphabet characters at least once for each character at least once so does this contain a yes H does this contain B yes so basically it contain all the characters so the answer is true if yo...
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
81
Challenge and today's question is your absolutely amazing question because this question will be already understood okay so first okay and what we have to do is we have to do all these things but one thing is said in it that Note: It is not necessary to have a distinct value. Note: It is not necessary to have a distinc...
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
490
It is the problem number 490 liters that is called you have in this problem what we have is a two-dimensional arrangement that represents a two-dimensional arrangement that represents a two-dimensional arrangement that represents a labyrinth so to speak where the cells with a value of zero are places where we can move ...
The Maze
the-maze
There is a ball in a `maze` with empty spaces (represented as `0`) and walls (represented as `1`). The ball can go through the empty spaces by rolling **up, down, left or right**, but it won't stop rolling until hitting a wall. When the ball stops, it could choose the next direction. Given the `m x n` `maze`, the ball...
null
Depth-First Search,Breadth-First Search,Graph
Medium
499,505
1,338
Hello everyone welcome back to my channel Suji we are going to discuss the problem who has problem in July 4 inches reduce the size to only so what is said in the input and we have a setup in this teachers have taken out the true part in this way. Whatever entries we will take in Somerset, we will remove all the increm...
Reduce Array Size to The Half
queries-quality-and-percentage
You are given an integer array `arr`. You can choose a set of integers and remove all the occurrences of these integers in the array. Return _the minimum size of the set so that **at least** half of the integers of the array are removed_. **Example 1:** **Input:** arr = \[3,3,3,3,5,5,5,2,2,7\] **Output:** 2 **Explan...
null
Database
Easy
1773
309
today we're gonna be working on it called question number three zero nine um best time to buy and sell stock with cooldown now you are given an array prices where prices of i is the price of a given stock on the ith day so we have been given the prices of the stocks uh find the maximum profit you can achieve you make c...
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
973
hey guys so today we are going over the code 973 question okay closest points to a region so we have a list of points on the plane find the uh k closest points to the origin zero here the distance between two points on a plane is the you calidean distance you may return the answer to any other um dancer is guaranteed t...
K Closest Points to Origin
stamping-the-sequence
Given an array of `points` where `points[i] = [xi, yi]` represents a point on the **X-Y** plane and an integer `k`, return the `k` closest points to the origin `(0, 0)`. The distance between two points on the **X-Y** plane is the Euclidean distance (i.e., `√(x1 - x2)2 + (y1 - y2)2`). You may return the answer in **an...
null
String,Stack,Greedy,Queue
Hard
null
1,534
let's go over number 1534 count good triplets given an array of integers so we have an integers array of integers uh and three integers a b and c so we're going to be given an array of numbers and a b and c they're all going to be numbers too uh you need to find the number of good chippers so what a good drip is a trip...
Count Good Triplets
minimum-number-of-frogs-croaking
Given an array of integers `arr`, and three integers `a`, `b` and `c`. You need to find the number of good triplets. A triplet `(arr[i], arr[j], arr[k])` is **good** if the following conditions are true: * `0 <= i < j < k < arr.length` * `|arr[i] - arr[j]| <= a` * `|arr[j] - arr[k]| <= b` * `|arr[i] - arr[k]|...
keep the frequency of all characters from "croak" using a hashmap. For each character in the given string, greedily match it to a possible "croak".
String,Counting
Medium
null
128
Consecutive element sequence so basically the problem is 1004 200 132 how four came like this, you can see van tu three four is formed in such a sequence, right van tu three four is not present in it, so our count will stop so what should be its length Gaya four means four hundred, you can see, if it is not 99%, then i...
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
732
Hi gas welcome and welcome back to my channel so today our problem is my calendar three what is given to us in this problem statement here we have to implement a class my calendar three class in which you have a constructor and the second book function is book You have been given two arguments in the function, start an...
My Calendar III
my-calendar-iii
A `k`\-booking happens when `k` events have some non-empty intersection (i.e., there is some time that is common to all `k` events.) You are given some events `[startTime, endTime)`, after each given event, return an integer `k` representing the maximum `k`\-booking between all the previous events. Implement the `MyC...
Treat each interval [start, end) as two events "start" and "end", and process them in sorted order.
Design,Segment Tree,Ordered Set
Hard
729,731
929
hey guys welcome back to my channel and i'm back again with another really interesting coding interview question video today guys we are going to solve question number 929 unique email addresses of least code before i start with the video guys just want to request you that if you have not yet subscribed to my channel t...
Unique Email Addresses
groups-of-special-equivalent-strings
Every **valid email** consists of a **local name** and a **domain name**, separated by the `'@'` sign. Besides lowercase letters, the email may contain one or more `'.'` or `'+'`. * For example, in `"alice@leetcode.com "`, `"alice "` is the **local name**, and `"leetcode.com "` is the **domain name**. If you add pe...
null
Array,Hash Table,String
Medium
null
1,680
hey guys today we're going to look at a problem from lead code weekly contest 218. this one is called concatenation of consecutive binary numbers so given an integer n you need to return the decimal value of the binary string formed by concatenating the binary representations of 1 to n in order return this in modulo of...
Concatenation of Consecutive Binary Numbers
count-all-possible-routes
Given an integer `n`, return _the **decimal value** of the binary string formed by concatenating the binary representations of_ `1` _to_ `n` _in order, **modulo**_ `109 + 7`. **Example 1:** **Input:** n = 1 **Output:** 1 **Explanation: ** "1 " in binary corresponds to the decimal value 1. **Example 2:** **Input:**...
Use dynamic programming to solve this problem with each state defined by the city index and fuel left. Since the array contains distinct integers fuel will always be spent in each move and so there can be no cycles.
Array,Dynamic Programming,Memoization
Hard
null
1,601
hey there everyone welcome back to lead coding in this video we'll be solving a really interesting problem from lead code and name of the problem is maximum number of achievable transfer request so we have n buildings numbered from 0 to n minus 1 each building has a number of employees is a transfer season and some emp...
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,187
hey everyone welcome back today we are going to solve problem number 1187 make array strictly increasing first we'll see the explanation of the problem statement in the logic on the code now white stab into the solution so in this problem we are given two input arrays array 1 and array two so we need to make all the el...
Make Array Strictly Increasing
print-foobar-alternately
Given two integer arrays `arr1` and `arr2`, return the minimum number of operations (possibly zero) needed to make `arr1` strictly increasing. In one operation, you can choose two indices `0 <= i < arr1.length` and `0 <= j < arr2.length` and do the assignment `arr1[i] = arr2[j]`. If there is no way to make `arr1` str...
null
Concurrency
Medium
1203,1216
905
hey everybody this is larry this is may 2nd um i think yeah uh second day of may hit the like button hit the subscribe button join me on discord let me know what you're thinking let me know how you're doing this problem and all the good stuff and also uh for my viewers who are celebrating uh it hopefully i'm saying tha...
Sort Array By Parity
length-of-longest-fibonacci-subsequence
Given an integer array `nums`, move all the even integers at the beginning of the array followed by all the odd integers. Return _**any array** that satisfies this condition_. **Example 1:** **Input:** nums = \[3,1,2,4\] **Output:** \[2,4,3,1\] **Explanation:** The outputs \[4,2,3,1\], \[2,4,1,3\], and \[4,2,1,3\] w...
null
Array,Hash Table,Dynamic Programming
Medium
1013
1,287
hello guys and welcome back to lead Logics this is the element appearing more than 25% in a sorted area problem more than 25% in a sorted area problem more than 25% in a sorted area problem it is a lead code easy and the number for this is 1287 so in this problem we are given with an integer array which is already sort...
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
329
hey everybody this is larry this is me in uh oh this is day oh and i just got back from uh all my travels you can see on instagram but yeah this is me doing day 19 of the may lego daily challenge hit the like button in the subscriber enjoyment discord and of course at least for when i'm in traveling mode uh so i'm you ...
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
1,176
today last song Lead code 1176 diet plan performance okay so uh the question is so we have a director to consumes calorie eye calories on the ice day and with an integer k for every consecutive sequence of cake days okay starting from calories I to calories I plus K minus one we have the total calories consumed during ...
Diet Plan Performance
design-a-leaderboard
A dieter consumes `calories[i]` calories on the `i`\-th day. Given an integer `k`, for **every** consecutive sequence of `k` days (`calories[i], calories[i+1], ..., calories[i+k-1]` for all `0 <= i <= n-k`), they look at _T_, the total calories consumed during that sequence of `k` days (`calories[i] + calories[i+1] + ...
What data structure can we use to keep the players' data? Keep a map (dictionary) of player scores. For each top(K) function call, find the maximum K scores and add them.
Hash Table,Design,Sorting
Medium
null
969
welcome to my channel so in this video i'm going to try to solve this problem do some live 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 try to restore this problem get a good understanding about the question so given an arra...
Pancake Sorting
number-of-recent-calls
Given an array of integers `arr`, sort the array by performing a series of **pancake flips**. In one pancake flip we do the following steps: * Choose an integer `k` where `1 <= k <= arr.length`. * Reverse the sub-array `arr[0...k-1]` (**0-indexed**). For example, if `arr = [3,2,1,4]` and we performed a pancake f...
null
Design,Queue,Data Stream
Easy
null
228
Hello Hi Guys Welcome To Kalpeshwar Today's Question Summary Ranges In This Question Byagi Vanaspati Unique Interior And Better Returns This Molested List And In This Date Cover All The Number Hindi Are Exactly Dentist Italian Top Namaskar But By Yashwant Ranges And Ignoring Teacher X Dot X In Bhi mono friends but not ...
Summary Ranges
summary-ranges
You are given a **sorted unique** integer array `nums`. A **range** `[a,b]` is the set of all integers from `a` to `b` (inclusive). Return _the **smallest sorted** list of ranges that **cover all the numbers in the array exactly**_. That is, each element of `nums` is covered by exactly one of the ranges, and there is...
null
Array
Easy
163,352
47
hi everyone uh today we'll be doing question 47 we code called permutations two so it's just like permutations one except this time the collection of numbers contains duplicates and we still want all possible unique permutations so in this case um if you haven't seen my video on permutations one uh you might want to ta...
Permutations II
permutations-ii
Given a collection of numbers, `nums`, that might contain duplicates, return _all possible unique permutations **in any order**._ **Example 1:** **Input:** nums = \[1,1,2\] **Output:** \[\[1,1,2\], \[1,2,1\], \[2,1,1\]\] **Example 2:** **Input:** nums = \[1,2,3\] **Output:** \[\[1,2,3\],\[1,3,2\],\[2,1,3\],\[2,3,...
null
Array,Backtracking
Medium
31,46,267,1038
404
welcome back guys today we are going to solve lead code problem 404 sum of left leaves uh before we start looking this problem i just want to mention that i often create lead code solution videos in java technology and i also create java j2e interview related helpful videos so please check out my playlist it has a good...
Sum of Left Leaves
sum-of-left-leaves
Given the `root` of a binary tree, return _the sum of all left leaves._ A **leaf** is a node with no children. A **left leaf** is a leaf that is the left child of another node. **Example 1:** **Input:** root = \[3,9,20,null,null,15,7\] **Output:** 24 **Explanation:** There are two left leaves in the binary tree, wit...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Easy
null
297
hi folks today we are going to solve some tree civilization and destabilization problems the first question is the code 297 and we are going to serialize and decelerate the banner tree if you haven't raised this problems you can spend some time so let's see how to solve it first of all the root note is one so we can wr...
Serialize and Deserialize Binary Tree
serialize-and-deserialize-binary-tree
Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection link to be reconstructed later in the same or another computer environment. Design an algorithm to serialize and deserialize a bi...
null
String,Tree,Depth-First Search,Breadth-First Search,Design,Binary Tree
Hard
271,449,652,765
682
welcome to tim's leeco challenge this question is called baseball game you are keeping score for a baseball game with strange rules the game consists of several rounds where the scores of past rounds may affect the future round scores the beginning of the game you start with an empty record you are given a list of stri...
Baseball Game
baseball-game
You are keeping the scores for a baseball game with strange rules. At the beginning of the game, you start with an empty record. You are given a list of strings `operations`, where `operations[i]` is the `ith` operation you must apply to the record and is one of the following: * An integer `x`. * Record a new...
null
Array,Stack,Simulation
Easy
1720
225
hey everyone it is this side hope you are doing good so let's start with the question so the question is implement stack using queue okay so basically you have given a stack obviously you have to implement the stack implementation using the queue so as you know stack is a la last in first out stack so it's a lifo struc...
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
258
Premature Ejaculation Sir Azamgarh will put the question, it was a game like Welcome game, meaning that if you get scared after seeing this question, then you will not have any question. You have subscribed to the fun, its questions were about thought process, it will take a lot of time, complexity will be very high an...
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
347
welcome back to code Meets World today we're looking at leap code number 347 which is top K frequent elements in this problem we're given an integer array called nums and an integer K and we need to return the K most frequent elements and we can return this in any order so looking at the examples in this array with k e...
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
772
and welcome back to the cracking fang youtube channel today we're going to be solving lead code problem 772 basic calculator 3. implement a basic calculator to evaluate a simple expression string the expression string contains only non-negative integers a plus operator a non-negative integers a plus operator a non-nega...
Basic Calculator III
construct-quad-tree
Implement a basic calculator to evaluate a simple expression string. The expression string contains only non-negative integers, `'+'`, `'-'`, `'*'`, `'/'` operators, and open `'('` and closing parentheses `')'`. The integer division should **truncate toward zero**. You may assume that the given expression is always v...
null
Array,Divide and Conquer,Tree,Matrix
Medium
null
1,716
hey everybody this is glav this is day six of the Leo day challenge hit the like button hit the Subscribe and join me on Discord let me know what you think about today's PR uh today I have no intro just because uh I'm actually doing in the morning uh and I didn't find for it but uh but the timing actually worked out to...
Calculate Money in Leetcode Bank
maximum-non-negative-product-in-a-matrix
Hercy wants to save money for his first car. He puts money in the Leetcode bank **every day**. He starts by putting in `$1` on Monday, the first day. Every day from Tuesday to Sunday, he will put in `$1` more than the day before. On every subsequent Monday, he will put in `$1` more than the **previous Monday**. Given...
Use Dynamic programming. Keep the highest value and lowest value you can achieve up to a point.
Array,Dynamic Programming,Matrix
Medium
null
1,383
hello everyone welcome to codex camp we are at fifth day of june record challenge and the problem we are going to cover in this video is maximum performance of a team the input given here is again which represent the number of employees and we have given two integer arrays one is speed of employees another one is effic...
Maximum Performance of a Team
number-of-single-divisor-triplets
You are given two integers `n` and `k` and two integer arrays `speed` and `efficiency` both of length `n`. There are `n` engineers numbered from `1` to `n`. `speed[i]` and `efficiency[i]` represent the speed and efficiency of the `ith` engineer respectively. Choose **at most** `k` different engineers out of the `n` en...
The maximum value of nums.length is very large, but the maximum value of nums[i] is not. Count the number of times each value appears in nums. Brute force through every possible combination of values and count how many single divisor triplets can be made with that combination of values.
Math
Medium
2301
341
hey guys this video is a little bit special and because i came across this question today in my uh interview with google uh so let's walk through it and this is a big call number 341 flatten nasty this iterator so uh let's dive in uh to the example so you can see the element in the list it can be a list or it can be a ...
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,220
hi everyone with Calvin here so let's discuss about weekly contest 157 for question count for one permutation so we are given M and it's the length of the string that we want to form and this thing can be form only by our letter and there are five rules here which saying about if our last character is a and the next ch...
Count Vowels Permutation
smallest-sufficient-team
Given an integer `n`, your task is to count how many strings of length `n` can be formed under the following rules: * Each character is a lower case vowel (`'a'`, `'e'`, `'i'`, `'o'`, `'u'`) * Each vowel `'a'` may only be followed by an `'e'`. * Each vowel `'e'` may only be followed by an `'a'` or an `'i'`. * ...
Do a bitmask DP. For each person, for each set of skills, we can update our understanding of a minimum set of people needed to perform this set of skills.
Array,Dynamic Programming,Bit Manipulation,Bitmask
Hard
2105,2114
1,727
Hello everyone Welcome to my channel here I solve problems Lead code today task number 1727 is the largest under Matrix with permutations we are given a binary Matrix of size M by N and we are also allowed to rearrange the columns of the matrix in any order we need to return the area of ​​the largest under matrices ret...
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
5
foreign called longest palindrome accept string it is a medium let's get started given a string s return the longest palindromic substring in X so just to recap what a palindrome is it reads the same forward and backwards so a common one is a race car reading this backwards we have r-a-c-e r-a-c-e r-a-c-e c-a-r so it's...
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,832
hello everyone welcome to harsha lectures in this lecture i am going to explain you about check if the sentence is pangram or not okay so here pancream means user will give one sentence so in that sentence we need to check all alphabetical name all alphabetical letters are there or not so here a pancream is a sentence ...
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
860
what's up guys Nick white here and I am very tired I'm doing so many problems but it's gonna be worth it maybe I don't know maybe won't be worth it I don't know why I committed to doing all these problems but this one's easy so that's a little piece of you know whatever it's goodness so this lemonade change also check ...
Lemonade Change
design-circular-queue
At a lemonade stand, each lemonade costs `$5`. Customers are standing in a queue to buy from you and order one at a time (in the order specified by bills). Each customer will only buy one lemonade and pay with either a `$5`, `$10`, or `$20` bill. You must provide the correct change to each customer so that the net tran...
null
Array,Linked List,Design,Queue
Medium
859,1767
128
hey guys Greg here and let's solve longest consecutive sequence so we're given an unsorted array of integers nums and we need to return the length of the longest consecutive elements sequence this is such a confusingly written problem and it's much better with the example so if you look right here we have 100 4 200 1 3...
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
1,991
all right so let's talk about the fun and middle index in Array so uh what it means is pretty straightforward so just find the leftmost middle index and the middle index is an index where num zero plus nums one plus all the way to in Middle East minus one equal to the middle index plus one and plus all the way until nu...
Find the Middle Index in Array
league-statistics
Given a **0-indexed** integer array `nums`, find the **leftmost** `middleIndex` (i.e., the smallest amongst all the possible ones). A `middleIndex` is an index where `nums[0] + nums[1] + ... + nums[middleIndex-1] == nums[middleIndex+1] + nums[middleIndex+2] + ... + nums[nums.length-1]`. If `middleIndex == 0`, the lef...
null
Database
Medium
null
11
hello so today while doing this problem called container with Moore's water and problem says we get an array of integers such that each represents a point coordinates that are by I the index and a I so the I if the index in the array is the x-coordinate and a I the value in is the x-coordinate and a I the value in is t...
Container With Most Water
container-with-most-water
You are given an integer array `height` of length `n`. There are `n` vertical lines drawn such that the two endpoints of the `ith` line are `(i, 0)` and `(i, height[i])`. Find two lines that together with the x-axis form a container, such that the container contains the most water. Return _the maximum amount of water...
The aim is to maximize the area formed between the vertical lines. The area of any container is calculated using the shorter line as length and the distance between the lines as the width of the rectangle. Area = length of shorter vertical line * distance between lines We can definitely get the maximum width ...
Array,Two Pointers,Greedy
Medium
42
313
hey hello there today I'm looking at the questions 313 super ugly number we have to write a program to find the ANSF ugly super ugly number the definition for this super ugly number is that it is a positive number integer number whose all prime factors are in a given set of prime numbers we have and also that one is co...
Super Ugly Number
super-ugly-number
A **super ugly number** is a positive integer whose prime factors are in the array `primes`. Given an integer `n` and an array of integers `primes`, return _the_ `nth` _**super ugly number**_. The `nth` **super ugly number** is **guaranteed** to fit in a **32-bit** signed integer. **Example 1:** **Input:** n = 12, ...
null
Array,Hash Table,Math,Dynamic Programming,Heap (Priority Queue)
Medium
264
1,720
we given an input array and a first value we want to decode it based on the following formula seen here with xor and first value you'll notice that we want the red values to be output and you should know that the inverse of xor is xor itself so we can change these formulas into these formulas giving our result here you...
Decode XORed Array
crawler-log-folder
There is a **hidden** integer array `arr` that consists of `n` non-negative integers. It was encoded into another integer array `encoded` of length `n - 1`, such that `encoded[i] = arr[i] XOR arr[i + 1]`. For example, if `arr = [1,0,2,1]`, then `encoded = [1,2,3]`. You are given the `encoded` array. You are also give...
Simulate the process but don’t move the pointer beyond the main folder. Simulate the process but don’t move the pointer beyond the main folder.
Array,String,Stack
Easy
682,874
1,094
hey what's up guys this is sean here so uh today uh let's take a look at this uh lead called problem 1094 carpooling uh medium level problem i think it's not that hard but it's i think it's worth sharing with you guys a few uh ver a few solutions different solutions for this problem you know okay so you're driving on l...
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
455
Hello friends, in this problem we have been given some children and we have been given some cookies. We have to give at most one cookie to each child. Each child has a specific requirement that he wants a cookie of this particular size or that particular If he will not take a cookie of the same size or bigger or smalle...
Assign Cookies
assign-cookies
Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child `i` has a greed factor `g[i]`, which is the minimum size of a cookie that the child will be content with; and each cookie `j` has a size `s[j]`. If `s[j] >= g[i]`, we can assign ...
null
Array,Greedy,Sorting
Easy
null
77
okay this is throwing the number 77 combinations in this very simple problem the two integers n and k are given with a possible combination of k numbers out 0 1 from 1 to n you may written the answer in any order so let's see there example number one and it's poor so the all the possible uh sample we can pick is one tw...
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
148
hello everyone welcome or welcome back to my channel so today we are going to discuss another problem before going forward if you've not liked the video please like it subscribe to my channel and hit the bell icon so that you get notified whenever i post a new video so without any further ado let's get started so uh so...
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
763
Hello Super Singh Good Morning Good Afternoon Good Evening Time Video Problem Subscribe Side Subscribe Channel Subscribe Sure Partition post-partition Subscribe Sure Partition post-partition Subscribe Sure Partition post-partition Peeth Friend Character Pimpri Director Lies In Only One Subscribe To And Posting Richest ...
Partition Labels
special-binary-string
You are given a string `s`. We want to partition the string into as many parts as possible so that each letter appears in at most one part. Note that the partition is done so that after concatenating all the parts in order, the resultant string should be `s`. Return _a list of integers representing the size of these ...
Draw a line from (x, y) to (x+1, y+1) if we see a "1", else to (x+1, y-1). A special substring is just a line that starts and ends at the same y-coordinate, and that is the lowest y-coordinate reached. Call a mountain a special substring with no special prefixes - ie. only at the beginning and end is the lowest y-coo...
String,Recursion
Hard
678
1,903
all right so let's talk about the largest odd numbering stream so you're giving a example so basically you just want to check every single digit from the last one to the first one and then to see if every single digit is what is even or out so if this is even then just skip if the last digit so you're starting from her...
Largest Odd Number in String
design-most-recently-used-queue
You are given a string `num`, representing a large integer. Return _the **largest-valued odd** integer (as a string) that is a **non-empty substring** of_ `num`_, or an empty string_ `" "` _if no odd integer exists_. A **substring** is a contiguous sequence of characters within a string. **Example 1:** **Input:** nu...
You can store the data in an array and apply each fetch by moving the ith element to the end of the array (i.e, O(n) per operation). A better way is to use the square root decomposition technique. You can build chunks of size sqrt(n). For each fetch operation, You can search for the chunk which has the ith element and ...
Array,Hash Table,Stack,Design,Binary Indexed Tree,Ordered Set
Medium
146
77
Hello gas welcome to me youtube channel so today we are going to solve cheat code problem 77 combinations so what is the question that we have been given two numbers n and k and we have to find all the possible combinations of the size of k. I have to find out and number from where do I have to do the number thing, onc...
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
1,192
looky guys in this episode let's look at the lead code problem one nine two and the problem title is find all critical connections in a network let me quickly go through the problem statement see is that given an undirected graph find on critical connections inside it we'll see so this is the sample graph given to you ...
Critical Connections in a Network
divide-chocolate
There are `n` servers numbered from `0` to `n - 1` connected by undirected server-to-server `connections` forming a network where `connections[i] = [ai, bi]` represents a connection between servers `ai` and `bi`. Any server can reach other servers directly or indirectly through the network. A _critical connection_ is ...
After dividing the array into K+1 sub-arrays, you will pick the sub-array with the minimum sum. Divide the sub-array into K+1 sub-arrays such that the minimum sub-array sum is as maximum as possible. Use binary search with greedy check.
Array,Binary Search
Hard
410,1056
746
That God Today In This Video Will Give Water Problems From Its Problem Minimum Cost Climate So Let's Problem Statement States That Give Not Interior Cost Where Is The Cost For Is The Cost Of The Five Step On Shades Problem And Subscribe School Nov15 Separate Live One And to like going to subscribe by clicking on the li...
Min Cost Climbing Stairs
prefix-and-suffix-search
You are given an integer array `cost` where `cost[i]` is the cost of `ith` step on a staircase. Once you pay the cost, you can either climb one or two steps. You can either start from the step with index `0`, or the step with index `1`. Return _the minimum cost to reach the top of the floor_. **Example 1:** **Input...
For a word like "test", consider "#test", "t#test", "st#test", "est#test", "test#test". Then if we have a query like prefix = "te", suffix = "t", we can find it by searching for something we've inserted starting with "t#te".
String,Design,Trie
Hard
211
518
hello everyone it's m satchel again and today we're going to solve another programming challenge this is actually the fourth problem in our series which was supposed to be 100 problems solved the website would be lead code but this time one of my friends has sent me this problem so let's just go through it and see what...
Coin Change II
coin-change-2
You are given an integer array `coins` representing coins of different denominations and an integer `amount` representing a total amount of money. Return _the number of combinations that make up that amount_. If that amount of money cannot be made up by any combination of the coins, return `0`. You may assume that yo...
null
Array,Dynamic Programming
Medium
1393
20
in this episode of coding adventures we're gonna implement valid pagan thesis from lead code so let's get started if we get here the text of the problem it's also an easy problem it says that we're gonna receive a string of characters made out only of these brackets like three types of brackets and we need to determine...
Valid Parentheses
valid-parentheses
Given a string `s` containing just the characters `'('`, `')'`, `'{'`, `'}'`, `'['` and `']'`, determine if the input string is valid. An input string is valid if: 1. Open brackets must be closed by the same type of brackets. 2. Open brackets must be closed in the correct order. 3. Every close bracket has a corres...
An interesting property about a valid parenthesis expression is that a sub-expression of a valid expression should also be a valid expression. (Not every sub-expression) e.g. { { } [ ] [ [ [ ] ] ] } is VALID expression [ [ [ ] ] ] is VALID sub-expression { } [ ] is VALID sub-express...
String,Stack
Easy
22,32,301,1045,2221
1,187
um hello so today we are going to do this problem which is part of with code daily challenge make array strictly increasing so with this problem we have two arrays we have array one and we have array two and we want to return the minimum number of operations it's possibly zero that we need to make array 1 increasing ok...
Make Array Strictly Increasing
print-foobar-alternately
Given two integer arrays `arr1` and `arr2`, return the minimum number of operations (possibly zero) needed to make `arr1` strictly increasing. In one operation, you can choose two indices `0 <= i < arr1.length` and `0 <= j < arr2.length` and do the assignment `arr1[i] = arr2[j]`. If there is no way to make `arr1` str...
null
Concurrency
Medium
1203,1216
95
hey everyone today we are going to solve the little question unique binary search V2 so you are given integer and return all the structurally unique binary search V which has exactly any nodes of unique values from 1 to n returning the answer in any order so let's see the example so you are given n equals 3 and we can ...
Unique Binary Search Trees II
unique-binary-search-trees-ii
Given an integer `n`, return _all the structurally unique **BST'**s (binary search trees), which has exactly_ `n` _nodes of unique values from_ `1` _to_ `n`. Return the answer in **any order**. **Example 1:** **Input:** n = 3 **Output:** \[\[1,null,2,null,3\],\[1,null,3,2\],\[2,1,3\],\[3,1,null,null,2\],\[3,2,null,1\...
null
Dynamic Programming,Backtracking,Tree,Binary Search Tree,Binary Tree
Medium
96,241
41
hello everyone so today we're going to do the problem number 41 on lead code which is finding the first missing positive so we're given an array and we have to find the smallest positive integer that is not in the array so like this one you have one two zero the smallest integer that's not in the array is three here yo...
First Missing Positive
first-missing-positive
Given an unsorted integer array `nums`, return the smallest missing positive integer. You must implement an algorithm that runs in `O(n)` time and uses constant extra space. **Example 1:** **Input:** nums = \[1,2,0\] **Output:** 3 **Explanation:** The numbers in the range \[1,2\] are all in the array. **Example 2:*...
Think about how you would solve the problem in non-constant space. Can you apply that logic to the existing space? We don't care about duplicates or non-positive integers Remember that O(2n) = O(n)
Array,Hash Table
Hard
268,287,448,770
64
sound test hello everybody I'm Erica and this will be problem minimum puffs some likely it will be in a graph or a greet given the rectangular grid filled with non-negative numbers grid filled with non-negative numbers grid filled with non-negative numbers find the path from top left about the right which minimizes the...
Minimum Path Sum
minimum-path-sum
Given a `m x n` `grid` filled with non-negative numbers, find a path from top left to bottom right, which minimizes the sum of all numbers along its path. **Note:** You can only move either down or right at any point in time. **Example 1:** **Input:** grid = \[\[1,3,1\],\[1,5,1\],\[4,2,1\]\] **Output:** 7 **Explanat...
null
Array,Dynamic Programming,Matrix
Medium
62,174,741,2067,2192
961
let's go over question number 961 and repeat the element in size 2n array now the question says in an array a of size 2n there are n plus 1 unique elements so we have n plus 1 number of unique elements and exactly one of these elements is repeated n times return the element repeated end time so what we want to do is yo...
N-Repeated Element in Size 2N Array
long-pressed-name
You are given an integer array `nums` with the following properties: * `nums.length == 2 * n`. * `nums` contains `n + 1` **unique** elements. * Exactly one element of `nums` is repeated `n` times. Return _the element that is repeated_ `n` _times_. **Example 1:** **Input:** nums = \[1,2,3,3\] **Output:** 3 **...
null
Two Pointers,String
Easy
null
159
hello and welcome today we're doing a question from lee code called longest substring with at most two distinct characters it's a medium let's get started given a string s find the length of the longest substring t that contains at most two distinct characters example one given the input e c e v a we output three becau...
Longest Substring with At Most Two Distinct Characters
longest-substring-with-at-most-two-distinct-characters
Given a string `s`, return _the length of the longest_ _substring_ _that contains at most **two distinct characters**_. **Example 1:** **Input:** s = "eceba " **Output:** 3 **Explanation:** The substring is "ece " which its length is 3. **Example 2:** **Input:** s = "ccaabbb " **Output:** 5 **Explanation:** The ...
null
Hash Table,String,Sliding Window
Medium
3,239,340,1034
1,761
hello welcome back today let's try to solve another lead code problem 1761 minimum degree of our connected Trail in a graph so this drill means a triangle which are conducted so the trail just means a triangle so we just need to return the minimum degree of a connected tree in a graph or -1 if the graph has no in a gra...
Minimum Degree of a Connected Trio in a Graph
count-sorted-vowel-strings
You are given an undirected graph. You are given an integer `n` which is the number of nodes in the graph and an array `edges`, where each `edges[i] = [ui, vi]` indicates that there is an undirected edge between `ui` and `vi`. A **connected trio** is a set of **three** nodes where there is an edge between **every** pa...
For each character, its possible values will depend on the value of its previous character, because it needs to be not smaller than it. Think backtracking. Build a recursive function count(n, last_character) that counts the number of valid strings of length n and whose first characters are not less than last_character....
Dynamic Programming
Medium
null
26
in this video we'll go over lead code question number 26 remove duplicates from a sorted array given an integer array nums that is sorted in increasing order we need to remove all duplicate elements in place but there's a Twist instead of actually removing the elements we can just modify it so let's say there are K uni...
Remove Duplicates from Sorted Array
remove-duplicates-from-sorted-array
Given an integer array `nums` sorted in **non-decreasing order**, remove the duplicates [**in-place**](https://en.wikipedia.org/wiki/In-place_algorithm) such that each unique element appears only **once**. The **relative order** of the elements should be kept the **same**. Then return _the number of unique elements in_...
In this problem, the key point to focus on is the input array being sorted. As far as duplicate elements are concerned, what is their positioning in the array when the given array is sorted? Look at the image above for the answer. If we know the position of one of the elements, do we also know the positioning of all th...
Array,Two Pointers
Easy
27,80
1,041
That further this volume to coding decoding rohit singh bobonga dental clinic and 150 grams daily the robot boy suit on and heard your ₹10 exit available and heard your ₹10 exit available and heard your ₹10 exit available average selling mini this vitamin e hu is the robot is for me so e can any person wash the year Ta...
Robot Bounded In Circle
available-captures-for-rook
On an infinite plane, a robot initially stands at `(0, 0)` and faces north. Note that: * The **north direction** is the positive direction of the y-axis. * The **south direction** is the negative direction of the y-axis. * The **east direction** is the positive direction of the x-axis. * The **west direction**...
null
Array,Matrix,Simulation
Easy
null
915
That Hello one my name is and today we are going to call a collection in the address model whose name is partition and your interest rate so what is the exact question and how to get it then we will click on it let's quit okay so Before calling this question, one special thing is asked of you that you will have to do t...
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
230
hi everyone welcome back in this video we're going to solve liquco 230 which is the cave smallest element in a virus search tree so it's a medium problem it needs a parent search type problem so let's run out the prom We are given the root of a binary search tree in integer K we must return the cave smallest value of a...
Kth Smallest Element in a BST
kth-smallest-element-in-a-bst
Given the `root` of a binary search tree, and an integer `k`, return _the_ `kth` _smallest value (**1-indexed**) of all the values of the nodes in the tree_. **Example 1:** **Input:** root = \[3,1,4,null,2\], k = 1 **Output:** 1 **Example 2:** **Input:** root = \[5,3,6,2,4,null,null,1\], k = 3 **Output:** 3 **Cons...
Try to utilize the property of a BST. Try in-order traversal. (Credits to @chan13) What if you could modify the BST node's structure? The optimal runtime complexity is O(height of BST).
Tree,Depth-First Search,Binary Search Tree,Binary Tree
Medium
94,671
56
hi everyone today we'll be talking about merge intervals that's problem number 56 on leak code and it's one of the questions from blind 75 so let's get straight into it given an array of intervals where the interval i which is the element has a start and the end merge all the overlapping intervals and return an array o...
Merge Intervals
merge-intervals
Given an array of `intervals` where `intervals[i] = [starti, endi]`, merge all overlapping intervals, and return _an array of the non-overlapping intervals that cover all the intervals in the input_. **Example 1:** **Input:** intervals = \[\[1,3\],\[2,6\],\[8,10\],\[15,18\]\] **Output:** \[\[1,6\],\[8,10\],\[15,18\]\...
null
Array,Sorting
Medium
57,252,253,495,616,715,761,768,1028,2297,2319
350
all right welcome back to the study planned data structure in depth day three today we will have two related to two problems related with race the second one is already solved in my channel so i will just put this in this playlist and now i will solve this the first one the name of this question let's see intersection ...
Intersection of Two Arrays II
intersection-of-two-arrays-ii
Given two integer arrays `nums1` and `nums2`, return _an array of their intersection_. Each element in the result must appear as many times as it shows in both arrays and you may return the result in **any order**. **Example 1:** **Input:** nums1 = \[1,2,2,1\], nums2 = \[2,2\] **Output:** \[2,2\] **Example 2:** **I...
null
Array,Hash Table,Two Pointers,Binary Search,Sorting
Easy
349,1044,1392,2282
1,754
hi folks let's solve largest merge of two strings if you haven't read the problem you can take some time to read it the problem is we are given two strings rule one and word two and we want to construct a new string how to control it will merge in the following way we can either fix the first character in word one or w...
Largest Merge Of Two Strings
largest-merge-of-two-strings
You are given two strings `word1` and `word2`. You want to construct a string `merge` in the following way: while either `word1` or `word2` are non-empty, choose **one** of the following options: * If `word1` is non-empty, append the **first** character in `word1` to `merge` and delete it from `word1`. * For e...
null
null
Medium
null
911
hey everybody this is Larry this is me doing an extra bonus to have attemp problem uh an RNG so let's go hit the like button hit the Subscribe button join me on Discord let me know what you think about this one especially since the other actual daily PR is a what is it power of two I don't even remember already that wa...
Online Election
profitable-schemes
You are given two integer arrays `persons` and `times`. In an election, the `ith` vote was cast for `persons[i]` at time `times[i]`. For each query at a time `t`, find the person that was leading the election at time `t`. Votes cast at time `t` will count towards our query. In the case of a tie, the most recent vote (...
null
Array,Dynamic Programming
Hard
null
257
hey everybody this is larry this is me doing the bonus question for the 1st of august let's do a quick one let's do something i haven't done before let's uh do a random let the computer decide hit the like button hit the subscribe button join me on discord let me know what you think about this setup and uh we get a yee...
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
1,933
hi there i'm texas tim thanks for tuning in to my ongoing quest to grind through all the algorithm problems on leak code i have completed all the easy ones and now i'm working on the medium ones although sometimes leak code adds some new easy ones and so i go back and pick those off so why don't we see what lee code ha...
Check if String Is Decomposable Into Value-Equal Substrings
number-of-different-integers-in-a-string
A **value-equal** string is a string where **all** characters are the same. * For example, `"1111 "` and `"33 "` are value-equal strings. * In contrast, `"123 "` is not a value-equal string. Given a digit string `s`, decompose the string into some number of **consecutive value-equal** substrings where **exactly o...
Try to split the string so that each integer is in a different string. Try to remove each integer's leading zeroes and compare the strings to find how many of them are unique.
Hash Table,String
Easy
null
1,447
hey everybody this is Larry I'm doing this problem as part of a contest so you're gonna watch me live as I go through my daughter's I'm coding they've been explanation near the end and for more context they'll be a link below on this actual screen cats of the contest how did you do let me know you do hit the like butto...
Simplified Fractions
jump-game-iv
Given an integer `n`, return _a list of all **simplified** fractions between_ `0` _and_ `1` _(exclusive) such that the denominator is less-than-or-equal-to_ `n`. You can return the answer in **any order**. **Example 1:** **Input:** n = 2 **Output:** \[ "1/2 "\] **Explanation:** "1/2 " is the only unique fraction wit...
Build a graph of n nodes where nodes are the indices of the array and edges for node i are nodes i+1, i-1, j where arr[i] == arr[j]. Start bfs from node 0 and keep distance. The answer is the distance when you reach node n-1.
Array,Hash Table,Breadth-First Search
Hard
2001
606
hey everyone welcome back and let's write some more neat code today so today let's solve the problem construct string from binary tree before we get started i just want to mention if you haven't heard i recently launched neat code pro there's a 25 off launch sale going on right now you can get lifetime access to all cu...
Construct String from Binary Tree
construct-string-from-binary-tree
Given the `root` of a binary tree, construct a string consisting of parenthesis and integers from a binary tree with the preorder traversal way, and return it. Omit all the empty parenthesis pairs that do not affect the one-to-one mapping relationship between the string and the original binary tree. **Example 1:** *...
null
String,Tree,Depth-First Search,Binary Tree
Easy
536,652
278
Hello Hi Guys Welcome Back To My Channel Tu Yaar Swagat Hai Once Question Me Family Was This Year's In This Today We Are Going To Discuss The First Version We Had Said In The Last Video That This Is The Category That Is Going On I Will Name It Pyaar Basic Questions and Binary Search Category is ok, I am giving basic an...
First Bad Version
first-bad-version
You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the previous version, all the versions after a bad version are also bad. Suppose you have `n` versions `[1, 2, ..., n]` an...
null
Binary Search,Interactive
Easy
34,35,374
341
Hello Guys Welcome Water Mist President Loot In This Question Thursday Elements Class One Officer subscribe this Video give Video Please subscribe And subscribe The Amazing Difficult Subscribe Quid Left So Let's Robbers Loot Cash Withdrawal Necklace VCES Can They Have Three Idiots Rich Wives Subscribe Electronic Atal B...
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
283
foreign other problem from uh Ray category uh called Moon zeros uh in this always we will start with our problem statement input output and then move to an uh concrete example and then finally conduct the solution so in this case we have a pretty safe for a problem statement we only have one input which is sent jury ca...
Move Zeroes
move-zeroes
Given an integer array `nums`, move all `0`'s to the end of it while maintaining the relative order of the non-zero elements. **Note** that you must do this in-place without making a copy of the array. **Example 1:** **Input:** nums = \[0,1,0,3,12\] **Output:** \[1,3,12,0,0\] **Example 2:** **Input:** nums = \[0\]...
In-place means we should not be allocating any space for extra array. But we are allowed to modify the existing array. However, as a first step, try coming up with a solution that makes use of additional space. For this problem as well, first apply the idea discussed using an additional array and the in-place solution ...
Array,Two Pointers
Easy
27
1,930
hello everyone and good morning to all of you today we have problem which name is unique length 3 paric subsequences lead code 1 1930 problem so before going forward in this video please make sure that you have liked and subscribed to this Channel and also it's my advice to all of you that please read the problem and u...
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
1,035
hey everyone welcome back today we are going to see problem number 1035 uncrossed lights first you will see the explanation of the problem statement then the logic and the code now let's dive into the solution so here I have the first example from the Liker website so here we are given two input arrays nums 1 and num2 ...
Uncrossed Lines
cousins-in-binary-tree
You are given two integer arrays `nums1` and `nums2`. We write the integers of `nums1` and `nums2` (in the order they are given) on two separate horizontal lines. We may draw connecting lines: a straight line connecting two numbers `nums1[i]` and `nums2[j]` such that: * `nums1[i] == nums2[j]`, and * the line we d...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Easy
102
725
Hello Hi Guys Welcome At Least Three People Doing The Soldier's Problem September Challenge Its Play List Part Plus To The Problem British Sexual Speaker Latest Tips And Avoid Okay To Given Her Lips And Teachers Play List * Quantity List Subscribe Now To Parts Puberty With U That World Let's Come Parts Been Also Apart ...
Split Linked List in Parts
split-linked-list-in-parts
Given the `head` of a singly linked list and an integer `k`, split the linked list into `k` consecutive linked list parts. The length of each part should be as equal as possible: no two parts should have a size differing by more than one. This may lead to some parts being null. The parts should be in the order of occ...
If there are N nodes in the list, and k parts, then every part has N/k elements, except the first N%k parts have an extra one.
Linked List
Medium
61,328
266
hello everybody this is a male with another cognitive preparation video for you and this time I'm going to show you this problem palindrome permutation so given a string determining if a permutation of the string could form a palindrome so they give you a string and can you rearrange it such that what you get is a pali...
Palindrome Permutation
palindrome-permutation
Given a string `s`, return `true` _if a permutation of the string could form a_ _**palindrome**_ _and_ `false` _otherwise_. **Example 1:** **Input:** s = "code " **Output:** false **Example 2:** **Input:** s = "aab " **Output:** true **Example 3:** **Input:** s = "carerac " **Output:** true **Constraints:** ...
Consider the palindromes of odd vs even length. What difference do you notice? Count the frequency of each character. If each character occurs even number of times, then it must be a palindrome. How about character which occurs odd number of times?
Hash Table,String,Bit Manipulation
Easy
5,242,267,409
1,926
all right welcome to my next newest video where I'll take you through my process as I solve a random elak code and I'll walk you through my approach to seeing it for the first time and then um afterwards I'll walk through the Optimal Solutions afterwards so let's begin let's choose another medium the last two have been...
Nearest Exit from Entrance in Maze
products-price-for-each-store
You are given an `m x n` matrix `maze` (**0-indexed**) with empty cells (represented as `'.'`) and walls (represented as `'+'`). You are also given the `entrance` of the maze, where `entrance = [entrancerow, entrancecol]` denotes the row and column of the cell you are initially standing at. In one step, you can move o...
null
Database
Easy
1948
342
hey this is Topher with a lonely Dash and today we're going over lead code question 342 power of four which states given an integer n return true if it is a power of four otherwise return false an integer N is a power of four if there exists an integer X such that n = 4 to exists an integer X such that n = 4 to exists ...
Power of Four
power-of-four
Given an integer `n`, return _`true` if it is a power of four. Otherwise, return `false`_. An integer `n` is a power of four, if there exists an integer `x` such that `n == 4x`. **Example 1:** **Input:** n = 16 **Output:** true **Example 2:** **Input:** n = 5 **Output:** false **Example 3:** **Input:** n = 1 **O...
null
Math,Bit Manipulation,Recursion
Easy
231,326
1,508
Hello Friends Welcome Back Coordinator Bring this channel on Great Difficulty Channel Please Share subscribe Hafte Ghanta Playlist Cover Various Categories of Problem Certificates That Link Click Asli Streets Grams in Programming and Maun President Ayub Upload Vote for This Prompted The Repository in Delhi From Descrip...
Range Sum of Sorted Subarray Sums
longest-happy-prefix
You are given the array `nums` consisting of `n` positive integers. You computed the sum of all non-empty continuous subarrays from the array and then sorted them in non-decreasing order, creating a new array of `n * (n + 1) / 2` numbers. _Return the sum of the numbers from index_ `left` _to index_ `right` (**indexed ...
Use Longest Prefix Suffix (KMP-table) or String Hashing.
String,Rolling Hash,String Matching,Hash Function
Hard
2326
1,688
Hello everyone welcome to my channel Quote Surrey with Mike So today we are going to do video number four of our playlist of lead code easy, okay the lead is number 1688 easy is marked count of matches in tournament Microsoft has asked this question so this The question seems very easy and actually it is also easy but ...
Count of Matches in Tournament
the-most-recent-orders-for-each-product
You are given an integer `n`, the number of teams in a tournament that has strange rules: * If the current number of teams is **even**, each team gets paired with another team. A total of `n / 2` matches are played, and `n / 2` teams advance to the next round. * If the current number of teams is **odd**, one team ...
null
Database
Medium
1671,1735
1,712
hey everybody this is larry this is q3 of the weekly leco contest ways to split it away into three step away um yeah hit the like button to subscribe and join me on discord uh let me know what you think about this problem i had a lot of issues with this problem uh solving it i mean the problem is perfectly fine um it's...
Ways to Split Array Into Three Subarrays
unique-orders-and-customers-per-month
A split of an integer array is **good** if: * The array is split into three **non-empty** contiguous subarrays - named `left`, `mid`, `right` respectively from left to right. * The sum of the elements in `left` is less than or equal to the sum of the elements in `mid`, and the sum of the elements in `mid` is less ...
null
Database
Easy
null
1,078
hello everybody and welcome back to the DCC channel where in this series we solve litko technical interview questions later on probably some other technical interview questions when I'm done with all the little cold ones and let's see let's try occurences after bigram sounds weird so 10 1078 occurrences after bigram gi...
Occurrences After Bigram
remove-outermost-parentheses
Given two strings `first` and `second`, consider occurrences in some text of the form `"first second third "`, where `second` comes immediately after `first`, and `third` comes immediately after `second`. Return _an array of all the words_ `third` _for each occurrence of_ `"first second third "`. **Example 1:** **In...
Can you find the primitive decomposition? The number of ( and ) characters must be equal.
String,Stack
Easy
null
1,937
all right today i'm going to talk about question one 1937 maximum number of points was cost so the idea is we want to find a direct path from the first row to the last row and we want to sum up the numbers together we want to find the maximum sum that we can find from a pass and one caveat is there's a cost if you want...
Maximum Number of Points with Cost
maximize-the-beauty-of-the-garden
You are given an `m x n` integer matrix `points` (**0-indexed**). Starting with `0` points, you want to **maximize** the number of points you can get from the matrix. To gain points, you must pick one cell in **each row**. Picking the cell at coordinates `(r, c)` will **add** `points[r][c]` to your score. However, yo...
Consider every possible beauty and its first and last index in flowers. Remove all flowers with negative beauties within those indices.
Array,Greedy,Prefix Sum
Hard
null
902
hello everyone welcome to quartus camp we are at 18th day of december lead code challenge and the problem we are going to cover in this video is number at most yen given digit set so the input given here is a set of digits which are in the string format and an integer yen and we have to return the number of possible nu...
Numbers At Most N Given Digit Set
minimum-number-of-refueling-stops
Given an array of `digits` which is sorted in **non-decreasing** order. You can write numbers using each `digits[i]` as many times as we want. For example, if `digits = ['1','3','5']`, we may write numbers such as `'13'`, `'551'`, and `'1351315'`. Return _the number of positive integers that can be generated_ that are...
null
Array,Dynamic Programming,Greedy,Heap (Priority Queue)
Hard
null
1,004
Guy Hello you are doing 90 days software engineering prep with me this is 16 questions lead code is 75 overall question lead code is 1004 maximum code and this question represents a category which I call acquire release category ok sliding window only It happens from the acquire release, I give it a name, then tell me ...
Max Consecutive Ones III
least-operators-to-express-number
Given a binary array `nums` and an integer `k`, return _the maximum number of consecutive_ `1`_'s in the array if you can flip at most_ `k` `0`'s. **Example 1:** **Input:** nums = \[1,1,1,0,0,0,1,1,1,1,0\], k = 2 **Output:** 6 **Explanation:** \[1,1,1,0,0,**1**,1,1,1,1,**1**\] Bolded numbers were flipped from 0 to 1....
null
Math,Dynamic Programming
Hard
null
1,011
hello everyone let's try to be a cheat code ninja today in this problem we are going to see a very uncommon programming pattern in which we try to reverse fit some solutions and see if they are valid or not so let's begin with the problem statement we are given some packages and their weights and we have to load those ...
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
107
alright so this lead code question is called binary tree level order traversal - it says given a binary tree return the - it says given a binary tree return the - it says given a binary tree return the bottom-up order traversal of its nodes bottom-up order traversal of its nodes bottom-up order traversal of its nodes v...
Binary Tree Level Order Traversal II
binary-tree-level-order-traversal-ii
Given the `root` of a binary tree, return _the bottom-up level order traversal of its nodes' values_. (i.e., from left to right, level by level from leaf to root). **Example 1:** **Input:** root = \[3,9,20,null,null,15,7\] **Output:** \[\[15,7\],\[9,20\],\[3\]\] **Example 2:** **Input:** root = \[1\] **Output:** \[...
null
Tree,Breadth-First Search,Binary Tree
Medium
102,637
1,032
Hello everyone welcome to family without forced engineering and tenth standard electronic subscribe to the Video then subscribe to subscribe our Channel subscribe Video 's Seams Characters List 122 Electronic Bulb Skin Subscribe Now Subscribe That Matchbox with Input Border Not the ID Key Handi Aapke Govinda Notificati...
Stream of Characters
satisfiability-of-equality-equations
Design an algorithm that accepts a stream of characters and checks if a suffix of these characters is a string of a given array of strings `words`. For example, if `words = [ "abc ", "xyz "]` and the stream added the four characters (one by one) `'a'`, `'x'`, `'y'`, and `'z'`, your algorithm should detect that the suf...
null
Array,String,Union Find,Graph
Medium
null
11
water you're doing an integer array height of length n there are n vertical lines drawn such that the two endpoints of ith line are I zero and I height I find two lines that together with x-axis find two lines that together with x-axis find two lines that together with x-axis from a form a container such that the conta...
Container With Most Water
container-with-most-water
You are given an integer array `height` of length `n`. There are `n` vertical lines drawn such that the two endpoints of the `ith` line are `(i, 0)` and `(i, height[i])`. Find two lines that together with the x-axis form a container, such that the container contains the most water. Return _the maximum amount of water...
The aim is to maximize the area formed between the vertical lines. The area of any container is calculated using the shorter line as length and the distance between the lines as the width of the rectangle. Area = length of shorter vertical line * distance between lines We can definitely get the maximum width ...
Array,Two Pointers,Greedy
Medium
42
68
Hello brother, your knowledge portal has again come to Delhi Late with the challenge and today's problem is a very interesting problem and a hard problem and in the top interviews this is basically asked today. What is our problem? Today's problem is that we have an array of strings, okay and what is we have been given...
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
252
how's it going everybody we're gonna sit down and solve question number 252 meeting rooms we're gonna read the question understand it and then I'm gonna walk you through how you can effectively come up with a solution go step by step I'm not just gonna jump into a solution that's not what this channel is all about I wa...
Meeting Rooms
meeting-rooms
Given an array of meeting time `intervals` where `intervals[i] = [starti, endi]`, determine if a person could attend all meetings. **Example 1:** **Input:** intervals = \[\[0,30\],\[5,10\],\[15,20\]\] **Output:** false **Example 2:** **Input:** intervals = \[\[7,10\],\[2,4\]\] **Output:** true **Constraints:** * ...
null
Array,Sorting
Easy
56,253
174
or friends to the list of dungeon game this problem basically means we start from the left point and we try to reach the right bottom point and at the beginning we have an initial health point and we can either go right or go down and at each cell it has a integer and the weekend either increase our health point or dec...
Dungeon Game
dungeon-game
The demons had captured the princess and imprisoned her in **the bottom-right corner** of a `dungeon`. The `dungeon` consists of `m x n` rooms laid out in a 2D grid. Our valiant knight was initially positioned in **the top-left room** and must fight his way through `dungeon` to rescue the princess. The knight has an i...
null
Array,Dynamic Programming,Matrix
Hard
62,64,741,2354
304
hey guys i'm solving this question today uh from late code challenges so the question is given a 2d matrix handle multiple queries of the following type calculate the sum of the elements of matrix inside the rectangle defined by its upper left corner row one comma column one and lower right corner column so what's what...
Range Sum Query 2D - Immutable
range-sum-query-2d-immutable
Given a 2D matrix `matrix`, handle multiple queries of the following type: * Calculate the **sum** of the elements of `matrix` inside the rectangle defined by its **upper left corner** `(row1, col1)` and **lower right corner** `(row2, col2)`. Implement the `NumMatrix` class: * `NumMatrix(int[][] matrix)` Initial...
null
Array,Design,Matrix,Prefix Sum
Medium
303,308
201
hello guys welcome to my channel and I'm gonna solve the bitwise end of numbers range which is number 201 in lick codes so we're given the range from end to end where m and n is bigger than 0 and smaller than the maximum value of integer so we have to return the bitwise ends of all numbers in this range inclusive so le...
Bitwise AND of Numbers Range
bitwise-and-of-numbers-range
Given two integers `left` and `right` that represent the range `[left, right]`, return _the bitwise AND of all numbers in this range, inclusive_. **Example 1:** **Input:** left = 5, right = 7 **Output:** 4 **Example 2:** **Input:** left = 0, right = 0 **Output:** 0 **Example 3:** **Input:** left = 1, right = 2147...
null
Bit Manipulation
Medium
null
45
welcome to mazelico challenge today's problem is jump game two given an array of non-negative integers nums an array of non-negative integers nums an array of non-negative integers nums you are initially put positioned at the first index of the array each element in either ray represents your maximum jump length at tha...
Jump Game II
jump-game-ii
You are given a **0-indexed** array of integers `nums` of length `n`. You are initially positioned at `nums[0]`. Each element `nums[i]` represents the maximum length of a forward jump from index `i`. In other words, if you are at `nums[i]`, you can jump to any `nums[i + j]` where: * `0 <= j <= nums[i]` and * `i +...
null
Array,Dynamic Programming,Greedy
Medium
55,1428,2001
1,855
alright guys welcome back to study plan binary search day 11 the first problem for today the maximum distance between a pair of values so you are given through non-increasing so you are given through non-increasing so you are given through non-increasing zero indexed integer arrays number one and then a pair of additio...
Maximum Distance Between a Pair of Values
maximum-distance-between-a-pair-of-values
You are given two **non-increasing 0-indexed** integer arrays `nums1`​​​​​​ and `nums2`​​​​​​. A pair of indices `(i, j)`, where `0 <= i < nums1.length` and `0 <= j < nums2.length`, is **valid** if both `i <= j` and `nums1[i] <= nums2[j]`. The **distance** of the pair is `j - i`​​​​. Return _the **maximum distance** ...
null
null
Medium
null
63
in this video we're going to take a look at a legal problem called unique path number two so this question is very similar to unique paths number one i think you if you get that question you probably should be able to understand how to solve this problem so same thing here so the robot locates at the top left and every...
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
350
cool 350 intersection of two arrays to coming to a waist right and then write a function to compute the intersection and you have some bunch of examples are you share them in the associative search when you know the ya thinks going to follow up do we have to worry about them we still come in any order okay I mean I thi...
Intersection of Two Arrays II
intersection-of-two-arrays-ii
Given two integer arrays `nums1` and `nums2`, return _an array of their intersection_. Each element in the result must appear as many times as it shows in both arrays and you may return the result in **any order**. **Example 1:** **Input:** nums1 = \[1,2,2,1\], nums2 = \[2,2\] **Output:** \[2,2\] **Example 2:** **I...
null
Array,Hash Table,Two Pointers,Binary Search,Sorting
Easy
349,1044,1392,2282
111
hey guys likes to let's look at this 101 minimum depth of binary tree it's easy give it a binary tree find its minimum depth the minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node given a binary tree like this the returnees minimum depth is to number of nodes a...
Minimum Depth of Binary Tree
minimum-depth-of-binary-tree
Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. **Note:** A leaf is a node with no children. **Example 1:** **Input:** root = \[3,9,20,null,null,15,7\] **Output:** 2 **Example 2:** **Input:** root = \[2...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Easy
102,104