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 |
|---|---|---|---|---|---|---|---|---|
202 | hi everyone so let's solve another easy lead code question which is happy number so we have to write an algorithm and if uh determine if a number n is happy or not a happy number is number defined by following process starting with any positive integer replace the number by the sum of squares of its digits repeat the p... | 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 |
530 | hi guys welcome to algorithms Made Easy my name is kushboo and in this video we are going to see the question minimum absolute difference in a BST given the route of binary search tree return the minimum absolute difference between the values of any two different nodes in the tree so here is an example given to us and ... | Minimum Absolute Difference in BST | minimum-absolute-difference-in-bst | Given the `root` of a Binary Search Tree (BST), return _the minimum absolute difference between the values of any two different nodes in the tree_.
**Example 1:**
**Input:** root = \[4,2,6,1,3\]
**Output:** 1
**Example 2:**
**Input:** root = \[1,0,48,null,null,12,49\]
**Output:** 1
**Constraints:**
* The number... | null | Tree,Depth-First Search,Breadth-First Search,Binary Search Tree,Binary Tree | Easy | 532 |
1,861 | hello friends welcome to coding interviews channel hope you are doing great if you haven't subscribed to my channel yet please go ahead and subscribe let's jump into today's problem rotating the box you are given an embankment matrix of characters blocks representing a side view of a box each cell of the box is one of ... | Rotating the Box | building-boxes | You are given an `m x n` matrix of characters `box` representing a side-view of a box. Each cell of the box is one of the following:
* A stone `'#'`
* A stationary obstacle `'*'`
* Empty `'.'`
The box is rotated **90 degrees clockwise**, causing some of the stones to fall due to gravity. Each stone falls down u... | Suppose We can put m boxes on the floor, within all the ways to put the boxes, what’s the maximum number of boxes we can put in? The first box should always start in the corner | Math,Binary Search,Greedy | Hard | null |
994 | hey what's up guys jung here again and today uh i want to talk about this lead code problem number 994 rotting oranges medium problem it's very i think it's a it's an interesting problem okay you're given like a 2d grade and on each grade there will be only three options here either zero one or two where zero represent... | Rotting Oranges | prison-cells-after-n-days | You are given an `m x n` `grid` where each cell can have one of three values:
* `0` representing an empty cell,
* `1` representing a fresh orange, or
* `2` representing a rotten orange.
Every minute, any fresh orange that is **4-directionally adjacent** to a rotten orange becomes rotten.
Return _the minimum nu... | null | Array,Hash Table,Math,Bit Manipulation | Medium | null |
1,598 | today we will be discussing problem number 1598 of lead code it was a part of weekly contest 208 uh and it says you can easily guess out the approach by while seeing that the pictorial description so here the input will be logs something like this so from the main we are going to the d1 folder and from the d1 we are go... | Crawler Log Folder | crawler-log-folder | The Leetcode file system keeps a log each time some user performs a _change folder_ operation.
The operations are described below:
* `"../ "` : Move to the parent folder of the current folder. (If you are already in the main folder, **remain in the same folder**).
* `"./ "` : Remain in the same folder.
* `"x/ "... | null | null | Easy | null |
1,561 | hello hi guysi I hope that you guys are doing good in this video maximum number of coins you can get it has been asked by clear tip flip cart danzo and last one two years you can see the timings let's see uh again it's a marked as the medium problem but it's a very easy problem so let's see the problem statement itself... | Maximum Number of Coins You Can Get | rearrange-words-in-a-sentence | There are `3n` piles of coins of varying size, you and your friends will take piles of coins as follows:
* In each step, you will choose **any** `3` piles of coins (not necessarily consecutive).
* Of your choice, Alice will pick the pile with the maximum number of coins.
* You will pick the next pile with the ma... | Store each word and their relative position. Then, sort them by length of words in case of tie by their original order. | String,Sorting | Medium | null |
1,959 | hey everybody this is larry this is me going with bi-weekly contest 58 me going with bi-weekly contest 58 me going with bi-weekly contest 58 problem three minimum total space wasted with k resizing operations hit the like button hit the subscribe button join me on discord gives me some love give me some support um but ... | Minimum Total Space Wasted With K Resizing Operations | minimum-path-cost-in-a-hidden-grid | You are currently designing a dynamic array. You are given a **0-indexed** integer array `nums`, where `nums[i]` is the number of elements that will be in the array at time `i`. In addition, you are given an integer `k`, the **maximum** number of times you can **resize** the array (to **any** size).
The size of the ar... | The grid is at a maximum 100 x 100, so it is clever to assume that the robot's initial cell is grid[101][101] Run a DFS from the robot's position to make sure that you can reach the target, otherwise you should return -1. Now that you are sure you can reach the target and that you know the grid, run Dijkstra to find th... | Depth-First Search,Breadth-First Search,Graph,Heap (Priority Queue),Interactive | Medium | 865,1931 |
1,984 | hi so this question is minimum difference between the highs and lows of case score so we are given in Array and a k so the case uh representing the one uh case student from the array so that the difference between the highest and lowers of the case score is minimized right so return the minimum right so this question i... | Minimum Difference Between Highest and Lowest of K Scores | maximum-distance-between-a-pair-of-values | You are given a **0-indexed** integer array `nums`, where `nums[i]` represents the score of the `ith` student. You are also given an integer `k`.
Pick the scores of any `k` students from the array so that the **difference** between the **highest** and the **lowest** of the `k` scores is **minimized**.
Return _the **m... | Since both arrays are sorted in a non-increasing way this means that for each value in the first array. We can find the farthest value smaller than it using binary search. There is another solution using a two pointers approach since the first array is non-increasing the farthest j such that nums2[j] ≥ nums1[i] is at l... | Array,Two Pointers,Binary Search,Greedy | Medium | 2199 |
1,958 | so hello everyone in this youtube video that i'm going to show uh in which i'm going to show you how the method that i proposed to solve this problem which is entitled check if move is legal uh it's a ledge code problem that's a that was on the 1858 uh by bi-weekly by wikileaks by bi-weekly by wikileaks by bi-weekly by... | Check if Move is Legal | ad-free-sessions | You are given a **0-indexed** `8 x 8` grid `board`, where `board[r][c]` represents the cell `(r, c)` on a game board. On the board, free cells are represented by `'.'`, white cells are represented by `'W'`, and black cells are represented by `'B'`.
Each move in this game consists of choosing a free cell and changing i... | null | Database | Easy | null |
1,455 | hey everybody this is Larry I'm doing this problem as part of a contest so you're gonna watch me live as I go through my darts I'm coding they've been explanation near the end and for more context they'll be a link below on this actual screen cats of the contest how did you do let me know you do hit the like button eit... | Check If a Word Occurs As a Prefix of Any Word in a Sentence | filter-restaurants-by-vegan-friendly-price-and-distance | Given a `sentence` that consists of some words separated by a **single space**, and a `searchWord`, check if `searchWord` is a prefix of any word in `sentence`.
Return _the index of the word in_ `sentence` _(**1-indexed**) where_ `searchWord` _is a prefix of this word_. If `searchWord` is a prefix of more than one wor... | Do the filtering and sort as said. Note that the id may not be the index in the array. | Array,Sorting | Medium | null |
895 | welcome to february's leco challenge today's problem the last problem of the month is maximum frequency stack finally finished another month so the question is implement frequency stack a class which simulates the operation of a stack-like the operation of a stack-like the operation of a stack-like data structure frequ... | Maximum Frequency Stack | shortest-path-to-get-all-keys | Design a stack-like data structure to push elements to the stack and pop the most frequent element from the stack.
Implement the `FreqStack` class:
* `FreqStack()` constructs an empty frequency stack.
* `void push(int val)` pushes an integer `val` onto the top of the stack.
* `int pop()` removes and returns the... | null | Bit Manipulation,Breadth-First Search | Hard | null |
89 | hey everybody this is larry this is the first of july uh happy july uh if you're new to this channel hit the like button in the subscriber and join me on discord we usually solve every problem live and hopefully get the streak going this is my i don't know 12 13 i don't know 15 months straight or something like that yo... | Gray Code | gray-code | An **n-bit gray code sequence** is a sequence of `2n` integers where:
* Every integer is in the **inclusive** range `[0, 2n - 1]`,
* The first integer is `0`,
* An integer appears **no more than once** in the sequence,
* The binary representation of every pair of **adjacent** integers differs by **exactly one ... | null | Math,Backtracking,Bit Manipulation | Medium | 717 |
1,424 | Hello friends, today we will watch the video of C Plus Medical Entrance Form, that is your left question, here first of all we have to see the matter that we have to do in the program, then you understand this matter, this is your matriculation, what we have to print in the matriculation. You have to print sexual ali, ... | Diagonal Traverse II | maximum-candies-you-can-get-from-boxes | Given a 2D integer array `nums`, return _all elements of_ `nums` _in diagonal order as shown in the below images_.
**Example 1:**
**Input:** nums = \[\[1,2,3\],\[4,5,6\],\[7,8,9\]\]
**Output:** \[1,4,2,7,5,3,8,6,9\]
**Example 2:**
**Input:** nums = \[\[1,2,3,4,5\],\[6,7\],\[8\],\[9,10,11\],\[12,13,14,15,16\]\]
**Ou... | Use Breadth First Search (BFS) to traverse all possible boxes you can open. Only push to the queue the boxes the you have with their keys. | Array,Breadth-First Search | Hard | null |
1,345 | hello guys welcome to deep codes and in today's video we will discuss record question 1345 that says Jump game four so here in this video I will discuss multiple approaches to solve this question I will discuss some of the flaws that are present in one or two approaches and I will tell you why one specific approach can... | Jump Game IV | perform-string-shifts | Given an array of integers `arr`, you are initially positioned at the first index of the array.
In one step you can jump from index `i` to index:
* `i + 1` where: `i + 1 < arr.length`.
* `i - 1` where: `i - 1 >= 0`.
* `j` where: `arr[i] == arr[j]` and `i != j`.
Return _the minimum number of steps_ to reach the... | Intuitively performing all shift operations is acceptable due to the constraints. You may notice that left shift cancels the right shift, so count the total left shift times (may be negative if the final result is right shift), and perform it once. | Array,Math,String | Easy | null |
109 | hello friends in this video we will see how to uh convert a sorted linked list to a balanced mind research tree so balance binary search tree is a binary search tree so it maintains the search property and also the difference between the depth of left and right subtrees so if there is a node here and we have a sub tree... | Convert Sorted List to Binary Search Tree | convert-sorted-list-to-binary-search-tree | Given the `head` of a singly linked list where elements are sorted in **ascending order**, convert _it to a_ **_height-balanced_** _binary search tree_.
**Example 1:**
**Input:** head = \[-10,-3,0,5,9\]
**Output:** \[0,-3,9,-10,null,5\]
**Explanation:** One possible answer is \[0,-3,9,-10,null,5\], which represents t... | null | Linked List,Divide and Conquer,Tree,Binary Search Tree,Binary Tree | Medium | 108,2306 |
525 | Hello everyone welcome to my YouTube channel in which equal number of van and like our example of zero and van is present because account of both zero and van is not van then its length we will return the maximum length now in the output which is You are the same example, you will come, just like our example is 11010, ... | Contiguous Array | contiguous-array | Given a binary array `nums`, return _the maximum length of a contiguous subarray with an equal number of_ `0` _and_ `1`.
**Example 1:**
**Input:** nums = \[0,1\]
**Output:** 2
**Explanation:** \[0, 1\] is the longest contiguous subarray with an equal number of 0 and 1.
**Example 2:**
**Input:** nums = \[0,1,0\]
**O... | null | Array,Hash Table,Prefix Sum | Medium | 325 |
1,354 | Hello Guys Welcome Gautam Sameer And Subscribe More Than 150 Thursdays Subscribe And subscribe The One Office Meeting Changes Electronic Meeting Changes Electronic Meeting Changes Electronic That Let's Understand What Problem With About How They Can Solve Staff Band Security Subscribe All Will Not Find The Total Subscr... | Construct Target Array With Multiple Sums | find-players-with-zero-or-one-losses | You are given an array `target` of n integers. From a starting array `arr` consisting of `n` 1's, you may perform the following procedure :
* let `x` be the sum of all elements currently in your array.
* choose index `i`, such that `0 <= i < n` and set the value of `arr` at index `i` to `x`.
* You may repeat thi... | Count the number of times a player loses while iterating through the matches. | Array,Hash Table,Sorting,Counting | Medium | 236 |
111 | Hello Hi Everyone Welcome To My Channel Today In This Video Vihar Solving Problems Minimum Death Of Spinal Tree To Binary Tree Very Famous Data Structure And Lots Of Problems In The Married Things Frequently Asked In Interview Secretary Vinod Angry In Detail And As A Result You Very Famous Traversal Entry Difficulty an... | Minimum Depth of Binary Tree | minimum-depth-of-binary-tree | Given a binary tree, find its minimum depth.
The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.
**Note:** A leaf is a node with no children.
**Example 1:**
**Input:** root = \[3,9,20,null,null,15,7\]
**Output:** 2
**Example 2:**
**Input:** root = \[2... | null | Tree,Depth-First Search,Breadth-First Search,Binary Tree | Easy | 102,104 |
374 | hey everyone so let us talk about this lead code problem guest number higher or lower so we are playing the guess game the game is as follows I pick a number from 1 to n you have to guess which number I picked and every time you guess wrong I will tell you whether the number I picked is higher or lower than your guess ... | Guess Number Higher or Lower | guess-number-higher-or-lower | We are playing the Guess Game. The game is as follows:
I pick a number from `1` to `n`. You have to guess which number I picked.
Every time you guess wrong, I will tell you whether the number I picked is higher or lower than your guess.
You call a pre-defined API `int guess(int num)`, which returns three possible re... | null | Binary Search,Interactive | Easy | 278,375,658 |
938 | in this video we will look at a range sum of a binary search tree so let's see the problem statement so we have a binary search tree so all the nodes in the left sub tree of a given node will be less than the current node and all nodes in the right subtree will be larger than the current node so uh here you are given a... | Range Sum of BST | numbers-at-most-n-given-digit-set | Given the `root` node of a binary search tree and two integers `low` and `high`, return _the sum of values of all nodes with a value in the **inclusive** range_ `[low, high]`.
**Example 1:**
**Input:** root = \[10,5,15,3,7,null,18\], low = 7, high = 15
**Output:** 32
**Explanation:** Nodes 7, 10, and 15 are in the ra... | null | Array,Math,Binary Search,Dynamic Programming | Hard | null |
953 | Hello guys welcome to front media manager and will be discussing various points induced in this question Thursday subscribe Indian hidden files appointed subscribe really description and subscribe this Video give and bihar radhe-radhe vidron in english bihar radhe-radhe vidron in english bihar radhe-radhe vidron in eng... | Verifying an Alien Dictionary | reverse-only-letters | In an alien language, surprisingly, they also use English lowercase letters, but possibly in a different `order`. The `order` of the alphabet is some permutation of lowercase letters.
Given a sequence of `words` written in the alien language, and the `order` of the alphabet, return `true` if and only if the given `wor... | This problem is exactly like reversing a normal string except that there are certain characters that we have to simply skip. That should be easy enough to do if you know how to reverse a string using the two-pointer approach. | Two Pointers,String | Easy | null |
436 | hey what's up guys chung here so today let's take a look at this little problem number 436 find right interval okay so you're given like a set of intervals and for each of the interval i check if there exists an interval j whose start point is bigger than or equal to the ice and the end point and for each of the i here... | 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 |
258 | hi folks let's try to do the elite core 258 which seems like a very easy problem to do and i guess it's good for if you're starting out and programming and you just want to do some low hanging fruits and probably practice your favorite language while doing that it sounds like a good idea so here it is it's given a non-... | Add Digits | add-digits | Given an integer `num`, repeatedly add all its digits until the result has only one digit, and return it.
**Example 1:**
**Input:** num = 38
**Output:** 2
**Explanation:** The process is
38 --> 3 + 8 --> 11
11 --> 1 + 1 --> 2
Since 2 has only one digit, return it.
**Example 2:**
**Input:** num = 0
**Output:** 0
*... | A naive implementation of the above process is trivial. Could you come up with other methods? What are all the possible results? How do they occur, periodically or randomly? You may find this Wikipedia article useful. | Math,Simulation,Number Theory | Easy | 202,1082,2076,2264 |
15 | hey everyone today we're doing thre sum and thre sum is a problem that is medium and if you understand what two sum is it should follow what three sum is but I'm going to read the problem statement out and I'm going to say it's given an integer array nums return all the triplets nums I nums J and nums K such that I is ... | 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 |
1,486 | okay let's go over 1486 xor operations in array so question says given an integer n so n is a lumber and integer start and start is also number defined an array gnomes where lumps at index I is equal to start plus two times I and we start at index zero so already Nam's is going to be an array with numbers and n is equa... | XOR Operation in an Array | find-the-distance-value-between-two-arrays | You are given an integer `n` and an integer `start`.
Define an array `nums` where `nums[i] = start + 2 * i` (**0-indexed**) and `n == nums.length`.
Return _the bitwise XOR of all elements of_ `nums`.
**Example 1:**
**Input:** n = 5, start = 0
**Output:** 8
**Explanation:** Array nums is equal to \[0, 2, 4, 6, 8\] w... | Sort 'arr2' and use binary search to get the closest element for each 'arr1[i]', it gives a time complexity of O(nlogn). | Array,Two Pointers,Binary Search,Sorting | Easy | null |
283 | hello guys I hope you are all doing well in this video I will explain and show you how to solve the problem of zero so let's get started so the problem is that they give you an array of integers and they ask you to move all the zeros to the end of it while maintaining the relative order of the non-zero element relative... | Move Zeroes | move-zeroes | Given an integer array `nums`, move all `0`'s to the end of it while maintaining the relative order of the non-zero elements.
**Note** that you must do this in-place without making a copy of the array.
**Example 1:**
**Input:** nums = \[0,1,0,3,12\]
**Output:** \[1,3,12,0,0\]
**Example 2:**
**Input:** nums = \[0\]... | In-place means we should not be allocating any space for extra array. But we are allowed to modify the existing array. However, as a first step, try coming up with a solution that makes use of additional space. For this problem as well, first apply the idea discussed using an additional array and the in-place solution ... | Array,Two Pointers | Easy | 27 |
1,732 | hey guys welcome back to my channel and i'm back again with another really interesting coding interpretation video this time guys we are going to solve question number 1732 find the highest altitude before i start with the problem statement guys if you have not yet subscribed to my channel then please do subscribe and ... | Find the Highest Altitude | minimum-one-bit-operations-to-make-integers-zero | There is a biker going on a road trip. The road trip consists of `n + 1` points at different altitudes. The biker starts his trip on point `0` with altitude equal `0`.
You are given an integer array `gain` of length `n` where `gain[i]` is the **net gain in altitude** between points `i` and `i + 1` for all (`0 <=... | The fastest way to convert n to zero is to remove all set bits starting from the leftmost one. Try some simple examples to learn the rule of how many steps are needed to remove one set bit. consider n=2^k case first, then solve for all n. | Dynamic Programming,Bit Manipulation,Memoization | Hard | 2119 |
494 | hello everyone welcome to clean coder youtube channel so today we are going to solve this uh lead code problem number 494 which is target sum it's a medium level liquid problem so let's go through the problem statement quickly uh this problem says you are given an integer error in nums and an integer target you want to... | Target Sum | target-sum | You are given an integer array `nums` and an integer `target`.
You want to build an **expression** out of nums by adding one of the symbols `'+'` and `'-'` before each integer in nums and then concatenate all the integers.
* For example, if `nums = [2, 1]`, you can add a `'+'` before `2` and a `'-'` before `1` and ... | null | Array,Dynamic Programming,Backtracking | Medium | 282 |
283 | hi everyone today we are going to solve the little question move zeros so you are given integer array numbers and move all 0 to the end of array while maintaining the relative order of the nonzero elements so let's see the example so you are given 0 1 0 3 12 and the output should be 1 3 12 0 so we need to move all 0 to... | 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 |
334 | Co whatsapp ka dubai apna talking about were elite problem ne and increasing classical okay and medium it kar koi problem hai account spoke very interesting hai via statement piece given interior alarms return to exit from up in this is jain with good spots pimple As per K A Viruddh R Also In The Interim Order Book On ... | 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 |
138 | hello friends welcome to joy of life so today we are going to look at another medium level problem from leadput the problem number is 138. the name of the problem is copy list with random pointer so it has a quite a long description so let's check it a link list of length n is given such that each node contains an addi... | Copy List with Random Pointer | copy-list-with-random-pointer | A linked list of length `n` is given such that each node contains an additional random pointer, which could point to any node in the list, or `null`.
Construct a [**deep copy**](https://en.wikipedia.org/wiki/Object_copying#Deep_copy) of the list. The deep copy should consist of exactly `n` **brand new** nodes, where e... | Just iterate the linked list and create copies of the nodes on the go. Since a node can be referenced from multiple nodes due to the random pointers, make sure you are not making multiple copies of the same node. You may want to use extra space to keep old node ---> new node mapping to prevent creating multiples copies... | Hash Table,Linked List | Medium | 133,1624,1634 |
921 | hello and welcome back to the cracking fang youtube channel today we're going to be solving lead code problem 921 minimum add to make parentheses valid if you haven't seen my video on minimum remove to make parentheses valid i'd highly recommend you watch that video first because a lot of the concepts that we're going ... | Minimum Add to Make Parentheses Valid | spiral-matrix-iii | A parentheses string is valid if and only if:
* It is the empty string,
* It can be written as `AB` (`A` concatenated with `B`), where `A` and `B` are valid strings, or
* It can be written as `(A)`, where `A` is a valid string.
You are given a parentheses string `s`. In one move, you can insert a parenthesis at... | null | Array,Matrix,Simulation | Medium | 54,59 |
1,759 | hello welcome back today let's try to serve another liquid problem 1759 called number of homogenous substance so for this problem the homogeneous system is all characters of three that are same and the substrate is a contiguous sequence of the characters with inner string it means for example this is CCC as contiguous ... | Count Number of Homogenous Substrings | find-the-missing-ids | Given a string `s`, return _the number of **homogenous** substrings of_ `s`_._ Since the answer may be too large, return it **modulo** `109 + 7`.
A string is **homogenous** if all the characters of the string are the same.
A **substring** is a contiguous sequence of characters within a string.
**Example 1:**
**Inpu... | null | Database | Medium | 1357,1420,1467 |
926 | Hee gas welcome back to my channel so today our problem is Philip Sting you are monotone increasing so this problem statement bay what have you given us here you have given us a binary sting in which you will not only have zeros and ones but okay what do you have to do Here you have to flip SI, in flip you can convert ... | Flip String to Monotone Increasing | find-and-replace-pattern | A binary string is monotone increasing if it consists of some number of `0`'s (possibly none), followed by some number of `1`'s (also possibly none).
You are given a binary string `s`. You can flip `s[i]` changing it from `0` to `1` or from `1` to `0`.
Return _the minimum number of flips to make_ `s` _monotone increa... | null | Array,Hash Table,String | Medium | null |
24 | hi guys welcome back to the channel today we are back with another very famous question today's question is swept notes in pairs given a linked list swept every two adjacent nodes and returned its head you may not modify the values in the list nodes only nodes itself may be changed so we are given with an example one t... | Swap Nodes in Pairs | swap-nodes-in-pairs | Given a linked list, swap every two adjacent nodes and return its head. You must solve the problem without modifying the values in the list's nodes (i.e., only nodes themselves may be changed.)
**Example 1:**
**Input:** head = \[1,2,3,4\]
**Output:** \[2,1,4,3\]
**Example 2:**
**Input:** head = \[\]
**Output:** \[\... | null | Linked List,Recursion | Medium | 25,528 |
1,817 | hello everyone welcome to another video now in this video we are going to look at another arrays medium level question now although it says it is although it is tagged in arrays but it is more of a map and set kind of question so let's jump into the question what it says and then we'll try to uh understand like how we ... | Finding the Users Active Minutes | calculate-money-in-leetcode-bank | You are given the logs for users' actions on LeetCode, and an integer `k`. The logs are represented by a 2D integer array `logs` where each `logs[i] = [IDi, timei]` indicates that the user with `IDi` performed an action at the minute `timei`.
**Multiple users** can perform actions simultaneously, and a single user can... | Simulate the process by keeping track of how much money John is putting in and which day of the week it is, and use this information to deduce how much money John will put in the next day. | Math | Easy | null |
797 | hey hello there let's talk about today's liquidity challenge question all passes from source to target given the directed acyclic graph dag we want to find all possible paths from node 0 to n minus 1 and return them in any order so it's obviously a graph problem and we're dealing with stack so the input to us is the ad... | All Paths From Source to Target | rabbits-in-forest | Given a directed acyclic graph (**DAG**) of `n` nodes labeled from `0` to `n - 1`, find all possible paths from node `0` to node `n - 1` and return them in **any order**.
The graph is given as follows: `graph[i]` is a list of all nodes you can visit from node `i` (i.e., there is a directed edge from node `i` to node `... | null | Array,Hash Table,Math,Greedy | Medium | null |
18 | foreign and welcome back to another YouTube video so today I'll be following the lead code question for thumb okay so one thing I would really recommend before going on with the solution to this is I would highly recommend that you first solve the previous questions that are twosome and threesome I have made videos for... | 4Sum | 4sum | Given an array `nums` of `n` integers, return _an array of all the **unique** quadruplets_ `[nums[a], nums[b], nums[c], nums[d]]` such that:
* `0 <= a, b, c, d < n`
* `a`, `b`, `c`, and `d` are **distinct**.
* `nums[a] + nums[b] + nums[c] + nums[d] == target`
You may return the answer in **any order**.
**Examp... | null | Array,Two Pointers,Sorting | Medium | 1,15,454,2122 |
316 | hey guys how's everything going this is Jay sir in this video I'm going to take a look at three one six remove dupli-color at three one six remove dupli-color at three one six remove dupli-color letters to be honest I didn't make it about this question I tried for like 30 minutes and I couldn't find the solution as som... | Remove Duplicate Letters | remove-duplicate-letters | Given a string `s`, remove duplicate letters so that every letter appears once and only once. You must make sure your result is **the smallest in lexicographical order** among all possible results.
**Example 1:**
**Input:** s = "bcabc "
**Output:** "abc "
**Example 2:**
**Input:** s = "cbacdcbc "
**Output:** "a... | Greedily try to add one missing character. How to check if adding some character will not cause problems ? Use bit-masks to check whether you will be able to complete the sub-sequence if you add the character at some index i. | String,Stack,Greedy,Monotonic Stack | Medium | 2157 |
63 | Hello Gas Lead Ko Daily Challenge We have come again today on Gyan Portal, your channel and okay for you, so today's question is our great question and great pe this question which has been given to us is that of macros n. One wait is great, okay and what we have to do is that our robot is standing at the top corner me... | Unique Paths II | unique-paths-ii | You are given an `m x n` integer array `grid`. There is a robot initially located at the **top-left corner** (i.e., `grid[0][0]`). The robot tries to move to the **bottom-right corner** (i.e., `grid[m - 1][n - 1]`). The robot can only move either down or right at any point in time.
An obstacle and space are marked as ... | The robot can only move either down or right. Hence any cell in the first row can only be reached from the cell left to it. However, if any cell has an obstacle, you don't let that cell contribute to any path. So, for the first row, the number of ways will simply be
if obstacleGrid[i][j] is not an obstacle
... | Array,Dynamic Programming,Matrix | Medium | 62,1022 |
1,897 | 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 redistribute characters to make all strings equal so in this question we given a string array called words in one operation we can pick two distinct indices I and J which means you can pick two strings ... | Redistribute Characters to Make All Strings Equal | maximize-palindrome-length-from-subsequences | You are given an array of strings `words` (**0-indexed**).
In one operation, pick two **distinct** indices `i` and `j`, where `words[i]` is a non-empty string, and move **any** character from `words[i]` to **any** position in `words[j]`.
Return `true` _if you can make **every** string in_ `words` _**equal** using **a... | Let's ignore the non-empty subsequence constraint. We can concatenate the two strings and find the largest palindromic subsequence with dynamic programming. Iterate through every pair of characters word1[i] and word2[j], and see if some palindrome begins with word1[i] and ends with word2[j]. This ensures that the subse... | String,Dynamic Programming | Hard | 516 |
6 | okay so this problem goes like this so i have a string okay i have a string and let's say that it says we are hiring okay so this is the original string now i can i write the string in a zigzag pattern okay so on let's say on the three rows okay so what that looks like is we are high all right so if you read from top l... | Zigzag Conversion | zigzag-conversion | The string `"PAYPALISHIRING "` is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)
P A H N
A P L S I I G
Y I R
And then read line by line: `"PAHNAPLSIIGYIR "`
Write the code that will take a string and make this co... | null | String | Medium | null |
232 | hi students welcome back today we are going to look at implementing a queue using two stacks okay so let's see the problem statement first the problem statement says implemented first in first node which is Q using only two stacks the implemented queue should support all the functions of a normal queue which is push p ... | Implement Queue using Stacks | implement-queue-using-stacks | Implement a first in first out (FIFO) queue using only two stacks. The implemented queue should support all the functions of a normal queue (`push`, `peek`, `pop`, and `empty`).
Implement the `MyQueue` class:
* `void push(int x)` Pushes element x to the back of the queue.
* `int pop()` Removes the element from th... | null | Stack,Design,Queue | Easy | 225 |
371 | hey guys welcome back to the channel in our previous video we solved this problem sum of two integers just pretty much saying given decimal numbers a and b we want to add them up without using the plus and minus sign okay we solved the user c because he was the better tool than python so today we're going to explain th... | 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 |
64 | Hello hello everyone welcome to my channel's studio will discuss some problem from list co DC minimum alarm of I will come in this problem is highly recommend you to the public number 6 to Chinese path 163 Amazing bathroom after going through this problem delivery me gift you To understand this problem and suffering fr... | 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,753 | hey everybody this is larry this is me going over weekly contest 227 uh q2 maximum score from removing stones um hit the like button hit the subscribe button join me on this card ask me questions about this one i think this one is really tricky uh it let's see it took me about four minutes to do this but uh well people... | Maximum Score From Removing Stones | path-with-minimum-effort | You are playing a solitaire game with **three piles** of stones of sizes `a`, `b`, and `c` respectively. Each turn you choose two **different non-empty** piles, take one stone from each, and add `1` point to your score. The game stops when there are **fewer than two non-empty** piles (meaning there ar... | Consider the grid as a graph, where adjacent cells have an edge with cost of the difference between the cells. If you are given threshold k, check if it is possible to go from (0, 0) to (n-1, m-1) using only edges of ≤ k cost. Binary search the k value. | Array,Binary Search,Depth-First Search,Breadth-First Search,Union Find,Heap (Priority Queue),Matrix | Medium | 794,1099 |
1,617 | everybody is larry does me going with q4 of the weekly contest 210 uh count subtrees with max distance between cities uh hit the like button hit the subscribe and join me on discord so i was able to solve this in about 12 to 13 minutes during the contest or during the virtual contest which is sad um so i think one thin... | Count Subtrees With Max Distance Between Cities | stone-game-iv | There are `n` cities numbered from `1` to `n`. You are given an array `edges` of size `n-1`, where `edges[i] = [ui, vi]` represents a bidirectional edge between cities `ui` and `vi`. There exists a unique path between each pair of cities. In other words, the cities form a **tree**.
A **subtree** is a subset of cities ... | Use dynamic programming to keep track of winning and losing states. Given some number of stones, Alice can win if she can force Bob onto a losing state. | Math,Dynamic Programming,Game Theory | Hard | 1685,1788,1808,2002,2156 |
143 | There are even today 11 times fruit rio de this problem only problem yagya not absolute end list this edition of verses in 12345 one to MP3 take and end definition of Venus which link year note tubelight note second world tour not third last not the sellout mode switch START SOME WORK LINK WITH LAST HERE LAST TO OPPORT... | Reorder List | reorder-list | You are given the head of a singly linked-list. The list can be represented as:
L0 -> L1 -> ... -> Ln - 1 -> Ln
_Reorder the list to be on the following form:_
L0 -> Ln -> L1 -> Ln - 1 -> L2 -> Ln - 2 -> ...
You may not modify the values in the list's nodes. Only nodes themselves may be changed.
**Example 1:**
**... | null | Linked List,Two Pointers,Stack,Recursion | Medium | 2216 |
451 | hi everyone it's Soren today we have a problem when we are given a string s and we need to sort it in descending order based on the frequency of the characters so what's that mean so for example in this case e is repeated twice R is repeated once and the t is also repeated once so we need to sort it so e should come fi... | Sort Characters By Frequency | sort-characters-by-frequency | Given a string `s`, sort it in **decreasing order** based on the **frequency** of the characters. The **frequency** of a character is the number of times it appears in the string.
Return _the sorted string_. If there are multiple answers, return _any of them_.
**Example 1:**
**Input:** s = "tree "
**Output:** "eer... | null | Hash Table,String,Sorting,Heap (Priority Queue),Bucket Sort,Counting | Medium | 347,387,1741 |
549 | hey everybody this is Larry this is me doing a bonus question uh that haven't done before I have to remember to set premium because for some reason it doesn't always do PM let's do a medium because I think I'm liking a lot of mediums or something uh and then oh yeah to do and yeah let's go and hopefully no SQL phone I ... | Binary Tree Longest Consecutive Sequence II | binary-tree-longest-consecutive-sequence-ii | Given the `root` of a binary tree, return _the length of the longest consecutive path in the tree_.
A consecutive path is a path where the values of the consecutive nodes in the path differ by one. This path can be either increasing or decreasing.
* For example, `[1,2,3,4]` and `[4,3,2,1]` are both considered valid... | null | Tree,Depth-First Search,Binary Tree | Medium | 298,1416 |
1,004 | Hi friends welcome to my channel co destination so as we are continuing this challenge one code one day on my channel so daily we are discussing one problem and with detail analysis so today we are taking one very famous topic sliding window first we will discuss the Concept Behind This Then After That We Will Pick One... | 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 |
442 | hello and welcome back to the cracking fang youtube channel today we're gonna be solving lead code problem 442. find all duplicates in an array before we read the question prompt i would just like to kindly ask you to subscribe to my channel i have the goal of reaching a thousand subscribers by the end of may and i nee... | Find All Duplicates in an Array | find-all-duplicates-in-an-array | Given an integer array `nums` of length `n` where all the integers of `nums` are in the range `[1, n]` and each integer appears **once** or **twice**, return _an array of all the integers that appears **twice**_.
You must write an algorithm that runs in `O(n)` time and uses only constant extra space.
**Example 1:**
... | null | Array,Hash Table | Medium | 448 |
434 | hey everyone welcome back and today we'll be doing another lead code four three four number of segments in a string and easy one given a string as written the number of segments in the string so if there is a Hello is my name is John there are five words so basically just return the words how many words are in this str... | Number of Segments in a String | number-of-segments-in-a-string | Given a string `s`, return _the number of segments in the string_.
A **segment** is defined to be a contiguous sequence of **non-space characters**.
**Example 1:**
**Input:** s = "Hello, my name is John "
**Output:** 5
**Explanation:** The five segments are \[ "Hello, ", "my ", "name ", "is ", "John "\]
**Exam... | null | String | Easy | null |
1,877 | hi so today we are going to solve lead code problem number 1876 minimize maximum pair sum in Array it is today's problem of the day so in this question they will give us a an array and you have to try all the possible way in which you will make pair of two elements and in which element you will get minimum of Maximum p... | Minimize Maximum Pair Sum in Array | find-followers-count | The **pair sum** of a pair `(a,b)` is equal to `a + b`. The **maximum pair sum** is the largest **pair sum** in a list of pairs.
* For example, if we have pairs `(1,5)`, `(2,3)`, and `(4,4)`, the **maximum pair sum** would be `max(1+5, 2+3, 4+4) = max(6, 5, 8) = 8`.
Given an array `nums` of **even** length `n`, pai... | null | Database | Easy | null |
141 | hello everyone my name is alvaro and in this video i will be solving another problem from the blind lead code 75 problem list today i will be doing problem 141 which is called linked list cycle so let's read the problem statement a given head the head of a linked list determine if the linked list has a cycle in it ther... | 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 |
697 | YouTube welcome back today we have this problem it's a degree of an array we have given non-empty array of non-negative given non-empty array of non-negative given non-empty array of non-negative integers the degree of this array is defined as the maximum frequency of the of one of its elements your task is to find the... | Degree of an Array | degree-of-an-array | Given a non-empty array of non-negative integers `nums`, the **degree** of this array is defined as the maximum frequency of any one of its elements.
Your task is to find the smallest possible length of a (contiguous) subarray of `nums`, that has the same degree as `nums`.
**Example 1:**
**Input:** nums = \[1,2,2,3,... | Say 5 is the only element that occurs the most number of times - for example, nums = [1, 5, 2, 3, 5, 4, 5, 6]. What is the answer? | Array,Hash Table | Easy | 53 |
1,980 | let's do elite code find unique binary string okay given the array of strings that does not appear in numbs okay finally string okay so you have zero one zero hidden one what if there is no answer so let's think also this answer and there's also this answer expected rows of nums to have size in between four and four oh... | Find Unique Binary String | faulty-sensor | Given an array of strings `nums` containing `n` **unique** binary strings each of length `n`, return _a binary string of length_ `n` _that **does not appear** in_ `nums`_. If there are multiple answers, you may return **any** of them_.
**Example 1:**
**Input:** nums = \[ "01 ", "10 "\]
**Output:** "11 "
**Explanatio... | Check for a common prefix of the two arrays. After this common prefix, there should be one array similar to the other but shifted by one. If both arrays can be shifted, return -1. | Array,Two Pointers | Easy | null |
1,846 | hello everyone welcome back to the channel so today we'll solve the daily challenge from late code so let's see the question first which is maximum element after decreasing and rearranging this is a medium level problem and you are given an array of positive integers array uh perform some operation possibly none on AR ... | Maximum Element After Decreasing and Rearranging | maximum-element-after-decreasing-and-rearranging | You are given an array of positive integers `arr`. Perform some operations (possibly none) on `arr` so that it satisfies these conditions:
* The value of the **first** element in `arr` must be `1`.
* The absolute difference between any 2 adjacent elements must be **less than or equal to** `1`. In other words, `abs... | null | null | Medium | null |
1,277 | in today's problem we have to find the number of a square within a given matrix and what are squares square means squares of ones so even just one cell is itself a square in it and if you take 2 cross 2 it can be another square if we have 3 cross 3 that is another square so largest possible square size would be 3 cross... | Count Square Submatrices with All Ones | largest-multiple-of-three | Given a `m * n` matrix of ones and zeros, return how many **square** submatrices have all ones.
**Example 1:**
**Input:** matrix =
\[
\[0,1,1,1\],
\[1,1,1,1\],
\[0,1,1,1\]
\]
**Output:** 15
**Explanation:**
There are **10** squares of side 1.
There are **4** squares of side 2.
There is **1** square of side 3.... | A number is a multiple of three if and only if its sum of digits is a multiple of three. Use dynamic programming. To find the maximum number, try to maximize the number of digits of the number. Sort the digits in descending order to find the maximum number. | Array,Dynamic Programming,Greedy | Hard | null |
1,192 | Hello hello guys welcome back to decades and this video will see the critical connection to network problem which established code number 12192 in this problem can be solved by using the general co adamkhor brijesh no latest video problem statement in this problem drops number from 0 connected And electronic media netw... | Critical Connections in a Network | divide-chocolate | There are `n` servers numbered from `0` to `n - 1` connected by undirected server-to-server `connections` forming a network where `connections[i] = [ai, bi]` represents a connection between servers `ai` and `bi`. Any server can reach other servers directly or indirectly through the network.
A _critical connection_ is ... | After dividing the array into K+1 sub-arrays, you will pick the sub-array with the minimum sum. Divide the sub-array into K+1 sub-arrays such that the minimum sub-array sum is as maximum as possible. Use binary search with greedy check. | Array,Binary Search | Hard | 410,1056 |
58 | hello everyone in this video i'll be going over lee code number 58 length of last word the problem description is given a string s consisting of some words separated by spaces return the length of the last word in the string if the last word does not exist return zero a word is a maximal substring consisting of non-spa... | Length of Last Word | length-of-last-word | Given a string `s` consisting of words and spaces, return _the length of the **last** word in the string._
A **word** is a maximal substring consisting of non-space characters only.
**Example 1:**
**Input:** s = "Hello World "
**Output:** 5
**Explanation:** The last word is "World " with length 5.
**Example 2:**
... | null | String | Easy | null |
455 | hey everyone welcome back and let's write some more neat code today so today let's solve the problem assign cookies we're basically given two input arrays one is the greed factor of every child so every child has a certain greed Factor the higher the number the more greedy they are which means they require a larger coo... | Assign Cookies | assign-cookies | Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie.
Each child `i` has a greed factor `g[i]`, which is the minimum size of a cookie that the child will be content with; and each cookie `j` has a size `s[j]`. If `s[j] >= g[i]`, we can assign ... | null | Array,Greedy,Sorting | Easy | null |
1,361 | Hello guys I am Lalit Agarwal welcome to you all on your own coding channel code fix made by you made for you so let's start now today's lead code problem aaj ki lead code ki problem kya bol rahi hai achha before going towards the problem na one minute Dish for those who have understood this problem well and who want t... | Validate Binary Tree Nodes | tiling-a-rectangle-with-the-fewest-squares | You have `n` binary tree nodes numbered from `0` to `n - 1` where node `i` has two children `leftChild[i]` and `rightChild[i]`, return `true` if and only if **all** the given nodes form **exactly one** valid binary tree.
If node `i` has no left child then `leftChild[i]` will equal `-1`, similarly for the right child.
... | Can you use backtracking to solve this problem ?. Suppose you've placed a bunch of squares. Where is the natural spot to place the next square ?. The maximum number of squares to be placed will be ≤ max(n,m). | Dynamic Programming,Backtracking | Hard | null |
1,015 | Hello Everyone Welcome to 0.5 Inch Time Without Dress subscribe this Video like and subscribe the Video then subscribe to the Page if you liked The Video then subscribe to the Page if and subscribe this channel for Unlimited Red Color Module subscribe Video subscribe Liquid Not Fit Into The 10 Most Important Meeting So... | Smallest Integer Divisible by K | smallest-integer-divisible-by-k | Given a positive integer `k`, you need to find the **length** of the **smallest** positive integer `n` such that `n` is divisible by `k`, and `n` only contains the digit `1`.
Return _the **length** of_ `n`. If there is no such `n`, return -1.
**Note:** `n` may not fit in a 64-bit signed integer.
**Example 1:**
**In... | null | null | Medium | null |
39 | hey guys welcome back to another video and today we're going to be solving the leaka question combination sum alright so recently i think last month i solved the question combination sum two so do that check that out after this question all right so given an area of distinct integers called candidates and a target inte... | Combination Sum | combination-sum | Given an array of **distinct** integers `candidates` and a target integer `target`, return _a list of all **unique combinations** of_ `candidates` _where the chosen numbers sum to_ `target`_._ You may return the combinations in **any order**.
The **same** number may be chosen from `candidates` an **unlimited number of... | null | Array,Backtracking | Medium | 17,40,77,216,254,377 |
1,605 | all right let's talk about the fine valid metric given row and column sum so you are given two array row sum and column sum of non-negative integer column sum of non-negative integer column sum of non-negative integer right uh you can go through this and i'm gonna just quickly just talk about the question so this is ac... | Find Valid Matrix Given Row and Column Sums | minimum-number-of-days-to-make-m-bouquets | You are given two arrays `rowSum` and `colSum` of non-negative integers where `rowSum[i]` is the sum of the elements in the `ith` row and `colSum[j]` is the sum of the elements of the `jth` column of a 2D matrix. In other words, you do not know the elements of the matrix, but you do know the sums of each row and column... | If we can make m or more bouquets at day x, then we can still make m or more bouquets at any day y > x. We can check easily if we can make enough bouquets at day x if we can get group adjacent flowers at day x. | Array,Binary Search | Medium | 2134,2257 |
328 | hi guys welcome to the tech grant today we will solve a problem on linked list do like and share the video subscribe to the channel to get further update and the problem here is called odd even linked list and what we need to do is we need to place all the odd nodes of the linked list together and even node of the engl... | Odd Even Linked List | odd-even-linked-list | Given the `head` of a singly linked list, group all the nodes with odd indices together followed by the nodes with even indices, and return _the reordered list_.
The **first** node is considered **odd**, and the **second** node is **even**, and so on.
Note that the relative order inside both the even and odd groups s... | null | Linked List | Medium | 725 |
58 | hello everyone welcome back here is when I'm saying and with another exciting live coding session today we got an interesting problem on our plate finding the length of last word in a string so and we are diving deep into go language for this one so here's our challenge for today given a string consisting of words sepa... | Length of Last Word | length-of-last-word | Given a string `s` consisting of words and spaces, return _the length of the **last** word in the string._
A **word** is a maximal substring consisting of non-space characters only.
**Example 1:**
**Input:** s = "Hello World "
**Output:** 5
**Explanation:** The last word is "World " with length 5.
**Example 2:**
... | null | String | Easy | null |
58 | in this video we'll be going over a length of last word so we're given a string s consists of some words separated by spaces return the length of the last word in the string if the last word does not exist will return zero a word is the maximum substring consisting of non-space substring consisting of non-space substri... | Length of Last Word | length-of-last-word | Given a string `s` consisting of words and spaces, return _the length of the **last** word in the string._
A **word** is a maximal substring consisting of non-space characters only.
**Example 1:**
**Input:** s = "Hello World "
**Output:** 5
**Explanation:** The last word is "World " with length 5.
**Example 2:**
... | null | String | Easy | null |
414 | given a non empty array of integers between the third maximum number this away if it does not exist we turn the maximum number the time complexity must be an O then okay huh okay I mean this seems pretty straightforward I mean it we've just if you only need to return the max number you just pretty much keep three where... | Third Maximum Number | third-maximum-number | Given an integer array `nums`, return _the **third distinct maximum** number in this array. If the third maximum does not exist, return the **maximum** number_.
**Example 1:**
**Input:** nums = \[3,2,1\]
**Output:** 1
**Explanation:**
The first distinct maximum is 3.
The second distinct maximum is 2.
The third distin... | null | Array,Sorting | Easy | 215 |
261 | problem 261 graph validated TR so we are getting a graph structure we are going to check if this graph can become a tree but it should be validated tree let me explain this problem yeah uh we should know about what should be a graph so for example this nod connected to this nod there's another two no they are also conn... | Graph Valid Tree | graph-valid-tree | You have a graph of `n` nodes labeled from `0` to `n - 1`. You are given an integer n and a list of `edges` where `edges[i] = [ai, bi]` indicates that there is an undirected edge between nodes `ai` and `bi` in the graph.
Return `true` _if the edges of the given graph make up a valid tree, and_ `false` _otherwise_.
**... | Given n = 5 and edges = [[0, 1], [1, 2], [3, 4]], what should your return? Is this case a valid tree? According to the definition of tree on Wikipedia: “a tree is an undirected graph in which any two vertices are connected by exactly one path. In other words, any connected graph without simple cycles is a tree.” | Depth-First Search,Breadth-First Search,Union Find,Graph | Medium | 207,323,871 |
33 | Hello everyone, in today's question, what we are waiting for is date is of interest and it is always having distinct characters and if we are getting date particular target value I am going to write index of date particular value so if we can see. D code air in D code you implement you search D thing I am using D binar... | Search in Rotated Sorted Array | search-in-rotated-sorted-array | There is an integer array `nums` sorted in ascending order (with **distinct** values).
Prior to being passed to your function, `nums` is **possibly rotated** at an unknown pivot index `k` (`1 <= k < nums.length`) such that the resulting array is `[nums[k], nums[k+1], ..., nums[n-1], nums[0], nums[1], ..., nums[k-1]]` ... | null | Array,Binary Search | Medium | 81,153,2273 |
35 | hello and welcome to another Elite code solution video this is problem number 35 search insert position for this problem we're 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 alg... | 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,870 | hi everyone today we are going to solve another lead code problem that is minimum speed to arrive on time and in this one we are given a distance array and the maximum hours in which we can reach to the office and we have to return the minimum positive integer speed that all the trains must travel at for you to reach t... | 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 |
116 | all right let's talk about populating next right pointers in each node so you're given a perfect binary tree so uh you have a struct node so you have valve left right and an x and then base basically you just have to point your current null uh to the next one in the current level and if you're on the last note right ju... | Populating Next Right Pointers in Each Node | populating-next-right-pointers-in-each-node | You are given a **perfect binary tree** where all leaves are on the same level, and every parent has two children. The binary tree has the following definition:
struct Node {
int val;
Node \*left;
Node \*right;
Node \*next;
}
Populate each next pointer to point to its next right node. If there is no next righ... | null | Linked List,Tree,Depth-First Search,Breadth-First Search,Binary Tree | Medium | 117,199 |
94 | hey everybody in this video we are going to be solving a problem on lead code which is binary tree in order traversal so it's a really simple problem tagged as easy and it has a very straightforward solution now other than this problem if you all want to check out some solutions to other problems on lead code based on ... | Binary Tree Inorder Traversal | binary-tree-inorder-traversal | Given the `root` of a binary tree, return _the inorder traversal of its nodes' values_.
**Example 1:**
**Input:** root = \[1,null,2,3\]
**Output:** \[1,3,2\]
**Example 2:**
**Input:** root = \[\]
**Output:** \[\]
**Example 3:**
**Input:** root = \[1\]
**Output:** \[1\]
**Constraints:**
* The number of nodes i... | null | Stack,Tree,Depth-First Search,Binary Tree | Easy | 98,144,145,173,230,272,285,758,799 |
338 | hey guys it's all five one here and today we're going to be solving counting bits in this problem we're given an integer n and they want us to return an array answers of length n plus one such that for each element the number of ones in the binary representation should be stored in that index so what does that mean exa... | 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 |
796 | oh cool we're given two strings a and B a chiffon string a consists on ticking string a moving the leftmost character the rightmost character okay that seems okay man this is so basically okay so basically just return whether it can be a ship of P or B can be a ship a can be a ship of P or B can be a ship of a which I ... | Rotate String | reaching-points | Given two strings `s` and `goal`, return `true` _if and only if_ `s` _can become_ `goal` _after some number of **shifts** on_ `s`.
A **shift** on `s` consists of moving the leftmost character of `s` to the rightmost position.
* For example, if `s = "abcde "`, then it will be `"bcdea "` after one shift.
**Example 1... | null | Math | Hard | null |
1,688 | hello everyone so in this video we'll solve liquid problem number 1688 that is count of matches in tournament so in the problem statement we are given an integer and that is the number of teams in the tournament and we have to find the total matches that will be played in the tournament So based upon the number of team... | Count of Matches in Tournament | the-most-recent-orders-for-each-product | You are given an integer `n`, the number of teams in a tournament that has strange rules:
* If the current number of teams is **even**, each team gets paired with another team. A total of `n / 2` matches are played, and `n / 2` teams advance to the next round.
* If the current number of teams is **odd**, one team ... | null | Database | Medium | 1671,1735 |
35 | hey guys persistent programmer here and today we're gonna do another Lika question search insert position so for this problem we're given a sorted array and the target value and we need to return the index of the target if the target is fog and if not we need to return the index of where that target would be so this is... | 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 |
816 | hey my name is khushbu and welcome to algorithms made easy in this video we are going to see the question ambiguous coordinates we had some two dimensional coordinates like 1 comma 3 or 2 comma 0.5 like 1 comma 3 or 2 comma 0.5 like 1 comma 3 or 2 comma 0.5 and then we removed all the commas and decimal points and spac... | Ambiguous Coordinates | design-hashset | We had some 2-dimensional coordinates, like `"(1, 3) "` or `"(2, 0.5) "`. Then, we removed all commas, decimal points, and spaces and ended up with the string s.
* For example, `"(1, 3) "` becomes `s = "(13) "` and `"(2, 0.5) "` becomes `s = "(205) "`.
Return _a list of strings representing all possibilities for wh... | null | Array,Hash Table,Linked List,Design,Hash Function | Easy | 817,1337 |
1,665 | hi everyone welcome back to the channel today let's solve a hard question from the code weekly contest the minimum initial energy to finish task the question statement so we are given an array a task where each element in the array is an array of two elements actual and minimum and actual is the actual amount of energy... | Minimum Initial Energy to Finish Tasks | diameter-of-n-ary-tree | You are given an array `tasks` where `tasks[i] = [actuali, minimumi]`:
* `actuali` is the actual amount of energy you **spend to finish** the `ith` task.
* `minimumi` is the minimum amount of energy you **require to begin** the `ith` task.
For example, if the task is `[10, 12]` and your current energy is `11`, yo... | For the node i, calculate the height of each of its children and keep the first and second maximum heights (max1_i , max2_i). Check all nodes and return max( 2 + max1_i + max2_i ). | Tree,Depth-First Search | Medium | 543 |
784 | cool 784 in either case permutation given a string as we can transport every letter individually to be lowercase or uppercase to create another string we turn a list of all possible strings we could create okay cool letters okay I mean you could do this with I'm just I don't actually know what the expectations for user... | Letter Case Permutation | insert-into-a-binary-search-tree | Given a string `s`, you can transform every letter individually to be lowercase or uppercase to create another string.
Return _a list of all possible strings we could create_. Return the output in **any order**.
**Example 1:**
**Input:** s = "a1b2 "
**Output:** \[ "a1b2 ", "a1B2 ", "A1b2 ", "A1B2 "\]
**Example 2:*... | null | Tree,Binary Search Tree,Binary Tree | Medium | 783 |
81 | Jai hind is problem fifty tere bandhe Raees clip from middle sorted in this app you can contain decrease is more exactly values like this you can contain decrease is more exactly values like this and strong sorted my tablets flatlens duplicate so wick liquid input deficit in this alert to a sweet can go appeal this... | Search in Rotated Sorted Array II | search-in-rotated-sorted-array-ii | There is an integer array `nums` sorted in non-decreasing order (not necessarily with **distinct** values).
Before being passed to your function, `nums` is **rotated** at an unknown pivot index `k` (`0 <= k < nums.length`) such that the resulting array is `[nums[k], nums[k+1], ..., nums[n-1], nums[0], nums[1], ..., nu... | null | Array,Binary Search | Medium | 33 |
1,095 | hello guys and welcome back to lead Logics today we are going to solve the question find in Mountain Area it is a lead Cod hard and the number for this is 1095 so we have to find an element in the mountain array and we have to return the minimum index of the element so what is a mountain array so in this question we ar... | 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 |
64 | what is up YouTube today we are gonna be going over minimum path some it's a meme problem leaked code Amazon had last this question before I started a slack channel where I posted problems I posted the link below and lastly check out my channel and subscribe if you haven't already I post videos every weekday I'll see y... | 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,689 | hello everyone welcome to quartus camp we are at 26th day of mail it code challenge and the problem we are going to cover today is partitioning into minimum number of deci binary numbers so the input given here is a string which represent a decimal number and we have to return the minimum number of positive deci binary... | Partitioning Into Minimum Number Of Deci-Binary Numbers | detect-pattern-of-length-m-repeated-k-or-more-times | A decimal number is called **deci-binary** if each of its digits is either `0` or `1` without any leading zeros. For example, `101` and `1100` are **deci-binary**, while `112` and `3001` are not.
Given a string `n` that represents a positive decimal integer, return _the **minimum** number of positive **deci-binary** n... | Use a three-layer loop to check all possible patterns by iterating through all possible starting positions, all indexes less than m, and if the character at the index is repeated k times. | Array,Enumeration | Easy | 1764 |
1,793 | hey everybody this is larry this is me going over with q4 weekly contest 232 maximum score of a good array um i think they just get lazy i mean this is it took a long time for me to actually just read this problem um because i don't know what is it go to way can you say anything else can you use any other adjective any... | Maximum Score of a Good Subarray | minimum-moves-to-make-array-complementary | You are given an array of integers `nums` **(0-indexed)** and an integer `k`.
The **score** of a subarray `(i, j)` is defined as `min(nums[i], nums[i+1], ..., nums[j]) * (j - i + 1)`. A **good** subarray is a subarray where `i <= k <= j`.
Return _the maximum possible **score** of a **good** subarray._
**Example 1:**... | Given a target sum x, each pair of nums[i] and nums[n-1-i] would either need 0, 1, or 2 modifications. Can you find the optimal target sum x value such that the sum of modifications is minimized? Create a difference array to efficiently sum all the modifications. | Array,Hash Table,Prefix Sum | Medium | null |
82 | hey hello there so the second link list question I'm looking at the day as the 82 removeduplicates front soldier listed - so it's potentially a full upper 283 - so it's potentially a full upper 283 - so it's potentially a full upper 283 remove duplicates for answering a list for that question we have a sorted linked li... | Remove Duplicates from Sorted List II | remove-duplicates-from-sorted-list-ii | Given the `head` of a sorted linked list, _delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list_. Return _the linked list **sorted** as well_.
**Example 1:**
**Input:** head = \[1,2,3,3,4,4,5\]
**Output:** \[1,2,5\]
**Example 2:**
**Input:** head = \[1,1,1,2,3\]
**Outpu... | null | Linked List,Two Pointers | Medium | 83,1982 |
1,750 | hello guys welcome back to my YouTube channel today I going to solve day five problem of this month on lead Cod if you guys haven't subscribed my YouTube channel yet then please go ahead and subscribe it now without any delay let's get started with today's problem so today uh we are going to solve problem number 1750 t... | Minimum Length of String After Deleting Similar Ends | check-if-two-expression-trees-are-equivalent | Given a string `s` consisting only of characters `'a'`, `'b'`, and `'c'`. You are asked to apply the following algorithm on the string any number of times:
1. Pick a **non-empty** prefix from the string `s` where all the characters in the prefix are equal.
2. Pick a **non-empty** suffix from the string `s` where all... | Count for each variable how many times it appeared in the first tree. Do the same for the second tree and check if the count is the same for both tree. | Tree,Depth-First Search,Binary Tree | Medium | 1736 |
1,094 | What is the problem of marriage, leaning forward, report problem number is 101, what is the problem of police, give us one and its quid, reasonable volume, maximum number of people can sit, then we are given a little in the name only, that melt, what is there in it. Like and if we talk about jeep players then in that 2... | Car Pooling | matrix-cells-in-distance-order | There is a car with `capacity` empty seats. The vehicle only drives east (i.e., it cannot turn around and drive west).
You are given the integer `capacity` and an array `trips` where `trips[i] = [numPassengersi, fromi, toi]` indicates that the `ith` trip has `numPassengersi` passengers and the locations to pick them u... | null | Array,Math,Geometry,Sorting,Matrix | Easy | 2304 |
397 | hey what's up guys so uh welcome to my little zone section so this is this uh 397 uh integral uh integer replacement oh so given the insurance you can replace the one or following so if one is even then you can replace and divide by two okay so that means if one is even you if it's even right then you don't have any wa... | Integer Replacement | integer-replacement | Given a positive integer `n`, you can apply one of the following operations:
1. If `n` is even, replace `n` with `n / 2`.
2. If `n` is odd, replace `n` with either `n + 1` or `n - 1`.
Return _the minimum number of operations needed for_ `n` _to become_ `1`.
**Example 1:**
**Input:** n = 8
**Output:** 3
**Explanat... | null | Dynamic Programming,Greedy,Bit Manipulation,Memoization | Medium | null |
1,844 | Salam alikum so we're going to continue with the lead code question 1844 replacing all digit characters as the question States you are given the zero indexed string s that has lower case English letter in its even indicates and digits in its odd indicates so there is a function shift C for characters X for numbers wher... | Replace All Digits with Characters | maximum-number-of-balls-in-a-box | You are given a **0-indexed** string `s` that has lowercase English letters in its **even** indices and digits in its **odd** indices.
There is a function `shift(c, x)`, where `c` is a character and `x` is a digit, that returns the `xth` character after `c`.
* For example, `shift('a', 5) = 'f'` and `shift('x', 0) =... | Note that both lowLimit and highLimit are of small constraints so you can iterate on all nubmer between them You can simulate the boxes by counting for each box the number of balls with digit sum equal to that box number | Hash Table,Math,Counting | Easy | null |
249 | hey everyone this is the lead code time so in this video there are two goals the first goal is to see how to solve this problem and then we are going to put some code there and the second one is to see uh how to behave during a real interview so let's get started remember the first step is always to try to understand t... | Group Shifted Strings | group-shifted-strings | We can shift a string by shifting each of its letters to its successive letter.
* For example, `"abc "` can be shifted to be `"bcd "`.
We can keep shifting the string to form a sequence.
* For example, we can keep shifting `"abc "` to form the sequence: `"abc " -> "bcd " -> ... -> "xyz "`.
Given an array of str... | null | Array,Hash Table,String | Medium | 49 |
105 | angry birds welcome to my channel it's all great problem constructed minority from creator and energizer traversal loudest offering being constructed by doing so for example this free mode traversal of history thing 30 to poisonous 500 600 you must not explain reversal on route subscribe which is not After detroit sub ... | 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 |
155 | what is going on everyone so today we are looking at lead code number 155 it's a question called min stack and so what we have here is we have to design a stack that supports push pop top and retrieving the minimum element in constant time okay so we have a class here min stack and we are going to initialize a stack ob... | Min Stack | min-stack | Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.
Implement the `MinStack` class:
* `MinStack()` initializes the stack object.
* `void push(int val)` pushes the element `val` onto the stack.
* `void pop()` removes the element on the top of the stack.
* `int top(... | Consider each node in the stack having a minimum value. (Credits to @aakarshmadhavan) | Stack,Design | Easy | 239,716 |
203 | hey everybody this is larry this is day 12 of the uh november nico day challenge forgot what month it was uh hit the like button in the subscribe button join me on discord let me know what you think about today's prom seems like it's easy only because they tell me i don't really like classifying them but all right let'... | Remove Linked List Elements | remove-linked-list-elements | Given the `head` of a linked list and an integer `val`, remove all the nodes of the linked list that has `Node.val == val`, and return _the new head_.
**Example 1:**
**Input:** head = \[1,2,6,3,4,5,6\], val = 6
**Output:** \[1,2,3,4,5\]
**Example 2:**
**Input:** head = \[\], val = 1
**Output:** \[\]
**Example 3:**... | null | Linked List,Recursion | Easy | 27,237,2216 |
1,942 | hey everybody this is larry this makeover q2 multiply weekly contest 57 the number of smallers on occupied chair so this one has two uh things you have to consider but otherwise it's what i call a bookkeeping prompt and so yeah you should hit the like button hit the subscribe button join me on discord and let me know w... | The Number of the Smallest Unoccupied Chair | primary-department-for-each-employee | There is a party where `n` friends numbered from `0` to `n - 1` are attending. There is an **infinite** number of chairs in this party that are numbered from `0` to `infinity`. When a friend arrives at the party, they sit on the unoccupied chair with the **smallest number**.
* For example, if chairs `0`, `1`, and `5... | null | Database | Easy | null |
113 | the old path sum2 problem which is the most important depth first search problem you're likely to encounter every how everybody has to do the path sum to problem it's absolutely the greatest bestest problem you've ever heard of nobody could live without doing the path sum two problem just one question what is the path ... | 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 |
1,347 | hello hi guys good morning welcome back to a new video in this we'll see the problem minimum number of steps to make two strings anagram the problem is itself already like this it has been asked by do Dash and Bloomberg six times in the last 6 months and has been asked BYL and quadrix and Twitter so let's see what the ... | Minimum Number of Steps to Make Two Strings Anagram | distance-to-a-cycle-in-undirected-graph | You are given two strings of the same length `s` and `t`. In one step you can choose **any character** of `t` and replace it with **another character**.
Return _the minimum number of steps_ to make `t` an anagram of `s`.
An **Anagram** of a string is a string that contains the same characters with a different (or the... | This problem can be broken down into two parts: finding the cycle, and finding the distance between each node and the cycle. How can we find the cycle? We can use DFS and keep track of the nodes we’ve seen, and the order that we see them in. Once we see a node we’ve already visited, we know that the cycle contains the ... | Depth-First Search,Breadth-First Search,Union Find,Graph | Hard | 2218 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.