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 |
|---|---|---|---|---|---|---|---|---|
815 | hey what's up guys chung here again so tonight let's take a look at this uh lead code problem here which is number 815 bus routes okay heart i like this problem so if we have a list of both roots and each roots uh roots i the bus route that's basically the route is a kind of list for example if the route 0 is a 1 5 7 i... | Bus Routes | champagne-tower | You are given an array `routes` representing bus routes where `routes[i]` is a bus route that the `ith` bus repeats forever.
* For example, if `routes[0] = [1, 5, 7]`, this means that the `0th` bus travels in the sequence `1 -> 5 -> 7 -> 1 -> 5 -> 7 -> 1 -> ...` forever.
You will start at the bus stop `source` (You... | null | Dynamic Programming | Medium | 1385 |
144 | Where there is in order travels sale, this is question number 94 and one is question number 145 which is post order, so we will see these three questions here, how will these three questions be here, okay, so you see an easy level here. The question is difficult, the upward is very high, okay, the question is quite goo... | Binary Tree Preorder Traversal | binary-tree-preorder-traversal | Given the `root` of a binary tree, return _the preorder traversal of its nodes' values_.
**Example 1:**
**Input:** root = \[1,null,2,3\]
**Output:** \[1,2,3\]
**Example 2:**
**Input:** root = \[\]
**Output:** \[\]
**Example 3:**
**Input:** root = \[1\]
**Output:** \[1\]
**Constraints:**
* The number of nodes ... | null | Stack,Tree,Depth-First Search,Binary Tree | Easy | 94,255,775 |
1,047 | how's it going guys so today i'm going to solve the question which is remove all adjacent duplicates in string so this question is quite simple like if you understand this question like you understand how the stack is working so we use the help of stack for this question all right so let's just read the first question ... | Remove All Adjacent Duplicates In String | maximize-sum-of-array-after-k-negations | You are given a string `s` consisting of lowercase English letters. A **duplicate removal** consists of choosing two **adjacent** and **equal** letters and removing them.
We repeatedly make **duplicate removals** on `s` until we no longer can.
Return _the final string after all such duplicate removals have been made_... | null | Array,Greedy,Sorting | Easy | 2204 |
670 | hey what's up guys john here again so today i want to talk about another lead called problem here number 670 maximum swap so the problem description is fairly straightforward basically you're given like an integer and you can only swap two digits at once at most once and then you need to return the possible maximum num... | Maximum Swap | maximum-swap | You are given an integer `num`. You can swap two digits at most once to get the maximum valued number.
Return _the maximum valued number you can get_.
**Example 1:**
**Input:** num = 2736
**Output:** 7236
**Explanation:** Swap the number 2 and the number 7.
**Example 2:**
**Input:** num = 9973
**Output:** 9973
**E... | null | Math,Greedy | Medium | 321 |
309 | hello everyone welcome to my YouTube channel today I'm sorry little question 309 best time to buy and sell stock with cooldown you are given a great prices where prices I is the price of a given stock on the ice day find the maximum profit you can achieve you may complete as many transactions as you like that is buy on... | 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 |
14 | Hello Gas Myself Amrita Welcome Back To Our Channel Techno Sage So In Today's Video We Are Going To Discuss Lead Code Problem Number 14 Date Is Longest Common Prefix So Let's Get Started Let's First Understand The Problem Write Un Function To Find The Longest Common Prefix String Amongst And Are Of Strings If There Is ... | Longest Common Prefix | longest-common-prefix | Write a function to find the longest common prefix string amongst an array of strings.
If there is no common prefix, return an empty string `" "`.
**Example 1:**
**Input:** strs = \[ "flower ", "flow ", "flight "\]
**Output:** "fl "
**Example 2:**
**Input:** strs = \[ "dog ", "racecar ", "car "\]
**Output:** " "... | null | String | Easy | null |
134 | hello and welcome to my YouTube channel today's video will be solving the gas station problem from its code before we get started make sure to hit that subscribe button if you haven't already that's why you won't miss out on any of the great content we have planned for this channel thanks for watching and let's get sta... | 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 |
436 | hey everybody this is larry this is day 27 of the august eco daily challenge uh hit the like button hit the subscribe button join me in discord and let's get started on find right interval uh okay give him a set of check if there exists an integral j equals storm point is bigger or equal to n point of integral i which ... | Find Right Interval | find-right-interval | You are given an array of `intervals`, where `intervals[i] = [starti, endi]` and each `starti` is **unique**.
The **right interval** for an interval `i` is an interval `j` such that `startj >= endi` and `startj` is **minimized**. Note that `i` may equal `j`.
Return _an array of **right interval** indices for each int... | null | Array,Binary Search,Sorting | Medium | 352 |
35 | hey everyone welcome back and let's write some more neat code today so today let's look at leak code 35 search insert position so we're given an array of distinct integers just like this one down here and a target value in this example the target value is 5 and we want to know does this 5 exist in this input array if i... | Search Insert Position | search-insert-position | Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.
You must write an algorithm with `O(log n)` runtime complexity.
**Example 1:**
**Input:** nums = \[1,3,5,6\], target = 5
**Output:** 2
**Exa... | null | Array,Binary Search | Easy | 278 |
1,695 | hey there everyone welcome back to lead coding in this video we'll be solving the second question of lead code weekly contest 220 name of the problem is maximum erratio value so this is the solution that i came up during the contest is still going on and in case you have some better approach that currently i am not abl... | Maximum Erasure Value | maximum-sum-obtained-of-any-permutation | You are given an array of positive integers `nums` and want to erase a subarray containing **unique elements**. The **score** you get by erasing the subarray is equal to the **sum** of its elements.
Return _the **maximum score** you can get by erasing **exactly one** subarray._
An array `b` is called to be a subarray... | Indexes with higher frequencies should be bound with larger values | Array,Greedy,Sorting,Prefix Sum | Medium | null |
42 | in this video we're going to take a look at um a lethal problem called trapping rain water so given a negative integers representing a elevation map where the width of each bar is one compute how much water it can trap after raining so here you can see we have an array and the above elevation map uh the black section i... | Trapping Rain Water | trapping-rain-water | Given `n` non-negative integers representing an elevation map where the width of each bar is `1`, compute how much water it can trap after raining.
**Example 1:**
**Input:** height = \[0,1,0,2,1,0,1,3,2,1,2,1\]
**Output:** 6
**Explanation:** The above elevation map (black section) is represented by array \[0,1,0,2,1,... | null | Array,Two Pointers,Dynamic Programming,Stack,Monotonic Stack | Hard | 11,238,407,756 |
1,558 | uh let's go to question 15 58 minimum numbers of function course to make target only this is medium question let's get into it okay let's check the function first our name is modify and then argument first argument is already and then second operation and this are these index okay if operation is zero at the value one ... | Minimum Numbers of Function Calls to Make Target Array | course-schedule-iv | You are given an integer array `nums`. You have an integer array `arr` of the same length with all values set to `0` initially. You also have the following `modify` function:
You want to use the modify function to covert `arr` to `nums` using the minimum number of calls.
Return _the minimum number of function calls t... | Imagine if the courses are nodes of a graph. We need to build an array isReachable[i][j]. Start a bfs from each course i and assign for each course j you visit isReachable[i][j] = True. Answer the queries from the isReachable array. | Depth-First Search,Breadth-First Search,Graph,Topological Sort | Medium | null |
1,261 | Hello Hi Friends Welcome Back Today We Are Going To Solid Problem 12615 Elements In Contaminated Binary Tree Before Will Look Into The Details Of The Problem And Some Examples Of Just Want To Mention That My Channel Focuses On Helping People Were Preparing For Java Coding Interview And Telephonic Interview Sun My Chann... | 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 |
1,845 | hey everybody this is larry this week over q2 of the bi-weekly contest 51 week over q2 of the bi-weekly contest 51 week over q2 of the bi-weekly contest 51 uh seat restoration manager uh hit the like button is a subscriber and join me on discord let me know what you think about this apartment during the contest and so ... | Seat Reservation Manager | largest-submatrix-with-rearrangements | Design a system that manages the reservation state of `n` seats that are numbered from `1` to `n`.
Implement the `SeatManager` class:
* `SeatManager(int n)` Initializes a `SeatManager` object that will manage `n` seats numbered from `1` to `n`. All seats are initially available.
* `int reserve()` Fetches the **sm... | For each column, find the number of consecutive ones ending at each position. For each row, sort the cumulative ones in non-increasing order and "fit" the largest submatrix. | Array,Greedy,Sorting,Matrix | Medium | 695 |
23 | in this video we'll be going over merge case sorted list so you're given an array of k linked lists each linked list is sorted in ascending order merge all of the linked list into one sorted like list and return it so in our first example we have 145 as a first list and then one three four second less and two and six a... | Merge k Sorted Lists | merge-k-sorted-lists | You are given an array of `k` linked-lists `lists`, each linked-list is sorted in ascending order.
_Merge all the linked-lists into one sorted linked-list and return it._
**Example 1:**
**Input:** lists = \[\[1,4,5\],\[1,3,4\],\[2,6\]\]
**Output:** \[1,1,2,3,4,4,5,6\]
**Explanation:** The linked-lists are:
\[
1->4... | null | Linked List,Divide and Conquer,Heap (Priority Queue),Merge Sort | Hard | 21,264 |
347 | Half a minute Spencer will be the chairman of the commission. He said that now we will solve good nutrition. Till now we have done all sparingly here comes at present president. How to delete all 10 inches right. We had asked the question in the last. I am assuming this. After all, we have to see the settings of the co... | Top K Frequent Elements | top-k-frequent-elements | Given an integer array `nums` and an integer `k`, return _the_ `k` _most frequent elements_. You may return the answer in **any order**.
**Example 1:**
**Input:** nums = \[1,1,1,2,2,3\], k = 2
**Output:** \[1,2\]
**Example 2:**
**Input:** nums = \[1\], k = 1
**Output:** \[1\]
**Constraints:**
* `1 <= nums.lengt... | null | Array,Hash Table,Divide and Conquer,Sorting,Heap (Priority Queue),Bucket Sort,Counting,Quickselect | Medium | 192,215,451,659,692,1014,1919 |
1,937 | hey guys uh in this video we can discuss decode one three one nine three seven the maximum number of points we can collect with the cost so basically for this program we're going to be given a greater points and uh we're gonna start from the first row and the correct one uh select one cell and then move to the second r... | 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 |
332 | hey everybody so today's question is reconstruct a denarii so in this we have given some list of tickets in those tickets we have given the two airports that have our pair of departure and arrival Airport so what we have to do is we have to find the final route that we can take starting from JFK Airport so that we can ... | 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 |
202 | Hello friends, so in today's video, you are going to explain Happy Number, what is the basic happy number, what is the problem, like if someone is giving a number, can this number be called basically any positive, it should be okay and play it when Have to repeat till if he is a servant in the house subscribe 280 in th... | Happy Number | happy-number | Write an algorithm to determine if a number `n` is happy.
A **happy number** is a number defined by the following process:
* Starting with any positive integer, replace the number by the sum of the squares of its digits.
* Repeat the process until the number equals 1 (where it will stay), or it **loops endlessly ... | null | Hash Table,Math,Two Pointers | Easy | 141,258,263,2076 |
1,887 | uh in my eye hey everybody this is day 19 of the Leo day challenge hit the like button hit the subscribe on join me on Discord let me know what you think about today's far and also today's VI uh here I am in NOA um yeah just enjoying no uh in this Temple yeah let's get back to the problem yeah uh day let's go hit all t... | Reduction Operations to Make the Array Elements Equal | minimum-degree-of-a-connected-trio-in-a-graph | Given an integer array `nums`, your goal is to make all elements in `nums` equal. To complete one operation, follow these steps:
1. Find the **largest** value in `nums`. Let its index be `i` (**0-indexed**) and its value be `largest`. If there are multiple elements with the largest value, pick the smallest `i`.
2. F... | Consider a trio with nodes u, v, and w. The degree of the trio is just degree(u) + degree(v) + degree(w) - 6. The -6 comes from subtracting the edges u-v, u-w, and v-w, which are counted twice each in the vertex degree calculation. To get the trios (u,v,w), you can iterate on u, then iterate on each w,v such that w and... | Graph | Hard | null |
226 | Hello friends today I'm going to solve liquid problem number 2 26 invert binary tree so here in this problem we are given the root of a binary tree and we need to invert the tree and return its root so first of all let's see what's a binary tree so binary tree is a tree which has a root node it starts with a root note ... | 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 |
1,706 | hey what's up guys so another question from lead code 75 level 2. so this question basically says yeah that we have a 2d array okay and if my particular cell says that it's of one value of one that means I'm gonna go towards right and if the next cell says that the value is one then I can successfully go to the next co... | Where Will the Ball Fall | min-cost-to-connect-all-points | You have a 2-D `grid` of size `m x n` representing a box, and you have `n` balls. The box is open on the top and bottom sides.
Each cell in the box has a diagonal board spanning two corners of the cell that can redirect a ball to the right or to the left.
* A board that redirects the ball to the right spans the top... | Connect each pair of points with a weighted edge, the weight being the manhattan distance between those points. The problem is now the cost of minimum spanning tree in graph with above edges. | Array,Union Find,Minimum Spanning Tree | Medium | 2287 |
870 | hello everyone welcome to kurdish camp hope you're all doing great and today we are going to cover advantage shuffle so the input given here is in two integer array a and b and we have to return any permutation of a that maximize its advantage with respect to b so what is the advantage of a with respect to b is that th... | Advantage Shuffle | magic-squares-in-grid | You are given two integer arrays `nums1` and `nums2` both of the same length. The **advantage** of `nums1` with respect to `nums2` is the number of indices `i` for which `nums1[i] > nums2[i]`.
Return _any permutation of_ `nums1` _that maximizes its **advantage** with respect to_ `nums2`.
**Example 1:**
**Input:** nu... | null | Array,Math,Matrix | Medium | 1311 |
1,569 | hey everybody this is larry this is me going over weekly contest 204's uh q4 a number of ways to reorder a way to get same bst uh hit the like button to subscribe and join the discord uh this is a tricky prom but a lot of it is because it requires math i don't know if it will be a good interview question um but we'll g... | Number of Ways to Reorder Array to Get Same BST | max-dot-product-of-two-subsequences | Given an array `nums` that represents a permutation of integers from `1` to `n`. We are going to construct a binary search tree (BST) by inserting the elements of `nums` in order into an initially empty BST. Find the number of different ways to reorder `nums` so that the constructed BST is identical to that formed from... | Use dynamic programming, define DP[i][j] as the maximum dot product of two subsequences starting in the position i of nums1 and position j of nums2. | Array,Dynamic Programming | Hard | null |
617 | Hello guys welcome to my interesting video not only coding that time also you can do it problem school malls 2nd T20 series level professional life get started solving abilities and physically mode tours and it's true love you all the value of the other is the note viewers you tree To understand what is this tours and ... | 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 |
349 | hey guys welcome to a new video in today's video we're going to look at a lead code problem and the problem's name is intersection of two arrays so in this question we given two integer arrays nums one and nums two and our task is to return an array of their intersection so by intersection it means the common elements ... | Intersection of Two Arrays | intersection-of-two-arrays | Given two integer arrays `nums1` and `nums2`, return _an array of their intersection_. Each element in the result must be **unique** and you may return the result in **any order**.
**Example 1:**
**Input:** nums1 = \[1,2,2,1\], nums2 = \[2,2\]
**Output:** \[2\]
**Example 2:**
**Input:** nums1 = \[4,9,5\], nums2 = \... | null | Array,Hash Table,Two Pointers,Binary Search,Sorting | Easy | 350,1149,1392,2190,2282 |
131 | What are you going to cover? Video: Paren What are you going to cover? Video: Paren What are you going to cover? Video: Paren Drum Partitioning is a thing of the exam. Let's do it. Parallelogram Partitioning is fine. You can solve it with DP also. If you have not studied the degree then you will have background and thi... | 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 |
862 | hello guys welcome back to tech dose and in this video we will see the shortest sub array with some greater than equals k problem which is from lead code number 862. a prerequisite before watching the current video is to watch my video on lead code number 209 because the technique being used here is used in this proble... | Shortest Subarray with Sum at Least K | find-and-replace-in-string | Given an integer array `nums` and an integer `k`, return _the length of the shortest non-empty **subarray** of_ `nums` _with a sum of at least_ `k`. If there is no such **subarray**, return `-1`.
A **subarray** is a **contiguous** part of an array.
**Example 1:**
**Input:** nums = \[1\], k = 1
**Output:** 1
**Examp... | null | Array,String,Sorting | Medium | null |
241 | hey folks welcome back to another video today we're looking at question um 241 different ways to add parenthesis the way we'll be solving this problem is by using recursion um and memorization as well so the reason why we're using recursion right here is because every time you look at a problem it can be divided into s... | Different Ways to Add Parentheses | different-ways-to-add-parentheses | Given a string `expression` of numbers and operators, return _all possible results from computing all the different possible ways to group numbers and operators_. You may return the answer in **any order**.
The test cases are generated such that the output values fit in a 32-bit integer and the number of different res... | null | Math,String,Dynamic Programming,Recursion,Memoization | Medium | 95,224,282,2147,2328 |
817 | hi everyone let's solve this problem linked list components so the problem statement says we are given this linked list 0 1 2 3 and a list g which has subset of values from this linked list which is 0 1 3 all we need to return is total number of connected components so what's the definition of a connected component so ... | Linked List Components | design-hashmap | You are given the `head` of a linked list containing unique integer values and an integer array `nums` that is a subset of the linked list values.
Return _the number of connected components in_ `nums` _where two values are connected if they appear **consecutively** in the linked list_.
**Example 1:**
**Input:** head... | null | Array,Hash Table,Linked List,Design,Hash Function | Easy | 816,1337 |
338 | hey guys welcome back to the channel in our previous video we solved this problem counting bits the easy problem but we started using a method called extends okay this solution was pretty good it gave us a hundred percent timing it was a really good method of solving this but however i found this it might be a little b... | 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 |
285 | all right so this question is in order successor in BST so you're given a rot of a tree and there's a p value and then you want to make sure who is the parent of P basically right sucessor is going to be no two in this case so if no six um you will return no because there's no in order so it has to be in order so what ... | Inorder Successor in BST | inorder-successor-in-bst | Given the `root` of a binary search tree and a node `p` in it, return _the in-order successor of that node in the BST_. If the given node has no in-order successor in the tree, return `null`.
The successor of a node `p` is the node with the smallest key greater than `p.val`.
**Example 1:**
**Input:** root = \[2,1,3\... | null | Tree,Depth-First Search,Binary Search Tree,Binary Tree | Medium | 94,173,509 |
1,706 | That Album Pack And This Suggestion Will Take Another List Ko Problem Vriddhi Phil All Problem Appeared In The Doctor Just Watch This Video And Have Something Interesting For You Feature Problem Sirf Hai Vipin Ki Vriddhi Date Of Science And Roshan And Behavior And Goals Ok Sukhvind Sanobar Kabir Vidron In Witch Ear Fro... | Where Will the Ball Fall | min-cost-to-connect-all-points | You have a 2-D `grid` of size `m x n` representing a box, and you have `n` balls. The box is open on the top and bottom sides.
Each cell in the box has a diagonal board spanning two corners of the cell that can redirect a ball to the right or to the left.
* A board that redirects the ball to the right spans the top... | Connect each pair of points with a weighted edge, the weight being the manhattan distance between those points. The problem is now the cost of minimum spanning tree in graph with above edges. | Array,Union Find,Minimum Spanning Tree | Medium | 2287 |
115 | Hello friends, in today's video we are going to talk about liquid problem district, first of all this problem is a very famous problem, it is a very important problem because of the limit of Indian etc. and many times it means that it has been asked in the interview of a good company, then it is okay. Is the problem no... | Distinct Subsequences | distinct-subsequences | Given two strings `s` and `t`, return _the number of distinct_ **_subsequences_** _of_ `s` _which equals_ `t`.
The test cases are generated so that the answer fits on a 32-bit signed integer.
**Example 1:**
**Input:** s = "rabbbit ", t = "rabbit "
**Output:** 3
**Explanation:**
As shown below, there are 3 ways you... | null | String,Dynamic Programming | Hard | 2115 |
844 | Hello everyone welcome to my channel Quote Surrey with Mike So today we are going to do video number 23 of our strings playlist Lee number 844 is a very easy question we will make it with two approaches both small and approachable asked this question and it is very important And this is a good question, from the interv... | Backspace String Compare | backspace-string-compare | Given two strings `s` and `t`, return `true` _if they are equal when both are typed into empty text editors_. `'#'` means a backspace character.
Note that after backspacing an empty text, the text will continue empty.
**Example 1:**
**Input:** s = "ab#c ", t = "ad#c "
**Output:** true
**Explanation:** Both s and t... | null | null | Easy | null |
1,696 | hey what's up guys this is sean here so today let's take a look at uh this one 1696 jump game number six so you're given like a zero index integer arrays then read nums and an integer k so you can do uh a move uh basic a jump right so which means that you can you start from index zero and your goal is to reach the end ... | Jump Game VI | strange-printer-ii | You are given a **0-indexed** integer array `nums` and an integer `k`.
You are initially standing at index `0`. In one move, you can jump at most `k` steps forward without going outside the boundaries of the array. That is, you can jump from index `i` to any index in the range `[i + 1, min(n - 1, i + k)]` **inclusive*... | Try thinking in reverse. Given the grid, how can you tell if a colour was painted last? | Array,Graph,Topological Sort,Matrix | Hard | 664 |
160 | Hello Everyone Welcome to Centerpoint Today We Are Going to Solve Analysis Problem Name Intersection of Princely States Software for President subscribe and subscribe this Video Subscribe As Suffering From One To Avoid This Particular Intex Existence To Return Back To 1282 Where is the intersect 90 Pushpendra Films Sho... | Intersection of Two Linked Lists | intersection-of-two-linked-lists | Given the heads of two singly linked-lists `headA` and `headB`, return _the node at which the two lists intersect_. If the two linked lists have no intersection at all, return `null`.
For example, the following two linked lists begin to intersect at node `c1`:
The test cases are generated such that there are no cycle... | null | Hash Table,Linked List,Two Pointers | Easy | 599 |
1,730 | so this PA to get food I solved this problem in 11 minutes and now let me try to solve it again to check how many minutes I need to solve this problem while am yeah while am also giving a introduction of this problem and explain how to solve it so normally for this problem we are giving a people so the people want to e... | Shortest Path to Get Food | special-array-with-x-elements-greater-than-or-equal-x | You are starving and you want to eat food as quickly as possible. You want to find the shortest path to arrive at any food cell.
You are given an `m x n` character matrix, `grid`, of these different types of cells:
* `'*'` is your location. There is **exactly one** `'*'` cell.
* `'#'` is a food cell. There may be... | Count the number of elements greater than or equal to x for each x in the range [0, nums.length]. If for any x, the condition satisfies, return that x. Otherwise, there is no answer. | Array,Binary Search,Sorting | Easy | null |
818 | cool 8:18 race car or your car starts at cool 8:18 race car or your car starts at cool 8:18 race car or your car starts at position zero and speed past one an infinite number line your car can go into negative physician's car drives automatically according to sequence of instructions a and are when you get in instructi... | Race Car | similar-rgb-color | Your car starts at position `0` and speed `+1` on an infinite number line. Your car can go into negative positions. Your car drives automatically according to a sequence of instructions `'A'` (accelerate) and `'R'` (reverse):
* When you get an instruction `'A'`, your car does the following:
* `position += spee... | null | Math,String,Enumeration | Easy | null |
1,609 | hello and welcome to another video in this video we're going to be looking at even odd tree and in this problem you have a tree and all of its nodes are on different levels so the root starts at level zero then the next is level one level two level three and for every even level the nodes all have to be odd and increas... | Even Odd Tree | find-all-the-lonely-nodes | A binary tree is named **Even-Odd** if it meets the following conditions:
* The root of the binary tree is at level index `0`, its children are at level index `1`, their children are at level index `2`, etc.
* For every **even-indexed** level, all nodes at the level have **odd** integer values in **strictly increa... | Do a simple tree traversal, try to check if the current node is lonely or not. Node is lonely if at least one of the left/right pointers is null. | Tree,Depth-First Search,Breadth-First Search,Binary Tree | Easy | 563,1005 |
368 | hey everybody this is Larry this is day nine of the Le Cod daily challenge hit the like button hit the Subscribe button Joop me on Discord let me know what you think about this one and of course I'm going to do an extra PR after this I think so uh definitely check that out oh huh have to reset but uh hope everyone's do... | Largest Divisible Subset | largest-divisible-subset | Given a set of **distinct** positive integers `nums`, return the largest subset `answer` such that every pair `(answer[i], answer[j])` of elements in this subset satisfies:
* `answer[i] % answer[j] == 0`, or
* `answer[j] % answer[i] == 0`
If there are multiple solutions, return any of them.
**Example 1:**
**Inp... | null | Array,Math,Dynamic Programming,Sorting | Medium | null |
1,625 | hey what's up guys this is sean here so let's talk about uh this week's weekly contest problem number uh 1625 a lexicographically smallest stream after applying operations i hate this problem you know because it wastes me a lot of time on it okay sorry i'm a bit a little bit running my nose so okay so bear with my voic... | Lexicographically Smallest String After Applying Operations | group-sold-products-by-the-date | You are given a string `s` of **even length** consisting of digits from `0` to `9`, and two integers `a` and `b`.
You can apply either of the following two operations any number of times and in any order on `s`:
* Add `a` to all odd indices of `s` **(0-indexed)**. Digits post `9` are cycled back to `0`. For example... | null | Database | Easy | 2335 |
645 | welcome to march's leeco challenge today's problem is set mismatch you have a set of integers s which originally contains all the numbers from one to n unfortunately due to some error one of the numbers in s got duplicated to another number in the set which results in a repetition of one number and a loss of one number... | Set Mismatch | set-mismatch | You have a set of integers `s`, which originally contains all the numbers from `1` to `n`. Unfortunately, due to some error, one of the numbers in `s` got duplicated to another number in the set, which results in **repetition of one** number and **loss of another** number.
You are given an integer array `nums` represe... | null | Array,Hash Table,Bit Manipulation,Sorting | Easy | 287 |
1,552 | Gone leave Nanda Bachchan in a fiction post They specifically for ordinary Questions and will look into its difficult situation Reduce specific Subscribe Coming to loot that we have to match towards the previous Pigmented cells in this post This definition is given between Any to you that what is saying about drying of... | Magnetic Force Between Two Balls | build-an-array-with-stack-operations | In the universe Earth C-137, Rick discovered a special form of magnetic force between two balls if they are put in his new invented basket. Rick has `n` empty baskets, the `ith` basket is at `position[i]`, Morty has `m` balls and needs to distribute the balls into the baskets such that the **minimum magnetic force** be... | Use “Push” for numbers to be kept in target array and [“Push”, “Pop”] for numbers to be discarded. | Array,Stack,Simulation | Easy | null |
480 | So how can't you all do well? In front of you, in which we have already asked the question which is our find media in data stream, the concept of the same will be there on the user here and this is our question which is lead code quality which we are going to do now in this. Another concept is going to be created which... | Sliding Window Median | sliding-window-median | The **median** is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two middle values.
* For examples, if `arr = [2,3,4]`, the median is `3`.
* For examples, if `arr = [1,2,3,4]`, the median is `(2 + 3) / 2 = 2.5`.
You are give... | The simplest of solutions comes from the basic idea of finding the median given a set of numbers. We know that by definition, a median is the center element (or an average of the two center elements). Given an unsorted list of numbers, how do we find the median element? If you know the answer to this question, can we e... | Array,Hash Table,Sliding Window,Heap (Priority Queue) | Hard | 295 |
1,190 | hey everybody this is Ben and welcome back to another Elite code video and today we're going to be looking at problem 1190 titled reverse substrings between each pair of parentheses we will read The Prompt we'll talk about the pseudo code we'll walk through an example and then we will type a code up a solution together... | Reverse Substrings Between Each Pair of Parentheses | smallest-common-region | You are given a string `s` that consists of lower case English letters and brackets.
Reverse the strings in each pair of matching parentheses, starting from the innermost one.
Your result should **not** contain any brackets.
**Example 1:**
**Input:** s = "(abcd) "
**Output:** "dcba "
**Example 2:**
**Input:** s... | Try to model the problem as a graph problem. The given graph is a tree. The problem is reduced to finding the lowest common ancestor of two nodes in a tree. | Array,Hash Table,String,Tree,Depth-First Search,Breadth-First Search | Medium | 235,236 |
1,870 | hey everybody this is Larry this is Day 26 of the liko daily challenge hit the like button subscribe button join me on Discord let me know what you think about this from 1870 minimum time to or minimum speed to arrive on time oops uh yeah hit all the good buttons let's see what this problem's about okay so you're givin... | Minimum Speed to Arrive on Time | minimum-speed-to-arrive-on-time | You are given a floating-point number `hour`, representing the amount of time you have to reach the office. To commute to the office, you must take `n` trains in sequential order. You are also given an integer array `dist` of length `n`, where `dist[i]` describes the distance (in kilometers) of the `ith` train ride.
E... | null | null | Medium | null |
7 | so uh we are going to uh understand one interesting question if you have given one integer suppose if you have given one integer one two three and you have to reverse it how you can do that or suppose you have a minus number suppose minus 3 4 2. so you should make it the two four three so this is the problems how you a... | 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 |
658 | hey hello there so today we have another binary search question 658 e to find K closest islands we have a sorted array ARR and two integer values K and X we want to find the K closest elements to this X reference number the value X may or may not be in this array we don't really care the usage of X is to use it as a re... | Find K Closest Elements | find-k-closest-elements | Given a **sorted** integer array `arr`, two integers `k` and `x`, return the `k` closest integers to `x` in the array. The result should also be sorted in ascending order.
An integer `a` is closer to `x` than an integer `b` if:
* `|a - x| < |b - x|`, or
* `|a - x| == |b - x|` and `a < b`
**Example 1:**
**Input:... | null | Array,Two Pointers,Binary Search,Sorting,Heap (Priority Queue) | Medium | 374,375,719 |
35 | Salaam Welcome, so today we have come with a new video, search insert po que, let's code it, what will be your code, first of all, you will have to declare low one webble, right from zero, after that you will have to int high equal to numbers dot length which Length is your number's ok, minus and ok, after that now her... | Search Insert Position | search-insert-position | Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.
You must write an algorithm with `O(log n)` runtime complexity.
**Example 1:**
**Input:** nums = \[1,3,5,6\], target = 5
**Output:** 2
**Exa... | null | Array,Binary Search | Easy | 278 |
1,636 | Hello friends welcome to my channel let's have a look at problem 1636 sought a read by increasing frequency in this video we are going to share two formats of solutions based on the method of using sorting key first I'll read through the problem statement and then we do the coding at the in between which we explain the... | Sort Array by Increasing Frequency | number-of-substrings-with-only-1s | Given an array of integers `nums`, sort the array in **increasing** order based on the frequency of the values. If multiple values have the same frequency, sort them in **decreasing** order.
Return the _sorted array_.
**Example 1:**
**Input:** nums = \[1,1,2,2,2,3\]
**Output:** \[3,1,1,2,2,2\]
**Explanation:** '3' h... | Count number of 1s in each consecutive-1 group. For a group with n consecutive 1s, the total contribution of it to the final answer is (n + 1) * n // 2. | Math,String | Medium | 1885,2186 |
951 | hey everyone welcome back and let's write some more neat code today so today let's solve the problem flip equivalent binary trees so we have a definition of a flip operation for a binary tree a flip operation is defined as choosing any single node in the tree and then taking the left and right subtrees of that node and... | Flip Equivalent Binary Trees | partition-array-into-disjoint-intervals | For a binary tree **T**, we can define a **flip operation** as follows: choose any node, and swap the left and right child subtrees.
A binary tree **X** is _flip equivalent_ to a binary tree **Y** if and only if we can make **X** equal to **Y** after some number of flip operations.
Given the roots of two binary trees... | null | Array | Medium | 2138 |
64 | hello viewers welcome back to my channel i hope you are enjoying all the videos if you have not subscribed yet please subscribe to my channel and here among other friends i am back with another dynamic programming problem from lead code today it is uh the minimum path sum we are given with m y and grid filled with non-... | 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 |
1,460 | in this video we will solve lead code 1460 it says that you are given two arrays one is target and second one is some other array and your task is to convert this arr to target and what you can do you are allowed to select a sub array out of this and then reverse that sub array and you can do that multiple times so can... | Make Two Arrays Equal by Reversing Subarrays | number-of-substrings-containing-all-three-characters | You are given two integer arrays of equal length `target` and `arr`. In one step, you can select any **non-empty subarray** of `arr` and reverse it. You are allowed to make any number of steps.
Return `true` _if you can make_ `arr` _equal to_ `target` _or_ `false` _otherwise_.
**Example 1:**
**Input:** target = \[1,... | For each position we simply need to find the first occurrence of a/b/c on or after this position. So we can pre-compute three link-list of indices of each a, b, and c. | Hash Table,String,Sliding Window | Medium | 2187 |
985 | here I present solution to day 21st of September lead code challenge the problem that we have in today is some of NE even numbers after queries so I'll be explaining you this question as well as the algorithm by the presentation so let's quickly hop on to it now let's try and understand the question by an example here ... | Sum of Even Numbers After Queries | bag-of-tokens | You are given an integer array `nums` and an array `queries` where `queries[i] = [vali, indexi]`.
For each query `i`, first, apply `nums[indexi] = nums[indexi] + vali`, then print the sum of the even values of `nums`.
Return _an integer array_ `answer` _where_ `answer[i]` _is the answer to the_ `ith` _query_.
**Exam... | null | Array,Two Pointers,Greedy,Sorting | Medium | null |
96 | hey everybody this is Larry this is day 24 of the decode June daily challenge I don't like button to subscribe button join it this quote for chat and let's get started unique binary search tree given n how many structurally unique binary search trees that stores values 1 2 n given 3 years 5 okay so this is a very famou... | Unique Binary Search Trees | unique-binary-search-trees | Given an integer `n`, return _the number of structurally unique **BST'**s (binary search trees) which has exactly_ `n` _nodes of unique values from_ `1` _to_ `n`.
**Example 1:**
**Input:** n = 3
**Output:** 5
**Example 2:**
**Input:** n = 1
**Output:** 1
**Constraints:**
* `1 <= n <= 19` | null | Math,Dynamic Programming,Tree,Binary Search Tree,Binary Tree | Medium | 95 |
1,770 | so hey there everyone welcome back so let's solve this today's problem of the day name is maximum score from performing multiplication operations so let's read the problem uh so we are given two integer arrays nums and multipliers of size n and M respectively where n is greater than or equal to M so the arrays are one ... | Maximum Score from Performing Multiplication Operations | minimum-deletions-to-make-character-frequencies-unique | You are given two **0-indexed** integer arrays `nums` and `multipliers` of size `n` and `m` respectively, where `n >= m`.
You begin with a score of `0`. You want to perform **exactly** `m` operations. On the `ith` operation (**0-indexed**) you will:
* Choose one integer `x` from **either the start or the end** of t... | As we can only delete characters, if we have multiple characters having the same frequency, we must decrease all the frequencies of them, except one. Sort the alphabet characters by their frequencies non-increasingly. Iterate on the alphabet characters, keep decreasing the frequency of the current character until it re... | String,Greedy,Sorting | Medium | 1355,2212 |
371 | hello everyone and welcome to my next self-study session today we're going to self-study session today we're going to self-study session today we're going to be looking at equal number 371 the sum of two integers and so basically with this problem we're given two numbers and we're required to add them together without ... | Sum of Two Integers | sum-of-two-integers | Given two integers `a` and `b`, return _the sum of the two integers without using the operators_ `+` _and_ `-`.
**Example 1:**
**Input:** a = 1, b = 2
**Output:** 3
**Example 2:**
**Input:** a = 2, b = 3
**Output:** 5
**Constraints:**
* `-1000 <= a, b <= 1000` | null | Math,Bit Manipulation | Medium | 2 |
821 | Jhaal Hello Guys Welcome to Your Consideration subscribe and subscribe the Channel Please subscribe and subscribe the Distance from Character subscribe and subscribe this Video subscribe Kare Tak Apni To Point Jadi Services subscribe and subscribe the Video then subscribe to the Page Candidates Right Inside Birthday Ar... | Shortest Distance to a Character | bricks-falling-when-hit | Given a string `s` and a character `c` that occurs in `s`, return _an array of integers_ `answer` _where_ `answer.length == s.length` _and_ `answer[i]` _is the **distance** from index_ `i` _to the **closest** occurrence of character_ `c` _in_ `s`.
The **distance** between two indices `i` and `j` is `abs(i - j)`, where... | null | Array,Union Find,Matrix | Hard | 2101,2322 |
152 | hello and welcome today we're doing a question from Le code called a maximum product subray it's a medium we're going to jump right into it given an integer array nums find a subarray that has the largest product and return the product example one we have 2 3 -24 and 23 would example one we have 2 3 -24 and 23 would ex... | 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 |
8 | Hello Hi Guys Welcome Back To The Video In Today's Video Will Be Looking At Another Question No Strings Winters And Into A Question That Is Implemented By Which Converts 2000 Function First Discards I Added White Space Character Accessory For Not Want Peace Character Is Mom Dad Starting From This Character Taken After ... | String to Integer (atoi) | string-to-integer-atoi | Implement the `myAtoi(string s)` function, which converts a string to a 32-bit signed integer (similar to C/C++'s `atoi` function).
The algorithm for `myAtoi(string s)` is as follows:
1. Read in and ignore any leading whitespace.
2. Check if the next character (if not already at the end of the string) is `'-'` or `... | null | String | Medium | 7,65,2168 |
334 | hey everyone uh so today we'll be dealing with this problem it's a very good problem increasing crypto subsequence basically in this problem we have to find three elements the third element should be greater than the second element and the second element should be strictly greater than the first element so uh that is o... | Increasing Triplet Subsequence | increasing-triplet-subsequence | Given an integer array `nums`, return `true` _if there exists a triple of indices_ `(i, j, k)` _such that_ `i < j < k` _and_ `nums[i] < nums[j] < nums[k]`. If no such indices exists, return `false`.
**Example 1:**
**Input:** nums = \[1,2,3,4,5\]
**Output:** true
**Explanation:** Any triplet where i < j < k is valid.
... | null | Array,Greedy | Medium | 300,2122,2280 |
876 | okay welcome back to argojs today's question is going to be the code 876 middle of linked list so given the head of the singly linked list return the middle node of the linked list if there are two middle nodes return the second middle node so pretty straightforward question it's just asking for us to return the middle... | Middle of the Linked List | hand-of-straights | Given the `head` of a singly linked list, return _the middle node of the linked list_.
If there are two middle nodes, return **the second middle** node.
**Example 1:**
**Input:** head = \[1,2,3,4,5\]
**Output:** \[3,4,5\]
**Explanation:** The middle node of the list is node 3.
**Example 2:**
**Input:** head = \[1,... | null | Array,Hash Table,Greedy,Sorting | Medium | null |
1,686 | hey everybody this is larry this is me going over uh lead code contest by weekly 41 q3 stone game six so this is a tricky problem so hit the like button to subscribe and join me in discord before i forget um but the cool part about this is going to be greedy um kind of so i think the thing that i've read from people so... | Stone Game VI | fix-product-name-format | Alice and Bob take turns playing a game, with Alice starting first.
There are `n` stones in a pile. On each player's turn, they can **remove** a stone from the pile and receive points based on the stone's value. Alice and Bob may **value the stones differently**.
You are given two integer arrays of length `n`, `alice... | null | Database | Easy | null |
1,283 | hello so continuing on this weekly contest 166 the third problem which is problem number 100 1283 find the smallest divas are given a threshold so the problem says we get an array of integers and numbers nums and then integer threshold and we will choose a positive integer divisor and divide all the array by that divis... | Find the Smallest Divisor Given a Threshold | reformat-date | Given an array of integers `nums` and an integer `threshold`, we will choose a positive integer `divisor`, divide all the array by it, and sum the division's result. Find the **smallest** `divisor` such that the result mentioned above is less than or equal to `threshold`.
Each result of the division is rounded to the ... | Handle the conversions of day, month and year separately. Notice that days always have a two-word ending, so if you erase the last two characters of this days you'll get the number. | String | Easy | null |
1,535 | hello hi guys good morning welcome back to the new video as you can see the background is changed I am at my home um so that's reason my video is coming a bit late but yeah no worries uh so basically this question we have uh 1535 find the winner of an AR game it has been asked by spinny and reti now the problem stateme... | Find the Winner of an Array Game | build-array-where-you-can-find-the-maximum-exactly-k-comparisons | Given an integer array `arr` of **distinct** integers and an integer `k`.
A game will be played between the first two elements of the array (i.e. `arr[0]` and `arr[1]`). In each round of the game, we compare `arr[0]` with `arr[1]`, the larger integer wins and remains at position `0`, and the smaller integer moves to t... | Use dynamic programming approach. Build dp table where dp[a][b][c] is the number of ways you can start building the array starting from index a where the search_cost = c and the maximum used integer was b. Recursively, solve the small sub-problems first. Optimize your answer by stopping the search if you exceeded k cha... | Dynamic Programming | Hard | null |
718 | hello everyone welcome to cse land i am nishanth let's solve the another lead code problem maximum length of repeated sub body we have to find the length of repeated survey like here one two three and in that three to one okay here three two one is there okay and here three to one is there so length is three this will ... | Maximum Length of Repeated Subarray | maximum-length-of-repeated-subarray | Given two integer arrays `nums1` and `nums2`, return _the maximum length of a subarray that appears in **both** arrays_.
**Example 1:**
**Input:** nums1 = \[1,2,3,2,1\], nums2 = \[3,2,1,4,7\]
**Output:** 3
**Explanation:** The repeated subarray with maximum length is \[3,2,1\].
**Example 2:**
**Input:** nums1 = \[0... | Use dynamic programming. dp[i][j] will be the answer for inputs A[i:], B[j:]. | Array,Binary Search,Dynamic Programming,Sliding Window,Rolling Hash,Hash Function | Medium | 209,2051 |
1,004 | welcome guys let's solve maximum consecutive ones version three given a binary ARs and an integer K written the maximum number of consecutive ones in the ARA if you can flip at most K zeros so let's have the first example as you can see in the first example so the first example the number of um varos we can flip is goi... | 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 |
166 | given to two integers representing the numerator denominator fraction return the fraction in a string format if the fraction part is repeating and close the repeating part in parenthesis okay you have the numerator and denominator and you basically divide it and if you have uh like a repeating decimal you have to put t... | Fraction to Recurring Decimal | fraction-to-recurring-decimal | Given two integers representing the `numerator` and `denominator` of a fraction, return _the fraction in string format_.
If the fractional part is repeating, enclose the repeating part in parentheses.
If multiple answers are possible, return **any of them**.
It is **guaranteed** that the length of the answer string ... | No scary math, just apply elementary math knowledge. Still remember how to perform a long division? Try a long division on 4/9, the repeating part is obvious. Now try 4/333. Do you see a pattern? Notice that once the remainder starts repeating, so does the divided result. Be wary of edge cases! List out as many test ca... | Hash Table,Math,String | Medium | null |
1,329 | hello guys welcome to algorithms made easy today we will be discussing the question sort the matrix diagonally in this question we are given a matrix of m cross and size and we need to sort each matrix diagram in ascending order and return the resulting matrix as given in the first example we can see that we need to so... | Sort the Matrix Diagonally | minimum-cost-to-move-chips-to-the-same-position | A **matrix diagonal** is a diagonal line of cells starting from some cell in either the topmost row or leftmost column and going in the bottom-right direction until reaching the matrix's end. For example, the **matrix diagonal** starting from `mat[2][0]`, where `mat` is a `6 x 3` matrix, includes cells `mat[2][0]`, `ma... | The first move keeps the parity of the element as it is. The second move changes the parity of the element. Since the first move is free, if all the numbers have the same parity, the answer would be zero. Find the minimum cost to make all the numbers have the same parity. | Array,Math,Greedy | Easy | 1895 |
1,388 | Do that Anuj, rather the driver reached the hotel. A very classical attempt on mode 121. You must have seen this many times in contests on simple lead. Let's use the name of the question is Pizza Bread 3m Slices. You have a pizza of three slices. Ok buy pizza. Bread slice of wearing size different size An you and your ... | Pizza With 3n Slices | greatest-sum-divisible-by-three | There is a pizza with `3n` slices of varying size, you and your friends will take slices of pizza as follows:
* You will pick **any** pizza slice.
* Your friend Alice will pick the next slice in the anti-clockwise direction of your pick.
* Your friend Bob will pick the next slice in the clockwise direction of yo... | Represent the state as DP[pos][mod]: maximum possible sum starting in the position "pos" in the array where the current sum modulo 3 is equal to mod. | Array,Dynamic Programming,Greedy | Medium | null |
141 | So the name of the question is Link List Cycle. You will find this question in the lead code 141. So let's look at the problem statement. You have a link list and in this you have to tell whether it is a cycle or not. This is the example I have taken. In this, first of all we We are on the head which is van, from here ... | Linked List Cycle | linked-list-cycle | Given `head`, the head of a linked list, determine if the linked list has a cycle in it.
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 tail's `next` pointer is co... | null | Hash Table,Linked List,Two Pointers | Easy | 142,202 |
876 | Hello friends welcome back today I'm going to solve liquid problem number 876 middle of the linked list this is a so what are we given is we are given a single linked list of length n so it could be of an odd length or an even length and we need to find out the middle of the linked list so for an odd length it's obviou... | Middle of the Linked List | hand-of-straights | Given the `head` of a singly linked list, return _the middle node of the linked list_.
If there are two middle nodes, return **the second middle** node.
**Example 1:**
**Input:** head = \[1,2,3,4,5\]
**Output:** \[3,4,5\]
**Explanation:** The middle node of the list is node 3.
**Example 2:**
**Input:** head = \[1,... | null | Array,Hash Table,Greedy,Sorting | Medium | null |
1,705 | hey what's up guys this is sean here again so let's take a look at uh this one uh 1705 maximum number of eaten apples so i'm going gonna give it my own upvote so you're giving like a special apple tree that grows apples every day for end days okay and on the ice day the tree grows apples ice number of apples that will ... | Maximum Number of Eaten Apples | count-unhappy-friends | There is a special kind of apple tree that grows apples every day for `n` days. On the `ith` day, the tree grows `apples[i]` apples that will rot after `days[i]` days, that is on day `i + days[i]` the apples will be rotten and cannot be eaten. On some days, the apple tree does not grow any apples, which are denoted by ... | Create a matrix “rank” where rank[i][j] holds how highly friend ‘i' views ‘j’. This allows for O(1) comparisons between people | Array,Simulation | Medium | null |
547 | hey everybody this is Larry this is day four of the June liquor day challenge hit the like button hit the Subscribe button join me on Discord let me know what you think about today's form 547 number of provinces I'm still here in Irvine um in Romania I think a couple of days off from hiking because uh kind of my back i... | Number of Provinces | number-of-provinces | There are `n` cities. Some of them are connected, while some are not. If city `a` is connected directly with city `b`, and city `b` is connected directly with city `c`, then city `a` is connected indirectly with city `c`.
A **province** is a group of directly or indirectly connected cities and no other cities outside ... | null | Depth-First Search,Breadth-First Search,Union Find,Graph | Medium | 323,657,734,737,1085,2206 |
235 | hello everyone welcome to learn overflow in this video we will discuss about today's later problem that is the lowest covered ancestor of a binary search tree this is a easy level problem and we'll understand what this question is asking us to do and how we can actually solve a question like this so this is easy level ... | 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 |
150 | hey guys welcome or welcome back to my channel so today we are going to discuss another problem is evaluate reverse polish notation so in this problem we'll be given an arithmetic expression in Reverse polish notation so if you do not know what reverse policy notation is I would highly recommend just go through this ar... | Evaluate Reverse Polish Notation | evaluate-reverse-polish-notation | You are given an array of strings `tokens` that represents an arithmetic expression in a [Reverse Polish Notation](http://en.wikipedia.org/wiki/Reverse_Polish_notation).
Evaluate the expression. Return _an integer that represents the value of the expression_.
**Note** that:
* The valid operators are `'+'`, `'-'`, ... | null | Array,Math,Stack | Medium | 224,282 |
148 | so today we're doing this problem called sort list and the problem is that we get a soul we have to sort a linking list in our plugin time and using constant space complexity and this is the linkedlist and so we're gonna sort it so something like this and like this so it was not sorted and we need to sort of like this ... | 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 |
1,022 | hi i am ayoshi rawat and welcome to my channel today we will discuss the september lead code challenge day 8 problem sum of root to leave binary numbers let's have a look at the problem statement now given a binary tree each node has value 0 or 1. each root to leave path represents a binary number starting with the mos... | Sum of Root To Leaf Binary Numbers | unique-paths-iii | You are given the `root` of a binary tree where each node has a value `0` or `1`. Each root-to-leaf path represents a binary number starting with the most significant bit.
* For example, if the path is `0 -> 1 -> 1 -> 0 -> 1`, then this could represent `01101` in binary, which is `13`.
For all leaves in the tree, c... | null | Array,Backtracking,Bit Manipulation,Matrix | Hard | 37,63,212 |
518 | Hello everyone, today we are going to do question number 518 of the network, whose name is coin change, this question can be asked many times in the interview and its approach is absolutely standard, although it is a medium mark, but its problem statement is very standard. Yes, representing coins of different denominat... | 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 |
304 | hello everyone welcome to our channel code with sunny and in this video i am going to talk about the problem rain some query 2d and it is immutable and the problem index is 304 and the problem is of one of the medium type problem of the lead code okay so given a 2d matrix that is going to handle multiple queries of the... | 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 |
645 | hi everyone so today we'll be doing this problem called uh said mismatch so you're you have a set of number a set of integers which originally contains all the numbers from one to n unfortunately due to some error one of the numbers in s got duplicated to another number in the set which results in the repetition of one... | Set Mismatch | set-mismatch | You have a set of integers `s`, which originally contains all the numbers from `1` to `n`. Unfortunately, due to some error, one of the numbers in `s` got duplicated to another number in the set, which results in **repetition of one** number and **loss of another** number.
You are given an integer array `nums` represe... | null | Array,Hash Table,Bit Manipulation,Sorting | Easy | 287 |
417 | um hello so today we are going to do this problem called pacific atlantic water flow um so part of um lead code august dairy challenge so we have an m by n rectangular island um that borders the pacific ocean from the top and the left side and borders the atlantic ocean from the right and the bottom side right um and w... | Pacific Atlantic Water Flow | pacific-atlantic-water-flow | There is an `m x n` rectangular island that borders both the **Pacific Ocean** and **Atlantic Ocean**. The **Pacific Ocean** touches the island's left and top edges, and the **Atlantic Ocean** touches the island's right and bottom edges.
The island is partitioned into a grid of square cells. You are given an `m x n` i... | null | Array,Depth-First Search,Breadth-First Search,Matrix | Medium | null |
1,266 | hello guys and welcome back to lead Logics this is the minimum time visiting All Points problem it is a lead code easy and the number for this is 1266 uh so in this problem we are given a 2d plane and there are n points with integer coordinates given by points of I so points is actually a 2d array and every Row in poin... | Minimum Time Visiting All Points | minimum-time-visiting-all-points | On a 2D plane, there are `n` points with integer coordinates `points[i] = [xi, yi]`. Return _the **minimum time** in seconds to visit all the points in the order given by_ `points`.
You can move according to these rules:
* In `1` second, you can either:
* move vertically by one unit,
* move horizontally... | null | null | Easy | null |
1,928 | is so minimum cost to reach a destination in time question so we are given Ages which is a graph and we also have the maximum time we want to go from The Source node to the destination node and we must fulfill that the total time used should be less or equal the maximum time and then we wish to know what would be the l... | Minimum Cost to Reach Destination in Time | number-of-orders-in-the-backlog | There is a country of `n` cities numbered from `0` to `n - 1` where **all the cities are connected** by bi-directional roads. The roads are represented as a 2D integer array `edges` where `edges[i] = [xi, yi, timei]` denotes a road between cities `xi` and `yi` that takes `timei` minutes to travel. There may be multiple... | Store the backlog buy and sell orders in two heaps, the buy orders in a max heap by price and the sell orders in a min heap by price. Store the orders in batches and update the fields according to new incoming orders. Each batch should only take 1 "slot" in the heap. | Array,Heap (Priority Queue),Simulation | Medium | null |
409 | so given a string which consists of Upper and upper and lowercase like this so return the length of the longest palindrome that can be built with those letters and the letters are case sensitive for example a cannot be considered as a palindrome here so what is the parental number Palatine number or palindrome string i... | 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 |
165 | hello everyone hope you all are doing well so i am back with another daily challenge and it is late number of 165 compare version numbers it is a medium level question and i also fill the cell however you can see that the ratio of the light and the dislike is very poor more people don't like the question however i am a... | Compare Version Numbers | compare-version-numbers | Given two version numbers, `version1` and `version2`, compare them.
Version numbers consist of **one or more revisions** joined by a dot `'.'`. Each revision consists of **digits** and may contain leading **zeros**. Every revision contains **at least one character**. Revisions are **0-indexed from left to right**, wit... | null | Two Pointers,String | Medium | null |
1,183 | everyone with Calvin here so let's accessible beauty contests eight for question so we have a matrix of size win with time sake and then every cells inside have either value of 0 or 1 and any square sub-matrix of the of their any square sub-matrix of the of their any square sub-matrix of the of their matrix with size o... | Maximum Number of Ones | statistics-from-a-large-sample | Consider a matrix `M` with dimensions `width * height`, such that every cell has value `0` or `1`, and any **square** sub-matrix of `M` of size `sideLength * sideLength` has at most `maxOnes` ones.
Return the maximum possible number of ones that the matrix `M` can have.
**Example 1:**
**Input:** width = 3, height = ... | The hard part is the median. Write a helper function which finds the k-th element from the sample. | Math,Two Pointers,Probability and Statistics | Medium | null |
1,095 | Hey guys welcome and welcome back to my knowledge today's problem is find in mountain array it is a very interesting problem and there is a concept in it which will be good for your revision so first let's see what is the problem ok so the problem is that you are given in Array and it is a mountain array if and only if... | Find in Mountain Array | two-city-scheduling | _(This problem is an **interactive problem**.)_
You may recall that an array `arr` is a **mountain array** if and only if:
* `arr.length >= 3`
* There exists some `i` with `0 < i < arr.length - 1` such that:
* `arr[0] < arr[1] < ... < arr[i - 1] < arr[i]`
* `arr[i] > arr[i + 1] > ... > arr[arr.length ... | null | Array,Greedy,Sorting | Medium | null |
1,763 | and I don't really know what comes next I'm just doing my best even though I'm so stressed out everything just feels like a test that I feel so depressed when I can't seem to get up with something deep inside won't let me quit I swearing that's what God inspired by thirst I'm inspired by worth I desire your worst so yo... | Longest Nice Substring | all-valid-triplets-that-can-represent-a-country | A string `s` is **nice** if, for every letter of the alphabet that `s` contains, it appears **both** in uppercase and lowercase. For example, `"abABB "` is nice because `'A'` and `'a'` appear, and `'B'` and `'b'` appear. However, `"abA "` is not because `'b'` appears, but `'B'` does not.
Given a string `s`, return _th... | null | Database | Easy | null |
1,678 | hey everybody this is larry this is me going over q1 of the week the contest 2218's first forum q1 uh hit the like button to subscribe on drummond discord and you can watch me solve it live during the contest afterwards um but go faster interpretation so i think this is pretty straightforward in the sense that you just... | Goal Parser Interpretation | number-of-ways-to-split-a-string | You own a **Goal Parser** that can interpret a string `command`. The `command` consists of an alphabet of `"G "`, `"() "` and/or `"(al) "` in some order. The Goal Parser will interpret `"G "` as the string `"G "`, `"() "` as the string `"o "`, and `"(al) "` as the string `"al "`. The interpreted strings are then concat... | There is no way if the sum (number of '1's) is not divisible by the number of splits. So sum%3 should be 0. Preffix s1 , and suffix s3 should have sum/3 characters '1'. Follow up: Can you generalize the problem with numbers between [-10^9, 10^9] such the sum between subarrays s1, s2, s3 are the same? | Math,String | Medium | 548 |
475 | hey everyone um welcome to the channel in this video we are going to discuss about the lead code problem called heaters in this problem we are given houses array as well as heaters right so what uh basically we have to find is uh by this array heaters we know that uh at the second position right if we take this as an e... | Heaters | heaters | Winter is coming! During the contest, your first job is to design a standard heater with a fixed warm radius to warm all the houses.
Every house can be warmed, as long as the house is within the heater's warm radius range.
Given the positions of `houses` and `heaters` on a horizontal line, return _the minimum radius ... | null | Array,Two Pointers,Binary Search,Sorting | Medium | null |
1,970 | Hello everyone welcome to my channel my page is available with the name liquid 1970 hard mark to hai but it is going to be very easy very simple bfs and dfs bill help you solve this question ok there is just a small catch that too we understand Lange last where you can style cross question name is this it has been aske... | Last Day Where You Can Still Cross | sorting-the-sentence | There is a **1-based** binary matrix where `0` represents land and `1` represents water. You are given integers `row` and `col` representing the number of rows and columns in the matrix, respectively.
Initially on day `0`, the **entire** matrix is **land**. However, each day a new cell becomes flooded with **water**. ... | Divide the string into the words as an array of strings Sort the words by removing the last character from each word and sorting according to it | String,Sorting | Easy | 2168 |
1,169 | Hey guys, welcome back to the lead code series, this is Manish Sharif, today we are going to do question number 1169 and our question is invalid transactions, it is a very complicated question, it is a medium level problem, it was fun to do this question because here in oops. You will get to see many concepts together ... | Invalid Transactions | largest-values-from-labels | A transaction is possibly invalid if:
* the amount exceeds `$1000`, or;
* if it occurs within (and including) `60` minutes of another transaction with the **same name** in a **different city**.
You are given an array of strings `transaction` where `transactions[i]` consists of comma-separated values representing ... | Consider the items in order from largest to smallest value, and greedily take the items if they fall under the use_limit. We can keep track of how many items of each label are used by using a hash table. | Array,Hash Table,Greedy,Sorting,Counting | Medium | null |
121 | hey everyone welcome back to take you forward so we completed one ddp dp on grids dp on subsequences and dp on strings so it's sty it's so it's time to start dp on stocks yes and there are generically uh six problem stocks uh is that the spelling yeah that's suspending so we have six problems and in any of the intervie... | Best Time to Buy and Sell Stock | best-time-to-buy-and-sell-stock | You are given an array `prices` where `prices[i]` is the price of a given stock on the `ith` day.
You want to maximize your profit by choosing a **single day** to buy one stock and choosing a **different day in the future** to sell that stock.
Return _the maximum profit you can achieve from this transaction_. If you ... | null | Array,Dynamic Programming | Easy | 53,122,123,188,309,2138,2144 |
1,834 | hey everyone welcome back and let's write some more neat code today so today let's solve single threaded cpu this problem actually just came out today and it's a pretty good one i just solved it so we are given n tasks labeled from zero to n minus one and each one of these tasks has two fields or two values one is the ... | Single-Threaded CPU | minimum-number-of-people-to-teach | You are given `n` tasks labeled from `0` to `n - 1` represented by a 2D integer array `tasks`, where `tasks[i] = [enqueueTimei, processingTimei]` means that the `ith` task will be available to process at `enqueueTimei` and will take `processingTimei` to finish processing.
You have a single-threaded CPU... | You can just use brute force and find out for each language the number of users you need to teach Note that a user can appear in multiple friendships but you need to teach that user only once | Array,Greedy | Medium | null |
105 | Hello everyone welcome, you have to make me a channel, I have given you these orders and post orders, okay Google asked this question, there is another question similar to this, lead code number is 105, I have made its video, already watch it in my playlist in the penalty playlist. If you feel like watching it, then wa... | Construct Binary Tree from Preorder and Inorder Traversal | construct-binary-tree-from-preorder-and-inorder-traversal | Given two integer arrays `preorder` and `inorder` where `preorder` is the preorder traversal of a binary tree and `inorder` is the inorder traversal of the same tree, construct and return _the binary tree_.
**Example 1:**
**Input:** preorder = \[3,9,20,15,7\], inorder = \[9,3,15,20,7\]
**Output:** \[3,9,20,null,null,... | null | Array,Hash Table,Divide and Conquer,Tree,Binary Tree | Medium | 106 |
523 | hello and welcome back to another Elite code problem today we're going to be doing problem continuous separate sum and it's definitely an interesting problem and it's quite tricky to solve so we're going to go over it so given an injury nums and an integer okay return true if nums has a good sub rate or false otherwise... | Continuous Subarray Sum | continuous-subarray-sum | Given an integer array nums and an integer k, return `true` _if_ `nums` _has a **good subarray** or_ `false` _otherwise_.
A **good subarray** is a subarray where:
* its length is **at least two**, and
* the sum of the elements of the subarray is a multiple of `k`.
**Note** that:
* A **subarray** is a contiguo... | null | Array,Hash Table,Math,Prefix Sum | Medium | 560,2119,2240 |
35 | hey guys in this video we shout out another problem search inside position the given a sorted array of distinct integers and a Target value return the number written the index if the target is found if not written the index where it would be if it were inserted in order so they have given an array which is solid in sor... | Search Insert Position | search-insert-position | Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.
You must write an algorithm with `O(log n)` runtime complexity.
**Example 1:**
**Input:** nums = \[1,3,5,6\], target = 5
**Output:** 2
**Exa... | null | Array,Binary Search | Easy | 278 |
1,970 | welcome to Pomodoro Joe for Friday June 30th 2023 today we're doing lead code problem 1970. last day where you can still cross this is a hard problem so there's a one-based interesting this so there's a one-based interesting this so there's a one-based interesting this is one based there's a one-based binary is one bas... | Last Day Where You Can Still Cross | sorting-the-sentence | There is a **1-based** binary matrix where `0` represents land and `1` represents water. You are given integers `row` and `col` representing the number of rows and columns in the matrix, respectively.
Initially on day `0`, the **entire** matrix is **land**. However, each day a new cell becomes flooded with **water**. ... | Divide the string into the words as an array of strings Sort the words by removing the last character from each word and sorting according to it | String,Sorting | Easy | 2168 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.