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 |
|---|---|---|---|---|---|---|---|---|
149 | hello guys welcome to God enzyme and in this video we are going to discuss problem 149 of lead code and the problem name is Max points in a line problem difficulty is hard let's read the problem statement given an array of points where points I is equal to X1 comma y1 represents a point in X Y plane return the maximum ... | Max Points on a Line | max-points-on-a-line | Given an array of `points` where `points[i] = [xi, yi]` represents a point on the **X-Y** plane, return _the maximum number of points that lie on the same straight line_.
**Example 1:**
**Input:** points = \[\[1,1\],\[2,2\],\[3,3\]\]
**Output:** 3
**Example 2:**
**Input:** points = \[\[1,1\],\[3,2\],\[5,3\],\[4,1\]... | null | Array,Hash Table,Math,Geometry | Hard | 356,2287 |
986 | hello everyone welcome to the channel today's question is interlaced intersections if you are new to the channel please consider subscribing we sold a lot of interview question on this channel and that can definitely help you with your interview a questions is given to lists of close intervals each list of intervals hi... | Interval List Intersections | largest-time-for-given-digits | You are given two lists of closed intervals, `firstList` and `secondList`, where `firstList[i] = [starti, endi]` and `secondList[j] = [startj, endj]`. Each list of intervals is pairwise **disjoint** and in **sorted order**.
Return _the intersection of these two interval lists_.
A **closed interval** `[a, b]` (with `a... | null | String,Enumeration | Medium | null |
225 | hello everyone we are solving problem number 225 to implement stack using queues so in this problem we need to implement functionalities of Stack which are push pop top and empty using only Q data structure so we will first take what is the difference between these two structures so for Q it implements first in first o... | 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 |
689 | hey hello there so today I want to talk about this question 689 marks in the sum of three non-overlapping sub-arrays we of three non-overlapping sub-arrays we of three non-overlapping sub-arrays we have an input array of positive integers and we want to find the three non-overlapping sub arrays within this non-overlapp... | Maximum Sum of 3 Non-Overlapping Subarrays | maximum-sum-of-3-non-overlapping-subarrays | Given an integer array `nums` and an integer `k`, find three non-overlapping subarrays of length `k` with maximum sum and return them.
Return the result as a list of indices representing the starting position of each interval (**0-indexed**). If there are multiple answers, return the lexicographically smallest one.
*... | null | Array,Dynamic Programming | Hard | 123 |
1,365 | That IPL 2000 Problems In Life In North And Look For Simple Right But Just In The Mid Day To Copy No Optimal Solution 2019 Tricks For Big Problems Sometimes In Talking About Very Similar Problem Only Give Me The Number Of Elements Which Element Hello Friends Welcome To My Channel Please Subscribe Limitations Subscribe ... | How Many Numbers Are Smaller Than the Current Number | how-many-numbers-are-smaller-than-the-current-number | Given the array `nums`, for each `nums[i]` find out how many numbers in the array are smaller than it. That is, for each `nums[i]` you have to count the number of valid `j's` such that `j != i` **and** `nums[j] < nums[i]`.
Return the answer in an array.
**Example 1:**
**Input:** nums = \[8,1,2,2,3\]
**Output:** \[4,... | null | null | Easy | null |
80 | Hello friends welcome back and watch this video. Simply Want Justice For This Element 's Daughter Suri Cruise Patient Element From One 's Daughter Suri Cruise Patient Element From One 's Daughter Suri Cruise Patient Element From One Point In This Universe In This Year Now Electric Reached To Of This Day Will Appear In ... | Remove Duplicates from Sorted Array II | remove-duplicates-from-sorted-array-ii | Given an integer array `nums` sorted in **non-decreasing order**, remove some duplicates [**in-place**](https://en.wikipedia.org/wiki/In-place_algorithm) such that each unique element appears **at most twice**. The **relative order** of the elements should be kept the **same**.
Since it is impossible to change the len... | null | Array,Two Pointers | Medium | 26 |
724 | hey everyone today we'll be doing another lead code problem to uh seven to four point pivot Index this is an easy one given an array of nums calculate the pivot index of this array is where the sum of all the numbers tricky left of the index equal to the sum of the all the numbers at the very right and if the index is ... | Find Pivot Index | find-pivot-index | Given an array of integers `nums`, calculate the **pivot index** of this array.
The **pivot index** is the index where the sum of all the numbers **strictly** to the left of the index is equal to the sum of all the numbers **strictly** to the index's right.
If the index is on the left edge of the array, then the left... | We can precompute prefix sums P[i] = nums[0] + nums[1] + ... + nums[i-1].
Then for each index, the left sum is P[i], and the right sum is P[P.length - 1] - P[i] - nums[i]. | Array,Prefix Sum | Easy | 560,2102,2369 |
200 | well it's another death first search problem you know you want it you know you came for it you can't live without it here we have number 200 number of islands so this says given an m by n 2d grid map of one's land and zero's water return the number of islands an island is surrounded by water and is formed by connected ... | Number of Islands | number-of-islands | Given an `m x n` 2D binary grid `grid` which represents a map of `'1'`s (land) and `'0'`s (water), return _the number of islands_.
An **island** is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water.
**Exampl... | null | Array,Depth-First Search,Breadth-First Search,Union Find,Matrix | Medium | 130,286,305,323,694,695,2035,2103 |
701 | welcome to october's leeco challenge today's problem is an insert into a binary search tree you are given the root node of a binary search tree and a value to insert into the tree return the root note of the binary search tree after the insertion it is guaranteed that the new value does not exist in the original binary... | Insert into a Binary Search Tree | insert-into-a-binary-search-tree | You are given the `root` node of a binary search tree (BST) and a `value` to insert into the tree. Return _the root node of the BST after the insertion_. It is **guaranteed** that the new value does not exist in the original BST.
**Notice** that there may exist multiple valid ways for the insertion, as long as the tre... | null | null | Medium | null |
1,547 | everyone welcome back and let's write some more neat code today's today let's solve the problem minimum cost to cut a stick and to be honest somebody at leak code really needs to put down the crack pipe because we are given a wooden stick of length n so far so good the stick is labeled from zero up until n so just like... | Minimum Cost to Cut a Stick | destination-city | Given a wooden stick of length `n` units. The stick is labelled from `0` to `n`. For example, a stick of length **6** is labelled as follows:
Given an integer array `cuts` where `cuts[i]` denotes a position you should perform a cut at.
You should perform the cuts in order, you can change the order of the cuts as you ... | Start in any city and use the path to move to the next city. Eventually, you will reach a city with no path outgoing, this is the destination city. | Hash Table,String | Easy | null |
539 | hello today we are going to take a look at question 539 minimum time difference in this problem we are given a list of 24-hour clock time points in our minutes 24-hour clock time points in our minutes 24-hour clock time points in our minutes format and we need to find the minimum minutes difference between any two time... | Minimum Time Difference | minimum-time-difference | Given a list of 24-hour clock time points in **"HH:MM "** format, return _the minimum **minutes** difference between any two time-points in the list_.
**Example 1:**
**Input:** timePoints = \["23:59","00:00"\]
**Output:** 1
**Example 2:**
**Input:** timePoints = \["00:00","23:59","00:00"\]
**Output:** 0
**Constrai... | null | Array,Math,String,Sorting | Medium | 2266 |
283 | we will have pointer J to go through each index and check for non-zero each index and check for non-zero each index and check for non-zero numbers and we will have pointer I to replace all the zeros with nonzero numbers identified by pointer J and to set Zer at the end of array here value at J pointer is zero therefore... | 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 |
404 | welcome to august liko challenge today's problem is some of left leaves find the sum of all left leaves in a given binary tree you can see we have a binary tree here and a left leaf is while a leaf on the left side so it's got no children and it's coming from the left we want to sum them all up so here 9 and 15 are the... | 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 |
1,027 | hey guys how's everything going let's continue our journey to lead code yay I'm Jay sir who is not good at algorithm today we will look at 102 7 longest arithmetic sequence given an array a of integers return the length of the longest arithmetic subsequence in a ok so 4 3 6 9 12 out of them are arithmetic sequence righ... | Longest Arithmetic Subsequence | sum-of-even-numbers-after-queries | Given an array `nums` of integers, return _the length of the longest arithmetic subsequence in_ `nums`.
**Note** that:
* A **subsequence** is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining elements.
* A sequence `seq` is arithmetic if `s... | null | Array,Simulation | Medium | null |
322 | welcome to march's leeco challenge today's problem is coin change you are given coins of different denominations and the total amount write a function to compute the fewest number of coins that you need to make up that amount if that amount cannot be made up return negative one you may assume you have an infinite numbe... | Coin Change | coin-change | You are given an integer array `coins` representing coins of different denominations and an integer `amount` representing a total amount of money.
Return _the fewest number of coins that you need to make up that amount_. If that amount of money cannot be made up by any combination of the coins, return `-1`.
You may a... | null | Array,Dynamic Programming,Breadth-First Search | Medium | 1025,1393,2345 |
735 | hello hi guys good morning welcome back to the new video and for sure if you have salt or if you have watched our live contest stream which we do every week if you have watched it for the past one month then for sure try this question but I also because you should be able to do it because I have told you this exact sam... | Asteroid Collision | asteroid-collision | We are given an array `asteroids` of integers representing asteroids in a row.
For each asteroid, the absolute value represents its size, and the sign represents its direction (positive meaning right, negative meaning left). Each asteroid moves at the same speed.
Find out the state of the asteroids after all collisio... | Say a row of asteroids is stable. What happens when a new asteroid is added on the right? | Array,Stack | Medium | 605,2245,2317 |
41 | what's up guys this is my two first video we gonna solve the famous problem the first missing positive it's usually asked by the top tech company like amazon okay so let's move to the description okay so given an inserted integer array nums uh find the smallest missing positive integer so let's take some examples the f... | 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 |
1,267 | hello everyone so in this video we'll go over one more problem from lead code the problem is count servers that communicate so let us go over the problem statement directly the problem statement goes like this that you are given a map of a server center represented as an m cross n integer matrix that is named as grid n... | Count Servers that Communicate | remove-zero-sum-consecutive-nodes-from-linked-list | You are given a map of a server center, represented as a `m * n` integer matrix `grid`, where 1 means that on that cell there is a server and 0 means that it is no server. Two servers are said to communicate if they are on the same row or on the same column.
Return the number of servers that communicate with any o... | Convert the linked list into an array. While you can find a non-empty subarray with sum = 0, erase it. Convert the array into a linked list. | Hash Table,Linked List | Medium | 1618 |
1 | hello everyone welcome to another one of my lead code videos and this one we'll do lead code one two sum and I'll try to make this a little bit more beginner friendly because it is likely that a good percentage of you watching this video are just starting out on lead code so yeah let me help you start out your journey ... | 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 |
142 | hey everybody this is larry this is day 19 of the lead code daily challenge hit the like button hit the subscribe button join my discord let me know what you think about today's forum this problem is link list psycho 2. so the second one is that the one with the pointer uh yes we're learning the note right okay yeah so... | Linked List Cycle II | linked-list-cycle-ii | Given the `head` of a linked list, return _the node where the cycle begins. If there is no cycle, return_ `null`.
There is a cycle in a linked list if there is some node in the list that can be reached again by continuously following the `next` pointer. Internally, `pos` is used to denote the index of the node that ta... | null | Hash Table,Linked List,Two Pointers | Medium | 141,287 |
438 | hello welcome to my channel today if you have leeco 438 find all anagrams in a string so given a string s and a non-empty so given a string s and a non-empty so given a string s and a non-empty string p find all the star indices of piece anagram in s so later you will see the condition here and also another condition i... | Find All Anagrams in a String | find-all-anagrams-in-a-string | Given two strings `s` and `p`, return _an array of all the start indices of_ `p`_'s anagrams in_ `s`. You may return the answer in **any order**.
An **Anagram** is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.
**Example 1:**
*... | null | Hash Table,String,Sliding Window | Medium | 242,567 |
12 | Roman number to integer so basically we have given a Roman number in the question and we have to find the integer for the same so here I have written the program for that if you can see the solution the map I have formed in the map I have just kept the Roman number with respective number and here I'm just taking a for ... | Integer to Roman | integer-to-roman | Roman numerals are represented by seven different symbols: `I`, `V`, `X`, `L`, `C`, `D` and `M`.
**Symbol** **Value**
I 1
V 5
X 10
L 50
C 100
D 500
M 1000
For example, `2` is written as `II` in Roman numeral, just two one's adde... | null | Hash Table,Math,String | Medium | 13,273 |
50 | hello guys welcome back to take those and in this video we will see how to find X raised to the power of n we will see the most optimal binary exponentiation technique in this problem and this is from lead code number 50 and it is a very important math algorithm problem which you should never skip before looking at the... | 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 |
318 | hello everyone welcome to quartus camp we are a 27th day of mail it goes challenge and the problem we are going to cover in this video is maximum product of word length the input given here is a string array which consists of words and we have to return the maximum product of any two words and the words should not have... | Maximum Product of Word Lengths | maximum-product-of-word-lengths | Given a string array `words`, return _the maximum value of_ `length(word[i]) * length(word[j])` _where the two words do not share common letters_. If no such two words exist, return `0`.
**Example 1:**
**Input:** words = \[ "abcw ", "baz ", "foo ", "bar ", "xtfn ", "abcdef "\]
**Output:** 16
**Explanation:** The two ... | null | Array,String,Bit Manipulation | Medium | null |
735 | hi everyone we'll see about the today asteroid Collision problem that is ask in many company okay let's start with the problem and the question is given you are given an asid of integer representing the asid in a row and for each estro the absolute value represent size and the sign represented Direction and it is will ... | Asteroid Collision | asteroid-collision | We are given an array `asteroids` of integers representing asteroids in a row.
For each asteroid, the absolute value represents its size, and the sign represents its direction (positive meaning right, negative meaning left). Each asteroid moves at the same speed.
Find out the state of the asteroids after all collisio... | Say a row of asteroids is stable. What happens when a new asteroid is added on the right? | Array,Stack | Medium | 605,2245,2317 |
131 | everyone welcome back and let's write some more neat code today so today let's look at a problem palindrome partitioning so we're given a string s and we want to partition it in such a way that every single sub-string of the partition every single sub-string of the partition every single sub-string of the partition is ... | Palindrome Partitioning | palindrome-partitioning | Given a string `s`, partition `s` such that every substring of the partition is a **palindrome**. Return _all possible palindrome partitioning of_ `s`.
**Example 1:**
**Input:** s = "aab"
**Output:** \[\["a","a","b"\],\["aa","b"\]\]
**Example 2:**
**Input:** s = "a"
**Output:** \[\["a"\]\]
**Constraints:**
* `1... | null | String,Dynamic Programming,Backtracking | Medium | 132,1871 |
174 | hey what's up guys this is john here so uh today i'd like to talk about this 174 dungeon game i think this is very interesting like problem okay so let's take a look uh the blah there's a dungeon and there's a nat knight and there's a trapped princess okay and the 2d dungeon here so you know at so the knight starts at ... | 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 |
51 | hello everyone it's me abhinaya so today in this video we're going to solve another interesting problem from lead code called n queens it's a half it's a heart problem the problem number is 51. let's see the question the end queen's puzzle is the problem of placing n queens on an n into n chessboard such that no two pi... | N-Queens | n-queens | The **n-queens** puzzle is the problem of placing `n` queens on an `n x n` chessboard such that no two queens attack each other.
Given an integer `n`, return _all distinct solutions to the **n-queens puzzle**_. You may return the answer in **any order**.
Each solution contains a distinct board configuration of the n-... | null | Array,Backtracking | Hard | 52,1043 |
52 | continue from an ass problem which is 51 in Queens let's take a look at number 52 in Queens number 2 so the problem is same except that we need to return the number of distinct solutions well it's totally the same right so please if you have any questions if I have something I'm familiar with this problem please take a... | N-Queens II | n-queens-ii | The **n-queens** puzzle is the problem of placing `n` queens on an `n x n` chessboard such that no two queens attack each other.
Given an integer `n`, return _the number of distinct solutions to the **n-queens puzzle**_.
**Example 1:**
**Input:** n = 4
**Output:** 2
**Explanation:** There are two distinct solutions ... | null | Backtracking | Hard | 51 |
1,255 | Hello, this is Nagopa from Live Coding. Today, I will solve problem number 1255 of Litcode, Maximum Score World Form by Letters. The pronunciation is a bit bad, but please understand and the difficulty level of the problem is hard. The problem was taken from Litcode, but it is a hard problem. It's not that difficult. I... | Maximum Score Words Formed by Letters | reverse-subarray-to-maximize-array-value | Given a list of `words`, list of single `letters` (might be repeating) and `score` of every character.
Return the maximum score of **any** valid set of words formed by using the given letters (`words[i]` cannot be used two or more times).
It is not necessary to use all characters in `letters` and each letter can only... | What's the score after reversing a sub-array [L, R] ? It's the score without reversing it + abs(a[R] - a[L-1]) + abs(a[L] - a[R+1]) - abs(a[L] - a[L-1]) - abs(a[R] - a[R+1]) How to maximize that formula given that abs(x - y) = max(x - y, y - x) ? This can be written as max(max(a[R] - a[L - 1], a[L - 1] - a[R]) + max(a[... | Array,Math,Greedy | Hard | null |
152 | Ask question will solve maximum products sub is aa products sub is un given date has largest product and return d product non empty sequence of element with it saying ok first let's see how to solve it here 2 * This is the first one which is taking 3 = 6, the 2 * This is the first one which is taking 3 = 6, the 2 * Thi... | Maximum Product Subarray | maximum-product-subarray | Given an integer array `nums`, find a subarray that has the largest product, and return _the product_.
The test cases are generated so that the answer will fit in a **32-bit** integer.
**Example 1:**
**Input:** nums = \[2,3,-2,4\]
**Output:** 6
**Explanation:** \[2,3\] has the largest product 6.
**Example 2:**
**I... | null | Array,Dynamic Programming | Medium | 53,198,238,628,713 |
1,541 | hello everyone today we will be going to discuss uh question number three from today's bi-weekly contest from lead code bi-weekly contest from lead code bi-weekly contest from lead code uh by weekly contest 32 so the problem we are going to discuss today is minimum insertions to make a parenthesis uh string balanced so... | Minimum Insertions to Balance a Parentheses String | top-travellers | Given a parentheses string `s` containing only the characters `'('` and `')'`. A parentheses string is **balanced** if:
* Any left parenthesis `'('` must have a corresponding two consecutive right parenthesis `'))'`.
* Left parenthesis `'('` must go before the corresponding two consecutive right parenthesis `'))'`... | null | Database | Easy | null |
904 | Problem is today's problem, you have to solve this fruits in basket so let's get into this problem. So today's problem is that you have put two food baskets inside it and told yourself that you have only one fruit in one basket. Now you have given yourself many different numbers of fruits and you have to tell yourself ... | Fruit Into Baskets | leaf-similar-trees | You are visiting a farm that has a single row of fruit trees arranged from left to right. The trees are represented by an integer array `fruits` where `fruits[i]` is the **type** of fruit the `ith` tree produces.
You want to collect as much fruit as possible. However, the owner has some strict rules that you must foll... | null | Tree,Depth-First Search,Binary Tree | Easy | null |
847 | hello everyone welcome to day 27 of the february decode challenge and the question that we have in today's maximum width of binary tree here in this question we are given a binary tree and we need to identify the maximum width that exists among all the levels in this tree as soon as you read the word levels you should ... | Shortest Path Visiting All Nodes | shortest-path-visiting-all-nodes | You have an undirected, connected graph of `n` nodes labeled from `0` to `n - 1`. You are given an array `graph` where `graph[i]` is a list of all the nodes connected with node `i` by an edge.
Return _the length of the shortest path that visits every node_. You may start and stop at any node, you may revisit nodes mul... | null | null | Hard | null |
108 | hi guys welcome to one more video in this video we'll take a look at convert sorted array to binary search free difficulty level is easy so the problem title itself gives out that we would be given a sorted array and then we need to convert it to a binary search tree so it's kind of a d serialized operation like we're ... | Convert Sorted Array to Binary Search Tree | convert-sorted-array-to-binary-search-tree | Given an integer array `nums` where the elements are sorted in **ascending order**, convert _it to a_ **_height-balanced_** _binary search tree_.
**Example 1:**
**Input:** nums = \[-10,-3,0,5,9\]
**Output:** \[0,-3,9,-10,null,5\]
**Explanation:** \[0,-10,5,null,-3,null,9\] is also accepted:
**Example 2:**
**Input... | null | Array,Divide and Conquer,Tree,Binary Search Tree,Binary Tree | Easy | 109 |
134 | problem is called a gas station problem and it has been asked quite a few times in amazon google microsoft uber and apple interviews so let's see what is this problem so in this problem you have a few gas stations so this array or list of gas denotes the different gas stations so gas station 0 1 2 3 4. so let's draw th... | Gas Station | gas-station | There are `n` gas stations along a circular route, where the amount of gas at the `ith` station is `gas[i]`.
You have a car with an unlimited gas tank and it costs `cost[i]` of gas to travel from the `ith` station to its next `(i + 1)th` station. You begin the journey with an empty tank at one of the gas stations.
Gi... | null | Array,Greedy | Medium | 1346 |
15 | on everyone so today we are looking at lead code number 15. it's a question called threesome okay so this is a very popular question it builds off of its predecessor which is a is leak code number one which is twosome also extremely popular and we're going to look at three different ways we can approach this we'll look... | 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 |
929 | hello everyone welcome to quartus camp we are 27th day of september leco challenge and the problem we are going to cover in this video is unique email addresses so the input given here is a list of strings where a list of email addresses given and we have to return the number of email address where the that the email a... | 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,011 | hello and welcome back to the cracking fang youtube channel today we're going to be solving leak code problem 1011 capacity to ship packages within d days at the moment this question is really popular with facebook amazon and google so definitely want to know if you have an upcoming on-site interview with any an upcomi... | 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 |
338 | hey how's it goin guys so in this video we'll discuss about this problem counting bits given a non-negative counting bits given a non-negative counting bits given a non-negative integer number now for every numbers I in the range 0 to num calculate the number of buns in their binary representation and it turned imagine... | Counting Bits | counting-bits | Given an integer `n`, return _an array_ `ans` _of length_ `n + 1` _such that for each_ `i` (`0 <= i <= n`)_,_ `ans[i]` _is the **number of**_ `1`_**'s** in the binary representation of_ `i`.
**Example 1:**
**Input:** n = 2
**Output:** \[0,1,1\]
**Explanation:**
0 --> 0
1 --> 1
2 --> 10
**Example 2:**
**Input:** n =... | You should make use of what you have produced already. Divide the numbers in ranges like [2-3], [4-7], [8-15] and so on. And try to generate new range from previous. Or does the odd/even status of the number help you in calculating the number of 1s? | Dynamic Programming,Bit Manipulation | Easy | 191 |
1,456 | hey everyone welcome back and let's write some more neat code today so today let's solve the problem maximum number of vowels in a substring of a given length we're given a string s and an integer k represents the size of our substring but I prefer to call it a window because substring problems are commonly sliding win... | Maximum Number of Vowels in a Substring of Given Length | find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance | Given a string `s` and an integer `k`, return _the maximum number of vowel letters in any substring of_ `s` _with length_ `k`.
**Vowel letters** in English are `'a'`, `'e'`, `'i'`, `'o'`, and `'u'`.
**Example 1:**
**Input:** s = "abciiidef ", k = 3
**Output:** 3
**Explanation:** The substring "iii " contains 3 vow... | Use Floyd-Warshall's algorithm to compute any-point to any-point distances. (Or can also do Dijkstra from every node due to the weights are non-negative). For each city calculate the number of reachable cities within the threshold, then search for the optimal city. | Dynamic Programming,Graph,Shortest Path | Medium | 2171 |
2 | welcome to part two of leeco the day keeps the dances away high script edition we're gonna be solving lead code questions using typescript and now as always i'll be showing you guys multiple solutions to the same problem and this one is add two numbers if this is your first time on this channel uh i do these lethal typ... | Add Two Numbers | add-two-numbers | You are given two **non-empty** linked lists representing two non-negative integers. The digits are stored in **reverse order**, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.
You may assume the two numbers do not contain any leading zero, except the number 0 ... | null | Linked List,Math,Recursion | Medium | 43,67,371,415,445,1031,1774 |
871 | Hello hello guys welcome to another video link syrup yes here all problem minimum number of curing stops work which traveling from starting question tourist destination and gas stations languages parameters for gas station languages parameters for gas station languages parameters for gas station subscribe first p... | Minimum Number of Refueling Stops | keys-and-rooms | A car travels from a starting position to a destination which is `target` miles east of the starting position.
There are gas stations along the way. The gas stations are represented as an array `stations` where `stations[i] = [positioni, fueli]` indicates that the `ith` gas station is `positioni` miles east of the sta... | null | Depth-First Search,Breadth-First Search,Graph | Medium | 261 |
474 | asalamu alikum ask 474 170 then first example M five n 3 Maxim answer four subset problem DP M 01 con string vector string s Str one 1 0 1 or one Z M five n man three result find Ma Max form maybe find Max form length size then DP for Z One Z integer Z count of s Str begin okay then integer one simple one then Matrix f... | 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 |
235 | hi and welcome to prototype we will be solving the problem for lead code 235 lowest common ancestor of a buy-in lowest common ancestor of a buy-in lowest common ancestor of a buy-in research tree this is another problem in the lead code 75 study plan let's get to it so given a buy and research tree BST find the lowest ... | Lowest Common Ancestor of a Binary Search Tree | lowest-common-ancestor-of-a-binary-search-tree | Given a binary search tree (BST), find the lowest common ancestor (LCA) node of two given nodes in the BST.
According to the [definition of LCA on Wikipedia](https://en.wikipedia.org/wiki/Lowest_common_ancestor): "The lowest common ancestor is defined between two nodes `p` and `q` as the lowest node in `T` that has bo... | null | Tree,Depth-First Search,Binary Search Tree,Binary Tree | Easy | 236,1190,1780,1790,1816 |
7 | lead code problem number seven reverse integer so this problem gives us a sign 32bit integer X and we have to return x with its digits reversed and if reversing X causes the value to go outside the sin 32bit inte range basically in minan or in Max right here I Jed down the values what is in mean then we have to return ... | Reverse Integer | reverse-integer | Given a signed 32-bit integer `x`, return `x` _with its digits reversed_. If reversing `x` causes the value to go outside the signed 32-bit integer range `[-231, 231 - 1]`, then return `0`.
**Assume the environment does not allow you to store 64-bit integers (signed or unsigned).**
**Example 1:**
**Input:** x = 123
... | null | Math | Medium | 8,190,2238 |
295 | Hello hello guys welcome back to tech division in this video you will see media and in no data stream problem something from the list number to 9 500 latest reader problem statement no problem medium size maintain value and order in to-do list size maintain value and order in to-do list size maintain value and order in... | Find Median from Data Stream | find-median-from-data-stream | The **median** is the middle value in an ordered integer list. If the size of the list is even, there is no middle value, and the median is the mean of the two middle values.
* For example, for `arr = [2,3,4]`, the median is `3`.
* For example, for `arr = [2,3]`, the median is `(2 + 3) / 2 = 2.5`.
Implement the M... | null | Two Pointers,Design,Sorting,Heap (Priority Queue),Data Stream | Hard | 480,1953,2207 |
606 | foreign this is Larry this is day seven of the liko day challenge hit the like button hit the Subscribe button join me on Discord let me know what you think about today's fun construction train from binary tree I'm just oh yes so sometimes I click I don't know if there are other Pages let me know in the comments if you... | 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 |
744 | Hello Gas, today we are back again with Gyan Portal and Gas, now we are going to challenge the lead to solve the daily problems I come across and the problem you are seeing today is The target of 744 is to find the smallest letter. So basically, first of all we have to read the big part of this problem, what is the pro... | Find Smallest Letter Greater Than Target | network-delay-time | You are given an array of characters `letters` that is sorted in **non-decreasing order**, and a character `target`. There are **at least two different** characters in `letters`.
Return _the smallest character in_ `letters` _that is lexicographically greater than_ `target`. If such a character does not exist, return t... | We visit each node at some time, and if that time is better than the fastest time we've reached this node, we travel along outgoing edges in sorted order. Alternatively, we could use Dijkstra's algorithm. | Depth-First Search,Breadth-First Search,Graph,Heap (Priority Queue),Shortest Path | Medium | 2151,2171 |
113 | hey everybody this is larry this is day fourth of the august nicole dairy challenge hit the like button to subscribe and join my discord let me know what you think about taste problem have some too um so i usually solve this live so if it's a little bit slow just fast forward move ahead whatever you need to do uh okay ... | Path Sum II | path-sum-ii | Given the `root` of a binary tree and an integer `targetSum`, return _all **root-to-leaf** paths where the sum of the node values in the path equals_ `targetSum`_. Each path should be returned as a list of the node **values**, not node references_.
A **root-to-leaf** path is a path starting from the root and ending at... | null | Backtracking,Tree,Depth-First Search,Binary Tree | Medium | 112,257,437,666,2217 |
147 | okay kids we're here for insertion sort lists now first of all before beginning whenever you want to deal with linked lists or sorry when you want to learn about them i recommend going here at this particular address link list problems and linked list basics over here as well and this is from stanford as well as all th... | Insertion Sort List | insertion-sort-list | Given the `head` of a singly linked list, sort the list using **insertion sort**, and return _the sorted list's head_.
The steps of the **insertion sort** algorithm:
1. Insertion sort iterates, consuming one input element each repetition and growing a sorted output list.
2. At each iteration, insertion sort removes... | null | Linked List,Sorting | Medium | 148,850 |
1,406 | all right let's take a look at leak code 1406 stone game three i think this is an incredibly good problem it's a dp problem and i think it's uh it's a golden standard of dp problems to be honest with you know you can start with a naive backtracking approach and then you can create a cache to cache your results and then... | Stone Game III | subtract-the-product-and-sum-of-digits-of-an-integer | Alice and Bob continue their games with piles of stones. There are several stones **arranged in a row**, and each stone has an associated value which is an integer given in the array `stoneValue`.
Alice and Bob take turns, with Alice starting first. On each player's turn, that player can take `1`, `2`, or `3` stones f... | How to compute all digits of the number ? Use modulus operator (%) to compute the last digit. Generalise modulus operator idea to compute all digits. | Math | Easy | null |
653 | hey everybody this is larry this is day 23 of the august leco daily challenge hit the like button to subscribe and join me on discord how was your weekend let me know how everything went and come join me on discord chat about it anyway today's problem is two sum four input is a binary search tree given the root of a bi... | Two Sum IV - Input is a BST | two-sum-iv-input-is-a-bst | Given the `root` of a binary search tree and an integer `k`, return `true` _if there exist two elements in the BST such that their sum is equal to_ `k`, _or_ `false` _otherwise_.
**Example 1:**
**Input:** root = \[5,3,6,2,4,null,7\], k = 9
**Output:** true
**Example 2:**
**Input:** root = \[5,3,6,2,4,null,7\], k = ... | null | Hash Table,Two Pointers,Tree,Depth-First Search,Breadth-First Search,Binary Search Tree,Binary Tree | Easy | 1,167,170,1150 |
1,979 | hello friends so today in this video we'll go through the first two problems from the latest lead code weekly contest to 55 so let's start the first problem is not too difficult it states that you're given and you have to find out the greatest common divisor of an array so the problem is asking you that you are given a... | Find Greatest Common Divisor of Array | maximum-number-of-people-that-can-be-caught-in-tag | Given an integer array `nums`, return _the **greatest common divisor** of the smallest number and largest number in_ `nums`.
The **greatest common divisor** of two numbers is the largest positive integer that evenly divides both numbers.
**Example 1:**
**Input:** nums = \[2,5,6,9,10\]
**Output:** 2
**Explanation:**
... | Try to use as much of the range of a person who is "it" as possible. Find the leftmost person who is "it" that has not caught anyone yet, and the leftmost person who is not "it" that has not been caught yet. If the person who is not "it" can be caught, pair them together and repeat the process. If the person who is not... | Array,Greedy | Medium | 2191 |
1,872 | hey everybody this is larry this is me going over q4 of the uh weekly contest 242 stone game eight so hit the like button hit the subscribe button join me on discord let me know what you think about this problem so this one i actually spent way too long on the greedy solution and the greedy was that i always just take ... | Stone Game VIII | can-you-eat-your-favorite-candy-on-your-favorite-day | Alice and Bob take turns playing a game, with **Alice starting first**.
There are `n` stones arranged in a row. On each player's turn, while the number of stones is **more than one**, they will do the following:
1. Choose an integer `x > 1`, and **remove** the leftmost `x` stones from the row.
2. Add the **sum** of... | The query is true if and only if your favorite day is in between the earliest and latest possible days to eat your favorite candy. To get the earliest day, you need to eat dailyCap candies every day. To get the latest day, you need to eat 1 candy every day. The latest possible day is the total number of candies with a ... | Array,Prefix Sum | Medium | null |
491 | welcome to algo simplified let's solve today's lead code challenge that is non-decreasing subsequences non-decreasing subsequences non-decreasing subsequences let's start with the problem statement in this problem we are given an array of nums return all different possible known decreasing subsequences of the given arr... | Non-decreasing Subsequences | increasing-subsequences | Given an integer array `nums`, return _all the different possible non-decreasing subsequences of the given array with at least two elements_. You may return the answer in **any order**.
**Example 1:**
**Input:** nums = \[4,6,7,7\]
**Output:** \[\[4,6\],\[4,6,7\],\[4,6,7,7\],\[4,7\],\[4,7,7\],\[6,7\],\[6,7,7\],\[7,7\]... | null | Array,Hash Table,Backtracking,Bit Manipulation | Medium | 646 |
354 | hello everyone welcome to another episode of coding decoded my name is ancha rodeja i'm working as technical architect sd4 at adobe and here i present russian doll envelopes problem and apologies i couldn't solve it in the morning and provide you with the solution as i was quite occupied with my professional commitment... | Russian Doll Envelopes | russian-doll-envelopes | You are given a 2D array of integers `envelopes` where `envelopes[i] = [wi, hi]` represents the width and the height of an envelope.
One envelope can fit into another if and only if both the width and height of one envelope are greater than the other envelope's width and height.
Return _the maximum number of envelope... | null | Array,Binary Search,Dynamic Programming,Sorting | Hard | 300,2123 |
1,658 | Hello everyone welcome to my channel codestoryWithMIK are going to do the medium mark but will keep the explanation quite easy and simple but there is a lot to learn and this approach is very similar we have done the previous message questions ok liquid number 1658 medium mark Have minimum operations you reduce These a... | Minimum Operations to Reduce X to Zero | minimum-swaps-to-arrange-a-binary-grid | You are given an integer array `nums` and an integer `x`. In one operation, you can either remove the leftmost or the rightmost element from the array `nums` and subtract its value from `x`. Note that this **modifies** the array for future operations.
Return _the **minimum number** of operations to reduce_ `x` _to **e... | For each row of the grid calculate the most right 1 in the grid in the array maxRight. To check if there exist answer, sort maxRight and check if maxRight[i] ≤ i for all possible i's. If there exist an answer, simulate the swaps. | Array,Greedy,Matrix | Medium | null |
226 | hello guys welcome to deep codes and in today's video we will discuss lead code question 226 that says invert binary tree so here you are given one binary tray uh you are given the root of the binary tree and you need to invert the tree and return its root okay so here what does the invert word mean invert the binary w... | Invert Binary Tree | invert-binary-tree | Given the `root` of a binary tree, invert the tree, and return _its root_.
**Example 1:**
**Input:** root = \[4,2,7,1,3,6,9\]
**Output:** \[4,7,2,9,6,3,1\]
**Example 2:**
**Input:** root = \[2,1,3\]
**Output:** \[2,3,1\]
**Example 3:**
**Input:** root = \[\]
**Output:** \[\]
**Constraints:**
* The number of n... | null | Tree,Depth-First Search,Breadth-First Search,Binary Tree | Easy | null |
84 | Jhal Hello Hi Guys, this question in this video we will discuss our largest this is this grinder solution so see I told you that you have got a bar chart of Lal Singh, this is the chart inside which you have these six heights that you have once. Two brothers' that you have once. Two brothers' that you have once. Two br... | Largest Rectangle in Histogram | largest-rectangle-in-histogram | Given an array of integers `heights` representing the histogram's bar height where the width of each bar is `1`, return _the area of the largest rectangle in the histogram_.
**Example 1:**
**Input:** heights = \[2,1,5,6,2,3\]
**Output:** 10
**Explanation:** The above is a histogram where width of each bar is 1.
The l... | null | Array,Stack,Monotonic Stack | Hard | 85,1918 |
409 | hey everyone welcome back and today we'll be doing another lead code 409 longest palindrome and easy one given a string gas which consists of a lowercase and uppercase letter written the length of the longest palindrome that can be built with those latter letters are case sensitive for example a is not considered a pal... | Longest Palindrome | longest-palindrome | Given a string `s` which consists of lowercase or uppercase letters, return _the length of the **longest palindrome**_ that can be built with those letters.
Letters are **case sensitive**, for example, `"Aa "` is not considered a palindrome here.
**Example 1:**
**Input:** s = "abccccdd "
**Output:** 7
**Explanation... | null | Hash Table,String,Greedy | Easy | 266,2237 |
1 | That the country's most important question recording interview is in this point in a lot of this interview solution I want to see what fiber skin coat 19 grower of solution but today the tell you about this method you for watching and using Hello friends welcome back to The place were simply programming with that today... | 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 |
706 | Share Guys Welcome To Your Comments In This Video You Will See The Question Designing Subscribe Now To Receive New Updates And To The Giver And - Note Content For The Giver Not To The Giver And - Note Content For The Giver Not To The Giver And - Note Content For The Giver Not Give The Name Of The Question Is The Beginn... | Design HashMap | design-hashmap | Design a HashMap without using any built-in hash table libraries.
Implement the `MyHashMap` class:
* `MyHashMap()` initializes the object with an empty map.
* `void put(int key, int value)` inserts a `(key, value)` pair into the HashMap. If the `key` already exists in the map, update the corresponding `value`.
* ... | null | null | Easy | null |
617 | welcome ladies and gentlemen boys and girls today we are going to solve unschooled problem which is must do binary tree so this is the binary problem see as simple like you get from the title idea okay so ladies and gentlemen let's just see like what the question is in the questions having been given a 2 by 3 is root 1... | Merge Two Binary Trees | merge-two-binary-trees | You are given two binary trees `root1` and `root2`.
Imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not. You need to merge the two trees into a new binary tree. The merge rule is that if two nodes overlap, then sum node values up as the new valu... | null | Tree,Depth-First Search,Breadth-First Search,Binary Tree | Easy | null |
931 | in December uh time is 12:24 a.m. uh the in December uh time is 12:24 a.m. uh the in December uh time is 12:24 a.m. uh the match is about to start and the motivation for solving this lead code problem is the first one is we haven't solved it in the past it's a fresh question so after a very long time I got a fresh ques... | Minimum Falling Path Sum | maximum-frequency-stack | Given an `n x n` array of integers `matrix`, return _the **minimum sum** of any **falling path** through_ `matrix`.
A **falling path** starts at any element in the first row and chooses the element in the next row that is either directly below or diagonally left/right. Specifically, the next element from position `(ro... | null | Hash Table,Stack,Design,Ordered Set | Hard | null |
747 | Dream II car, when I know I'm in this row, I'll wear it and solve a math problem to know better. For more detailed information, please go to the available books. okay how we work this number Ok hello everyone came here 2 years of d up to Nikko play times Today we will continue with you this one song already before comi... | Largest Number At Least Twice of Others | min-cost-climbing-stairs | You are given an integer array `nums` where the largest integer is **unique**.
Determine whether the largest element in the array is **at least twice** as much as every other number in the array. If it is, return _the **index** of the largest element, or return_ `-1` _otherwise_.
**Example 1:**
**Input:** nums = \[3... | Say f[i] is the final cost to climb to the top from step i. Then f[i] = cost[i] + min(f[i+1], f[i+2]). | Array,Dynamic Programming | Easy | 70 |
76 | 200 Hello friends, welcome to the new video of Tech and today we have problem number 22 Edison, today is Banswara day, our minimum is Window 7 Singh, it is okay, so I have made the work easy in this, it shows you that this problem is a high level problem. There is not so much ad in it will take some time to explain to ... | Minimum Window Substring | minimum-window-substring | Given two strings `s` and `t` of lengths `m` and `n` respectively, return _the **minimum window**_ **_substring_** _of_ `s` _such that every character in_ `t` _(**including duplicates**) is included in the window_. If there is no such substring, return _the empty string_ `" "`.
The testcases will be generated such tha... | Use two pointers to create a window of letters in S, which would have all the characters from T. Since you have to find the minimum window in S which has all the characters from T, you need to expand and contract the window using the two pointers and keep checking the window for all the characters. This approach is als... | Hash Table,String,Sliding Window | Hard | 30,209,239,567,632,727 |
231 | hello everyone welcome back to my channel so today we are going to discuss another problem is power of two so it's a very easy problem uh in this problem we'll be given an integer and we need to return true if it is a power of two otherwise return false power of 2 means that this number n can be represented as 2 raised... | Power of Two | power-of-two | Given an integer `n`, return _`true` if it is a power of two. Otherwise, return `false`_.
An integer `n` is a power of two, if there exists an integer `x` such that `n == 2x`.
**Example 1:**
**Input:** n = 1
**Output:** true
**Explanation:** 20 = 1
**Example 2:**
**Input:** n = 16
**Output:** true
**Explanation:**... | null | Math,Bit Manipulation,Recursion | Easy | 191,326,342 |
260 | hello guys mike decoder here so i decided to make some neat core problems because i'm running off ideas uh if you have any ideas for future videos leave it in the comments so let us see this problem given integer array numbers in which exactly two elements appear only once and all the other elements appear exactly twic... | Single Number III | single-number-iii | Given an integer array `nums`, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once. You can return the answer in **any order**.
You must write an algorithm that runs in linear runtime complexity and uses only constant extra space.
... | null | Array,Bit Manipulation | Medium | 136,137 |
971 | welcome to march's leeco challenge today's problem is flip binary tree to match pre-order traversal you're given the pre-order traversal you're given the pre-order traversal you're given the root of a binary tree with n nodes where each node is uniquely assigned a value from one to n you're also given a sequence of n v... | Flip Binary Tree To Match Preorder Traversal | shortest-bridge | You are given the `root` of a binary tree with `n` nodes, where each node is uniquely assigned a value from `1` to `n`. You are also given a sequence of `n` values `voyage`, which is the **desired** [**pre-order traversal**](https://en.wikipedia.org/wiki/Tree_traversal#Pre-order) of the binary tree.
Any node in the bi... | null | Array,Depth-First Search,Breadth-First Search,Matrix | Medium | null |
522 | hey everybody this is larry this is august 27th day of the august nicole day challenge congrats to yourself if you've made it this far you're almost to the end just a couple more days uh hit the like button hit the subscribe button join me on discord chat about this farm out of problems okay longest uncommon subsequenc... | Longest Uncommon Subsequence II | longest-uncommon-subsequence-ii | Given an array of strings `strs`, return _the length of the **longest uncommon subsequence** between them_. If the longest uncommon subsequence does not exist, return `-1`.
An **uncommon subsequence** between an array of strings is a string that is a **subsequence of one string but not the others**.
A **subsequence**... | null | Array,Hash Table,Two Pointers,String,Sorting | Medium | 521 |
134 | hello everyone welcome back to cooling Champs in today's video we are going to be solving the problem gas station so let us first start by understanding the problem statement given there are n gas stations along a circular route where the amount of gas at the Earth gas station is gas of I you have a car with unlimited ... | Gas Station | gas-station | There are `n` gas stations along a circular route, where the amount of gas at the `ith` station is `gas[i]`.
You have a car with an unlimited gas tank and it costs `cost[i]` of gas to travel from the `ith` station to its next `(i + 1)th` station. You begin the journey with an empty tank at one of the gas stations.
Gi... | null | Array,Greedy | Medium | 1346 |
1,261 | Hello everyone today test the camera list number 1234 problem solved I know the problem is that the account is ripped from the account so the problem was first a brother sister brother that the commission said to make active directory like they loot the person dishoom full feel good condition The second conditioner bal... | Find Elements in a Contaminated Binary Tree | swap-for-longest-repeated-character-substring | Given a binary tree with the following rules:
1. `root.val == 0`
2. If `treeNode.val == x` and `treeNode.left != null`, then `treeNode.left.val == 2 * x + 1`
3. If `treeNode.val == x` and `treeNode.right != null`, then `treeNode.right.val == 2 * x + 2`
Now the binary tree is contaminated, which means all `treeNode... | There are two cases: a block of characters, or two blocks of characters between one different character.
By keeping a run-length encoded version of the string, we can easily check these cases. | String,Sliding Window | Medium | null |
956 | hello friends today let's resolve the tallest billboard problem previously we solve it via that first search but currently it will cause time limited exceeded so today we will solve it with dynamic programming so let's recall what is the question about we are given an integer array which called the row rows um and we h... | Tallest Billboard | number-of-music-playlists | You are installing a billboard and want it to have the largest height. The billboard will have two steel supports, one on each side. Each steel support must be an equal height.
You are given a collection of `rods` that can be welded together. For example, if you have rods of lengths `1`, `2`, and `3`, you can weld the... | null | Math,Dynamic Programming,Combinatorics | Hard | null |
277 | foreign Solutions are created Microsoft and my aim is to empower every single person to be better at technical interviews keeping with that goal in mind today we are going to do a very interesting lead code problem so let's get started with that so today we are going to find the celebrity lead code problem and if we se... | Find the Celebrity | find-the-celebrity | Suppose you are at a party with `n` people labeled from `0` to `n - 1` and among them, there may exist one celebrity. The definition of a celebrity is that all the other `n - 1` people know the celebrity, but the celebrity does not know any of them.
Now you want to find out who the celebrity is or verify that there is... | The best hint for this problem can be provided by the following figure: Well, if you understood the gist of the above idea, you can extend it to find a candidate that can possibly be a celebrity. Why do we say a "candidate"? That is for you to think. This is clearly a greedy approach to find the answer. However, there ... | Two Pointers,Greedy,Graph,Interactive | Medium | 1039 |
72 | Hello Everyone Today Going To Cover A Distance Of This Heart Problem Likh Course Let's See Who Wins Gold In Return For Operations In Wave 205 On Thursday And Then Example Avv Exploded Battu Kya Hai How To Make A Tour Officer We Can Do It Not to be lit subscribe first replacing to drops vikram rathore and where going to... | Edit Distance | edit-distance | Given two strings `word1` and `word2`, return _the minimum number of operations required to convert `word1` to `word2`_.
You have the following three operations permitted on a word:
* Insert a character
* Delete a character
* Replace a character
**Example 1:**
**Input:** word1 = "horse ", word2 = "ros "
**O... | null | String,Dynamic Programming | Hard | 161,583,712,1105,2311 |
326 | hello everyone welcome to quartus cap so we are today at the 27th day of april lead code challenge and the problem given here is power of three so the input here is a integer value m and we have to written whether it is a power of 3 so now it seems to be very simple problem so coming up with the efficient solution matt... | Power of Three | power-of-three | Given an integer `n`, return _`true` if it is a power of three. Otherwise, return `false`_.
An integer `n` is a power of three, if there exists an integer `x` such that `n == 3x`.
**Example 1:**
**Input:** n = 27
**Output:** true
**Explanation:** 27 = 33
**Example 2:**
**Input:** n = 0
**Output:** false
**Explanat... | null | Math,Recursion | Easy | 231,342,1889 |
274 | hello everyone welcome back to my series of videos of me solving lead code problems this problem is H index what is it about given an array of integer citation where citation I is the number of citations a researcher receives for their index paper return the researchers age index what is the age index according to Wiki... | H-Index | h-index | Given an array of integers `citations` where `citations[i]` is the number of citations a researcher received for their `ith` paper, return _the researcher's h-index_.
According to the [definition of h-index on Wikipedia](https://en.wikipedia.org/wiki/H-index): The h-index is defined as the maximum value of `h` such th... | An easy approach is to sort the array first. What are the possible values of h-index? A faster approach is to use extra space. | Array,Sorting,Counting Sort | Medium | 275 |
17 | Hello guys welcome to this remedy subscribe The Channel Please subscribe And subscribe The Amazing subscribe and subscribe the I invented Khoj simple and see how to add that give strength and subscribe And subscribe The Amazing subscribe and subscribe the Video then subscribe The Channel and subscribe in this to India'... | 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 |
1,655 | hey what's up guys this is sean here so today let's take a look at 1655 distribute repeating integers okay so you're given like an integer an array of any integers where there are at most 50 unique values in the array right and then you're also given like an array of m customers other quantities so the each quantity me... | Distribute Repeating Integers | move-sub-tree-of-n-ary-tree | You are given an array of `n` integers, `nums`, where there are at most `50` unique values in the array. You are also given an array of `m` customer order quantities, `quantity`, where `quantity[i]` is the amount of integers the `ith` customer ordered. Determine if it is possible to distribute `nums` such that:
* Th... | Disconnect node p from its parent and append it to the children list of node q. If q was in the sub-tree of node p (case 1), get the parent node of p and replace p in its children list with q. If p was the root of the tree, make q the root of the tree. | Tree,Depth-First Search | Hard | 1650 |
322 | It is 200. Friends, today we have come to the shift question. Coin change and only 10 days are left to divide into lines. There are more questions. It is simple and easy. It means that how many points will it take for us to reach a particular amount. Look at the example. Direct that I have a coin of one rupee, a coin o... | Coin Change | coin-change | You are given an integer array `coins` representing coins of different denominations and an integer `amount` representing a total amount of money.
Return _the fewest number of coins that you need to make up that amount_. If that amount of money cannot be made up by any combination of the coins, return `-1`.
You may a... | null | Array,Dynamic Programming,Breadth-First Search | Medium | 1025,1393,2345 |
225 | Hello welcome back to Anonymous Data Scientist today we will discuss lead code problem number 225 which is implement stack using queues now before discussing it we should know the basic properties of stacks and queues in stack LIFO is used that is last in first out Suppose here we inserted element three inside the stac... | 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 |
1,306 | hey guys welcome back to another video and today we're going to be following the lead code question jump game three all right so in this question we're given an array of non-negative integer given an array of non-negative integer given an array of non-negative integer uh integers air you are initially positioned at sta... | Jump Game III | minimum-absolute-difference | Given an array of non-negative integers `arr`, you are initially positioned at `start` index of the array. When you are at index `i`, you can jump to `i + arr[i]` or `i - arr[i]`, check if you can reach to **any** index with value 0.
Notice that you can not jump outside of the array at any time.
**Example 1:**
**Inp... | Find the minimum absolute difference between two elements in the array. The minimum absolute difference must be a difference between two consecutive elements in the sorted array. | Array,Sorting | Easy | 2248 |
1,954 | If you haven't subscribed today's video is Scotland ice cream 94 young people on the table Mini Garden kilometer cola kinaf Apple and Samsung's new color is necessary punishment two of them epilation direct region million fish Yes no we will sing to you your hairstyle Heart goods We also two Hocaoglu when did we talk c... | Minimum Garden Perimeter to Collect Enough Apples | replace-all-digits-with-characters | In a garden represented as an infinite 2D grid, there is an apple tree planted at **every** integer coordinate. The apple tree planted at an integer coordinate `(i, j)` has `|i| + |j|` apples growing on it.
You will buy an axis-aligned **square plot** of land that is centered at `(0, 0)`.
Given an integer `neededAppl... | We just need to replace every even positioned character with the character s[i] positions ahead of the character preceding it Get the position of the preceeding character in alphabet then advance it s[i] positions and get the character at that position | String | Easy | 878 |
1,503 | hi guys good morning welcome back to the new video so in this video we're going to see the problem last moment before all the ants fall out of blank if you had not watched it we had already discussed in our live weekly contest problem discussions and not only this but also some variations of these kind of ant Collision... | Last Moment Before All Ants Fall Out of a Plank | reducing-dishes | We have a wooden plank of the length `n` **units**. Some ants are walking on the plank, each ant moves with a speed of **1 unit per second**. Some of the ants move to the **left**, the other move to the **right**.
When two ants moving in two **different** directions meet at some point, they change their directions and... | Use dynamic programming to find the optimal solution by saving the previous best like-time coefficient and its corresponding element sum. If adding the current element to the previous best like-time coefficient and its corresponding element sum would increase the best like-time coefficient, then go ahead and add it. Ot... | Array,Dynamic Programming,Greedy,Sorting | Hard | null |
1,822 | hello everyone today we are here to solve question number 1822 of lead code sign of the product of an array input type is list and output type is end means what a list and we have to determine the sign of the product of numbers okay so let's see what is the question there is a function sine func that returns 1 if x is ... | Sign of the Product of an Array | longest-palindromic-subsequence-ii | There is a function `signFunc(x)` that returns:
* `1` if `x` is positive.
* `-1` if `x` is negative.
* `0` if `x` is equal to `0`.
You are given an integer array `nums`. Let `product` be the product of all values in the array `nums`.
Return `signFunc(product)`.
**Example 1:**
**Input:** nums = \[-1,-2,-3,-4,... | As with any good dp problem that uses palindromes, try building the palindrome from the edges The prime point is to check that no two adjacent characters are equal, so save the past character while building the palindrome. | String,Dynamic Programming | Medium | 516 |
112 | all right welcome to this video we're gonna be solving Miko prom 112 past some so give you a binary tree right of numbers and then they'll give you some and you want you to determine so return true or false if you go down a route to leaf path when you add the numbers in each note you can get tolls some provide so in th... | Path Sum | path-sum | Given the `root` of a binary tree and an integer `targetSum`, return `true` if the tree has a **root-to-leaf** path such that adding up all the values along the path equals `targetSum`.
A **leaf** is a node with no children.
**Example 1:**
**Input:** root = \[5,4,8,11,null,13,4,7,2,null,null,null,1\], targetSum = 22... | null | Tree,Depth-First Search,Breadth-First Search,Binary Tree | Easy | 113,124,129,437,666 |
881 | hey everybody this is larry this is day 13 of the january league code daily challenge uh hit the like button hit the subscribe button join me on discord let me know what you think about today's prom votes to save people uh yes i usually solve these lives so um even the explanations are definitely um yeah right fast for... | Boats to Save People | loud-and-rich | You are given an array `people` where `people[i]` is the weight of the `ith` person, and an **infinite number of boats** where each boat can carry a maximum weight of `limit`. Each boat carries at most two people at the same time, provided the sum of the weight of those people is at most `limit`.
Return _the minimum n... | null | Array,Depth-First Search,Graph,Topological Sort | Medium | null |
238 | hey guys it's off by one here and today we're going to be solving product of array except self so in this problem we're given an integer array nums and they want us to return an array answer such that answer of I is equal to the product of all elements of nums except the current nums so what does that mean exactly if w... | Product of Array Except Self | product-of-array-except-self | Given an integer array `nums`, return _an array_ `answer` _such that_ `answer[i]` _is equal to the product of all the elements of_ `nums` _except_ `nums[i]`.
The product of any prefix or suffix of `nums` is **guaranteed** to fit in a **32-bit** integer.
You must write an algorithm that runs in `O(n)` time and without... | null | Array,Prefix Sum | Medium | 42,152,265,2267 |
227 | hey what's up guys this is john here so today let's take a look at 227 basic calculator number two and this is one of the uh the calculator series problems so for this problem there's no parenthesis and there's only uh two operators which is the plus subtract multiply and undivided and they're like us i think the total... | Basic Calculator II | basic-calculator-ii | Given a string `s` which represents an expression, _evaluate this expression and return its value_.
The integer division should truncate toward zero.
You may assume that the given expression is always valid. All intermediate results will be in the range of `[-231, 231 - 1]`.
**Note:** You are not allowed to use any ... | null | Math,String,Stack | Medium | 224,282,785 |
290 | hello everyone myself Rahul so today I am going to solve a problem related to Strings so the problem name is word pattern so let's go through this problem statement so here we are given a pattern and a string s we have to find if s follows the particular pattern the same pattern so here the follow means a full match su... | Word Pattern | word-pattern | Given a `pattern` and a string `s`, find if `s` follows the same pattern.
Here **follow** means a full match, such that there is a bijection between a letter in `pattern` and a **non-empty** word in `s`.
**Example 1:**
**Input:** pattern = "abba ", s = "dog cat cat dog "
**Output:** true
**Example 2:**
**Input:*... | null | Hash Table,String | Easy | 205,291 |
1,591 | hey what's up guys this is john again so uh this time 1591 stringed printer number two so this time the stringer the stringed printer will print following the below the two special rules here on each turn right the printer will print a solid rectangle and this will cover the existing colors in the rectangle and second ... | Strange Printer II | strange-printer-ii | There is a strange printer with the following two special requirements:
* On each turn, the printer will print a solid rectangular pattern of a single color on the grid. This will cover up the existing colors in the rectangle.
* Once the printer has used a color for the above operation, **the same color cannot be ... | null | null | Hard | null |
332 | all right let's look at this problem called reconstruct itinerary so you're given a list of tickets uh ticket represent uh starting airport and ending airport and in your list of tickets is for a single person and you're also given the starting station the starting airport so you started from JFK you have to reconstruc... | 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 |
850 | alright guys welcome to our channel code with sunny and in this video i will be talking about the heart problem of the lead code its index is eight five zero and it is its name is like rectangle area second okay so before moving on to discuss this problem is like i just want to summarize the topics that is being relate... | Rectangle Area II | insert-into-a-sorted-circular-linked-list | You are given a 2D array of axis-aligned `rectangles`. Each `rectangle[i] = [xi1, yi1, xi2, yi2]` denotes the `ith` rectangle where `(xi1, yi1)` are the coordinates of the **bottom-left corner**, and `(xi2, yi2)` are the coordinates of the **top-right corner**.
Calculate the **total area** covered by all `rectangles` ... | null | Linked List | Medium | 147 |
169 | hey if you're welcome back to the channel I hope you guys are doing extremely well so this is another video from the Strivers A to Z DSA course just in case you're for the first time here this is world's most in-depth course in this is world's most in-depth course in this is world's most in-depth course in DS algo why ... | Majority Element | majority-element | Given an array `nums` of size `n`, return _the majority element_.
The majority element is the element that appears more than `⌊n / 2⌋` times. You may assume that the majority element always exists in the array.
**Example 1:**
**Input:** nums = \[3,2,3\]
**Output:** 3
**Example 2:**
**Input:** nums = \[2,2,1,1,1,2,... | null | Array,Hash Table,Divide and Conquer,Sorting,Counting | Easy | 229,1102 |
1,728 | hey everybody this is larry this is me going with q4 of the uh weekly contest 224 uh cat and mouse 2. so i actually thought this one was a little bit easier than q3 for me but uh but that is not the general uh consensus so i don't know about that uh only 49 people solved it this problem um but for me and i there might ... | Cat and Mouse II | fancy-sequence | A game is played by a cat and a mouse named Cat and Mouse.
The environment is represented by a `grid` of size `rows x cols`, where each element is a wall, floor, player (Cat, Mouse), or food.
* Players are represented by the characters `'C'`(Cat)`,'M'`(Mouse).
* Floors are represented by the character `'.'` and c... | Use two arrays to save the cumulative multipliers at each time point and cumulative sums adjusted by the current multiplier. The function getIndex(idx) ask to the current value modulo 10^9+7. Use modular inverse and both arrays to calculate this value. | Math,Design,Segment Tree | Hard | null |
1,920 | Work in this area Ajay will have to That a [ That a [ That a Hello one and welcome to new video English video by going to discuss problem number 90 from the problem 000 agree here and Ichchadhari our in the middle of this From the name of the Laker to one point that and from the railway station duty reduce 2002 number ... | Build Array from Permutation | determine-color-of-a-chessboard-square | Given a **zero-based permutation** `nums` (**0-indexed**), build an array `ans` of the **same length** where `ans[i] = nums[nums[i]]` for each `0 <= i < nums.length` and return it.
A **zero-based permutation** `nums` is an array of **distinct** integers from `0` to `nums.length - 1` (**inclusive**).
**Example 1:**
*... | Convert the coordinates to (x, y) - that is, "a1" is (1, 1), "d7" is (4, 7). Try add the numbers together and look for a pattern. | Math,String | Easy | null |
1,790 | hi my name is david today we're going to do number one seven nine zero check if one string swap can make strings equal this is an easy level problem on the code and we're gonna solve it in javascript we're given a function that takes in two strings s1 and s2 and we want to return true or false if we can make a string s... | Check if One String Swap Can Make Strings Equal | lowest-common-ancestor-of-a-binary-tree-iii | You are given two strings `s1` and `s2` of equal length. A **string swap** is an operation where you choose two indices in a string (not necessarily different) and swap the characters at these indices.
Return `true` _if it is possible to make both strings equal by performing **at most one string swap** on **exactly on... | Store the path from p to the root. Traverse the path from q to the root, the first common point of the two paths is the LCA. | Hash Table,Tree,Binary Tree | Medium | 235,236,1780,1816 |
344 | Jhal Hello Everyone Welcome To My Channel Police Question Is Reverse Entry To Computer Channel Please subscribe this Channel Notification On This Channel Indian Tech Help You With Your Infidelity The Question Is Right The Function Demonstration In Its Ring Is Given By Adding Actors That Both Tape Express For Another Yo... | Reverse String | reverse-string | Write a function that reverses a string. The input string is given as an array of characters `s`.
You must do this by modifying the input array [in-place](https://en.wikipedia.org/wiki/In-place_algorithm) with `O(1)` extra memory.
**Example 1:**
**Input:** s = \["h","e","l","l","o"\]
**Output:** \["o","l","l","e","h... | The entire logic for reversing a string is based on using the opposite directional two-pointer approach! | Two Pointers,String,Recursion | Easy | 345,541 |
64 | Tiger, in this video, we will find the solution to this in minimum questions. We have the complete matrix in front of us. Sorry, inside the maths, that Bigg Boss has been given. Friends, you will have to pay to fix it and you have to carry the topless button. There are many of you. Dreams are quite difficult, so you ca... | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.