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 |
|---|---|---|---|---|---|---|---|---|
285 | hello friends today I will try something author successor in PST given a binary search tree and a node in it find the inorder successor of that node in the BST the success of a node P is a node with the smallest key creators and pitiful let us see the example given a tree about 2 1 3 and P is 1 so we will return to so ... | 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 |
559 | hello guys welcome to deep codes and in today's video we will discuss related question 559 this is maximum depth of energy so what does an editory means this is this would be the first question that comes to your mind when you think of this question okay so an editory means so let me try to give you an example so let's... | Maximum Depth of N-ary Tree | maximum-depth-of-n-ary-tree | Given a n-ary tree, find its maximum depth.
The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.
_Nary-Tree input serialization is represented in their level order traversal, each group of children is separated by the null value (See examples)._
**Example... | null | null | Easy | null |
767 | hello everyone welcome back here is vanamsin and today we have something super interesting lineup and for you a problem that's easy to understand but will give your brain a nice workout so we are attacking lead code 767 uh reorganized string problem and this isn't just a problem it's a puzzle that you are going to love... | Reorganize String | prime-number-of-set-bits-in-binary-representation | Given a string `s`, rearrange the characters of `s` so that any two adjacent characters are not the same.
Return _any possible rearrangement of_ `s` _or return_ `" "` _if not possible_.
**Example 1:**
**Input:** s = "aab"
**Output:** "aba"
**Example 2:**
**Input:** s = "aaab"
**Output:** ""
**Constraints:**
* ... | Write a helper function to count the number of set bits in a number, then check whether the number of set bits is 2, 3, 5, 7, 11, 13, 17 or 19. | Math,Bit Manipulation | Easy | 191 |
48 | foreign hello everyone and welcome back to another video so today I'm going to be solving the lead code question uh number 48 rotate image all right so over here we're going to be given a n by and two dimensional Matrix which represents an image and the goal is to rotate the image by 90 degrees in the clockwise Directi... | Rotate Image | rotate-image | You are given an `n x n` 2D `matrix` representing an image, rotate the image by **90** degrees (clockwise).
You have to rotate the image [**in-place**](https://en.wikipedia.org/wiki/In-place_algorithm), which means you have to modify the input 2D matrix directly. **DO NOT** allocate another 2D matrix and do the rotati... | null | Array,Math,Matrix | Medium | 2015 |
1,721 | Hello hello guys today we are going to solve the middle challenge the question language shopping note se request what do we have to do if suppose our cake gives everyone and extent the can help you stop this node and awareness of national defense that subscribe and Prominent Personalities From This Point To Our Loot An... | Swapping Nodes in a Linked List | maximum-profit-of-operating-a-centennial-wheel | You are given the `head` of a linked list, and an integer `k`.
Return _the head of the linked list after **swapping** the values of the_ `kth` _node from the beginning and the_ `kth` _node from the end (the list is **1-indexed**)._
**Example 1:**
**Input:** head = \[1,2,3,4,5\], k = 2
**Output:** \[1,4,3,2,5\]
**Ex... | Think simulation Note that the number of turns will never be more than 50 / 4 * n | Array,Simulation | Medium | null |
1,905 | thank you hello guys so yesterday we had already solved this problem count sub Islands but I felt that you know uh there are some modifications some you know more efficient ways to solve this problem hence a new video I hope you don't mind and you would enjoy this so in this video what I'm going to say that let me just... | Count Sub Islands | design-authentication-manager | You are given two `m x n` binary matrices `grid1` and `grid2` containing only `0`'s (representing water) and `1`'s (representing land). An **island** is a group of `1`'s connected **4-directionally** (horizontal or vertical). Any cells outside of the grid are considered water cells.
An island in `grid2` is considered ... | Using a map, track the expiry times of the tokens. When generating a new token, add it to the map with its expiry time. When renewing a token, check if it's on the map and has not expired yet. If so, update its expiry time. To count unexpired tokens, iterate on the map and check for each token if it's not expired yet. | Hash Table,Design | Medium | null |
332 | Hello friends welcome back today we are solving a hard problem reconstruct itinerary we'll start with reading the problem statement and look at some examples to understand the problem and next we'll look at what are oian paths and use high holers algorithm to solve this problem which takes linear time o of e where e is... | 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 |
476 | hello everyone to this question she's number complement given a positive integer output its complement number the complement strategy is flip the bits of binary representation means first we have to convert this digit to its binary and then when its complement now we will understand this in pen and paper so yeah number... | Number Complement | number-complement | The **complement** of an integer is the integer you get when you flip all the `0`'s to `1`'s and all the `1`'s to `0`'s in its binary representation.
* For example, The integer `5` is `"101 "` in binary and its **complement** is `"010 "` which is the integer `2`.
Given an integer `num`, return _its complement_.
**... | null | Bit Manipulation | Easy | null |
299 | hey guys today we're gonna be looking at question 299 elite code called bulls and cows uh it's a fun little question maybe a little bit on the easier side but i think it's interesting nonetheless and we're talking about so let's go through it you are playing the following bulls and cows game with your friend you write ... | Bulls and Cows | bulls-and-cows | You are playing the **[Bulls and Cows](https://en.wikipedia.org/wiki/Bulls_and_Cows)** game with your friend.
You write down a secret number and ask your friend to guess what the number is. When your friend makes a guess, you provide a hint with the following info:
* The number of "bulls ", which are digits in the ... | null | Hash Table,String,Counting | Medium | null |
152 | hello everyone welcome back today we will be solving one liquid question maximum product sub array given an energy array Norms find a sub array that has the largest product and return the product sub array is a contiguous non-empty sequence of the element within non-empty sequence of the element within non-empty sequen... | 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 |
222 | Hello Guys Software Co * C Problem From Hello Guys Software Co * C Problem From Hello Guys Software Co * C Problem From List Code Called Account Number Notes in a Complete Denial Tree O Pure Problem Statement Simple Governor Complete Binary Counter Number of Units So You Must Be Knowing What is the Complete Binary Tree... | Count Complete Tree Nodes | count-complete-tree-nodes | Given the `root` of a **complete** binary tree, return the number of the nodes in the tree.
According to **[Wikipedia](http://en.wikipedia.org/wiki/Binary_tree#Types_of_binary_trees)**, every level, except possibly the last, is completely filled in a complete binary tree, and all nodes in the last level are as far lef... | null | Binary Search,Tree,Depth-First Search,Binary Tree | Medium | 270 |
238 | hey everyone welcome back and let's write some more neat code today so today let's solve product of array except itself so this is another problem from the blind 75 list as you can see it's over here product breaks itself so i'm going to be adding that video solution today and we're getting one step closer to having ev... | Product of Array Except Self | product-of-array-except-self | Given an integer array `nums`, return _an array_ `answer` _such that_ `answer[i]` _is equal to the product of all the elements of_ `nums` _except_ `nums[i]`.
The product of any prefix or suffix of `nums` is **guaranteed** to fit in a **32-bit** integer.
You must write an algorithm that runs in `O(n)` time and without... | null | Array,Prefix Sum | Medium | 42,152,265,2267 |
345 | That Welcome Back Points Today We Are Going To Solve Liquid Problem 2235 Will Travel From This Question Is A Specific In Google Sheets Care And It's Just Click On Over Water Question Description And We Will Discuss How Would Want To Solve This Question To Write Function At Its Cost rings input and reverse only give win... | Reverse Vowels of a String | reverse-vowels-of-a-string | Given a string `s`, reverse only all the vowels in the string and return it.
The vowels are `'a'`, `'e'`, `'i'`, `'o'`, and `'u'`, and they can appear in both lower and upper cases, more than once.
**Example 1:**
**Input:** s = "hello"
**Output:** "holle"
**Example 2:**
**Input:** s = "leetcode"
**Output:** "leotc... | null | Two Pointers,String | Easy | 344,1089 |
211 | hi everyone it's Soren today we have a problem where we need to design a data structure that supports adding a new words and finding a string that matches to the previously added string so basically finding those words so in our case we are going to implement a class word dictionary and it will have two functions add w... | Design Add and Search Words Data Structure | design-add-and-search-words-data-structure | Design a data structure that supports adding new words and finding if a string matches any previously added string.
Implement the `WordDictionary` class:
* `WordDictionary()` Initializes the object.
* `void addWord(word)` Adds `word` to the data structure, it can be matched later.
* `bool search(word)` Returns ... | You should be familiar with how a Trie works. If not, please work on this problem: Implement Trie (Prefix Tree) first. | String,Depth-First Search,Design,Trie | Medium | 208,746 |
207 | Hello hello guys welcome to years and I will be solving dat no problem miding challenge hai mera total number of course you need to take a little from zero to name try minus one sum try mein hai prerequisites for example to take 2012 fast track courts vich Express Repair 2017 Total Number of Voters List of It's Possibl... | Course Schedule | course-schedule | There are a total of `numCourses` courses you have to take, labeled from `0` to `numCourses - 1`. You are given an array `prerequisites` where `prerequisites[i] = [ai, bi]` indicates that you **must** take course `bi` first if you want to take course `ai`.
* For example, the pair `[0, 1]`, indicates that to take cou... | This problem is equivalent to finding if a cycle exists in a directed graph. If a cycle exists, no topological ordering exists and therefore it will be impossible to take all courses. Topological Sort via DFS - A great video tutorial (21 minutes) on Coursera explaining the basic concepts of Topological Sort. Topologica... | Depth-First Search,Breadth-First Search,Graph,Topological Sort | Medium | 210,261,310,630 |
238 | hey guys Greg here and let's solve product of array except self so we're given an integer array nums and we need to return an answer array such that each answer at I is equal to the product of all elements of nums except nums at I and so this spot should be replaced by the multiplication of the other ones which is 2 * ... | Product of Array Except Self | product-of-array-except-self | Given an integer array `nums`, return _an array_ `answer` _such that_ `answer[i]` _is equal to the product of all the elements of_ `nums` _except_ `nums[i]`.
The product of any prefix or suffix of `nums` is **guaranteed** to fit in a **32-bit** integer.
You must write an algorithm that runs in `O(n)` time and without... | null | Array,Prefix Sum | Medium | 42,152,265,2267 |
1,011 | hi everyone in this video we are going to solve a problem the problem is capacity to ship packages within d-days capacity to ship packages within d-days capacity to ship packages within d-days and the problem number is one zero all right so first of all we are going to clearly understand what this problem says after th... | Capacity To Ship Packages Within D Days | flip-binary-tree-to-match-preorder-traversal | A conveyor belt has packages that must be shipped from one port to another within `days` days.
The `ith` package on the conveyor belt has a weight of `weights[i]`. Each day, we load the ship with packages on the conveyor belt (in the order given by `weights`). We may not load more weight than the maximum weight capaci... | null | Tree,Depth-First Search,Binary Tree | Medium | null |
309 | welcome to july's leeco challenge today's problem is best time to buy and sell stock with cooldown say you're given an array for which the ith element is the price of a given stock on day i design an algorithm to find the maximum profit you may complete as many transactions as you like with the following restrictions y... | 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 |
33 | hey what's up guys and quite hear I do testing coding stuff on twitch and YouTube check the description for all my information I do the premium Li code problems on patreon and if you join my discord and reach out to me I try to get back to everyone this is a problem called search in a rotated sorted array it is very si... | 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 |
863 | hey guys this is josh from lead dev where we explain programming questions as simple concise as we can today we'll be talking about the problem o nodes distance k in binary tree this is a popular question asked by amazon facebook and google we're given a binary tree with a root node root a target node and an integer va... | All Nodes Distance K in Binary Tree | sum-of-distances-in-tree | Given the `root` of a binary tree, the value of a target node `target`, and an integer `k`, return _an array of the values of all nodes that have a distance_ `k` _from the target node._
You can return the answer in **any order**.
**Example 1:**
**Input:** root = \[3,5,1,6,2,0,8,null,null,7,4\], target = 5, k = 2
**O... | null | Dynamic Programming,Tree,Depth-First Search,Graph | Hard | 1021,2175 |
1,732 | so this question is question number 1732 find the highest altitude there's a biker going on a road trip the road trip consists of n plus one points at different altitudes the biker starts his trip on point zero with up to equal zero you're given integer array gain of length n where gain i is the net gain in altitude be... | 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 |
461 | okay what's up guys this Isa here and let us continue with the next question of our binary um what is this bit manipulation playlist so next question is the Hamming distance let us read the question so the Hamming distance between two integers is the number of the position at which the corresponding bits are different ... | Hamming Distance | hamming-distance | The [Hamming distance](https://en.wikipedia.org/wiki/Hamming_distance) between two integers is the number of positions at which the corresponding bits are different.
Given two integers `x` and `y`, return _the **Hamming distance** between them_.
**Example 1:**
**Input:** x = 1, y = 4
**Output:** 2
**Explanation:**
1... | null | Bit Manipulation | Easy | 191,477 |
49 | hello and welcome back to the cracking fang youtube channel today we're going to be solving lead code problem number 49 group anagrams let's read the question prompt given an array of string strings group the anagrams together you can return the answer in any order an anagram is a word or phrase formed by rearranging t... | Group Anagrams | group-anagrams | Given an array of strings `strs`, group **the anagrams** together. You can return the answer in **any order**.
An **Anagram** is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.
**Example 1:**
**Input:** strs = \["eat","tea","tan... | null | Hash Table,String,Sorting | Medium | 242,249 |
44 | okay lit code number 44 wildcard matching this task has appeared before in the lead code tasks in the first 10 or 15 something like that the question is pretty much the description is the same as it was before with the minor differences we have a string we have a pattern string and we have to match them now the pattern... | Wildcard Matching | wildcard-matching | Given an input string (`s`) and a pattern (`p`), implement wildcard pattern matching with support for `'?'` and `'*'` where:
* `'?'` Matches any single character.
* `'*'` Matches any sequence of characters (including the empty sequence).
The matching should cover the **entire** input string (not partial).
**Exam... | null | String,Dynamic Programming,Greedy,Recursion | Hard | 10 |
264 | they know that today's li coding challenge question it's called ugly number two we want to write a program to find the ends our claim number the ugly numbers are positive integer numbers whose prime factors only includes a limited number of prime factor numbers 3 2 & 5 so giving example is that we want 2 & 5 so... | Ugly Number II | ugly-number-ii | An **ugly number** is a positive integer whose prime factors are limited to `2`, `3`, and `5`.
Given an integer `n`, return _the_ `nth` _**ugly number**_.
**Example 1:**
**Input:** n = 10
**Output:** 12
**Explanation:** \[1, 2, 3, 4, 5, 6, 8, 9, 10, 12\] is the sequence of the first 10 ugly numbers.
**Example 2:**
... | The naive approach is to call isUgly for every number until you reach the nth one. Most numbers are not ugly. Try to focus your effort on generating only the ugly ones. An ugly number must be multiplied by either 2, 3, or 5 from a smaller ugly number. The key is how to maintain the order of the ugly numbers. Try a simi... | Hash Table,Math,Dynamic Programming,Heap (Priority Queue) | Medium | 23,204,263,279,313,1307 |
5 | what's up everyone sam here from byte by byte calm and in this video I'm going to show you how to implement the longest palindromic substring problem so this is a really popular interview question as well and we're going to date into it right after the intro and if you haven't already make sure you hit that subscribe b... | Longest Palindromic Substring | longest-palindromic-substring | Given a string `s`, return _the longest_ _palindromic_ _substring_ in `s`.
**Example 1:**
**Input:** s = "babad "
**Output:** "bab "
**Explanation:** "aba " is also a valid answer.
**Example 2:**
**Input:** s = "cbbd "
**Output:** "bb "
**Constraints:**
* `1 <= s.length <= 1000`
* `s` consist of only dig... | How can we reuse a previously computed palindrome to compute a larger palindrome? If “aba” is a palindrome, is “xabax” a palindrome? Similarly is “xabay” a palindrome? Complexity based hint:
If we use brute-force and check whether for every start and end position a substring is a palindrome we have O(n^2) start - end ... | String,Dynamic Programming | Medium | 214,266,336,516,647 |
1,091 | hey everybody this is Larry this is me trying to do the first day of June the code daily giant hit the like button hit the Subscribe button drama and Discord let me know what you think um well as long as soon as it loads anyway uh yeah welcome everybody if you haven't watched it uh hopefully yeah uh I'm in Armenia righ... | Shortest Path in Binary Matrix | maximum-average-subtree | Given an `n x n` binary matrix `grid`, return _the length of the shortest **clear path** in the matrix_. If there is no clear path, return `-1`.
A **clear path** in a binary matrix is a path from the **top-left** cell (i.e., `(0, 0)`) to the **bottom-right** cell (i.e., `(n - 1, n - 1)`) such that:
* All the visite... | Can you find the sum of values and the number of nodes for every sub-tree ? Can you find the sum of values and the number of nodes for a sub-tree given the sum of values and the number of nodes of it's left and right sub-trees ? Use depth first search to recursively find the solution for the children of a node then use... | Tree,Depth-First Search,Binary Tree | Medium | 2126 |
1,598 | Hua Hai Abhivan Welcome to my channel it's all the problem and lock folder delete type unlock your times profile change shoulder and subscribe must subscribe thank you are the meaning of the queen 50 Mondays subscribe this Video then subscribe to the Page if you liked The Video then subscribe to the that main folder af... | 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,696 | what is that guys this is somebody on youtube and uh today i'm going to talk about question 1696 on lead code okay so the question is you have known already and i'm not going to spend time doing that okay the way to solve this question is we need to maintain a dp array a integer array that's called dp and what it does ... | 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 |
327 | hello friends today let's talk out of ranges on problem given integer rate numbers we needed to return a number of Renaissance at lying lower upper inclusive range some s IJ is defined as the sum of the elements in numbers between index I and J I less or equal than J inclusive naive algorithm below and squared is tripl... | Count of Range Sum | count-of-range-sum | Given an integer array `nums` and two integers `lower` and `upper`, return _the number of range sums that lie in_ `[lower, upper]` _inclusive_.
Range sum `S(i, j)` is defined as the sum of the elements in `nums` between indices `i` and `j` inclusive, where `i <= j`.
**Example 1:**
**Input:** nums = \[-2,5,-1\], lowe... | null | Array,Binary Search,Divide and Conquer,Binary Indexed Tree,Segment Tree,Merge Sort,Ordered Set | Hard | 315,493 |
561 | hello everyone welcome and welcome back to my Channel today we are going to discuss another problem but before going to forward if you not like the video so please like And subscribe my channel so you will get notified whenever my new video okay so without any further Ado let's start today the question is that array pa... | Array Partition | array-partition-i | Given an integer array `nums` of `2n` integers, group these integers into `n` pairs `(a1, b1), (a2, b2), ..., (an, bn)` such that the sum of `min(ai, bi)` for all `i` is **maximized**. Return _the maximized sum_.
**Example 1:**
**Input:** nums = \[1,4,3,2\]
**Output:** 4
**Explanation:** All possible pairings (ignori... | Obviously, brute force won't help here. Think of something else, take some example like 1,2,3,4. How will you make pairs to get the result? There must be some pattern. Did you observe that- Minimum element gets add into the result in sacrifice of maximum element. Still won't able to find pairs? Sort the array and try t... | Array,Greedy,Sorting,Counting Sort | Easy | 2112,2248,2261 |
367 | so hey everyone now i'm going to discuss the fifth question that is a valid perfect square from the dsa would come basically category binary search and the question is given that we have given a positive integer num and we have to write a function which returns true if the number is opposite is a perfect square else fa... | Valid Perfect Square | valid-perfect-square | Given a positive integer num, return `true` _if_ `num` _is a perfect square or_ `false` _otherwise_.
A **perfect square** is an integer that is the square of an integer. In other words, it is the product of some integer with itself.
You must not use any built-in library function, such as `sqrt`.
**Example 1:**
**In... | null | Math,Binary Search | Easy | 69,633 |
263 | If the error is 16 everywhere, then Aditya, we will solve the problem, the next number in the name of that problem and this problem is the problem number of the court is 203, now we have seen the problem statement, the number is all positivity, definitely ask crime patrol and limited to three and five means next. The n... | Ugly Number | ugly-number | An **ugly number** is a positive integer whose prime factors are limited to `2`, `3`, and `5`.
Given an integer `n`, return `true` _if_ `n` _is an **ugly number**_.
**Example 1:**
**Input:** n = 6
**Output:** true
**Explanation:** 6 = 2 \* 3
**Example 2:**
**Input:** n = 1
**Output:** true
**Explanation:** 1 has n... | null | Math | Easy | 202,204,264 |
1,810 | hello everyone let's take a look at this little problem minimum pass cost in a hidden grid it's a follow-up of grid it's a follow-up of grid it's a follow-up of only code 1778 shortest passing a hidden grid so uh if you have a parentheses problem you can practice it for since they are very similar except that the class... | Minimum Path Cost in a Hidden Grid | change-the-root-of-a-binary-tree | This is an **interactive problem**.
There is a robot in a hidden grid, and you are trying to get it from its starting cell to the target cell in this grid. The grid is of size `m x n`, and each cell in the grid is either empty or blocked. It is **guaranteed** that the starting cell and the target cell are different, a... | Start traversing from the leaf. Always go up till you reach the root. Change pointers as asked, make the current node's parent its left child, and make the left child the right one if needed. | Tree,Depth-First Search,Binary Tree | Medium | null |
70 | hey welcome back today we're going to be doing leode problem 70 climbing stairs and today's solution is going to use something called dynamic programming that's right dynamic programming this concept can be pretty hard to understand so with that being said let's do it together and if you haven't already like And subscr... | Climbing Stairs | climbing-stairs | You are climbing a staircase. It takes `n` steps to reach the top.
Each time you can either climb `1` or `2` steps. In how many distinct ways can you climb to the top?
**Example 1:**
**Input:** n = 2
**Output:** 2
**Explanation:** There are two ways to climb to the top.
1. 1 step + 1 step
2. 2 steps
**Example 2:**
... | To reach nth step, what could have been your previous steps? (Think about the step sizes) | Math,Dynamic Programming,Memoization | Easy | 747,1013,1236 |
303 | foreign mutable given an integer array nums we have to handle multiple queries of the following type we have to calculate the sum of the elements of nums between indices left and right inclusive we have to implement a num array class with the Constructor which initialize the object with the integer array nums and also ... | Range Sum Query - Immutable | range-sum-query-immutable | Given an integer array `nums`, handle multiple queries of the following type:
1. Calculate the **sum** of the elements of `nums` between indices `left` and `right` **inclusive** where `left <= right`.
Implement the `NumArray` class:
* `NumArray(int[] nums)` Initializes the object with the integer array `nums`.
* ... | null | Array,Design,Prefix Sum | Easy | 304,307,325 |
461 | what's up guys welcome back welcome to another coding every question on late code so this question is about Hamming distances so it says the Hamming distance is the distance between two integers is the number of positions at which the corresponding bits are different so given two integers one in X is one and Y is four ... | Hamming Distance | hamming-distance | The [Hamming distance](https://en.wikipedia.org/wiki/Hamming_distance) between two integers is the number of positions at which the corresponding bits are different.
Given two integers `x` and `y`, return _the **Hamming distance** between them_.
**Example 1:**
**Input:** x = 1, y = 4
**Output:** 2
**Explanation:**
1... | null | Bit Manipulation | Easy | 191,477 |
690 | what's up everyone today we're gonna be going over a leak code 690 employee importance now I'm not sure why there were so many downloads for this one but this is a pretty standard BFS grasp graph traversal they give us a custom class that has a ID importance per employee and then a list of integers who are that employe... | Employee Importance | employee-importance | You have a data structure of employee information, including the employee's unique ID, importance value, and direct subordinates' IDs.
You are given an array of employees `employees` where:
* `employees[i].id` is the ID of the `ith` employee.
* `employees[i].importance` is the importance value of the `ith` employ... | null | Hash Table,Depth-First Search,Breadth-First Search | Medium | 339 |
1,980 | hey everyone today we are going to solve theal equation find the unique binary string okay so let me explain with this example so 0 and 01 so my idea is simply to convert these binary strings to decimal because creating and comparing decimal number is easier than creating and comparing binary strings especially creatin... | 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 |
69 | hey guys how's everything going let's take a look at number 69 wow it's a good name for good number right okay that's uh we need to implement our own square root function the X is guaranteed to be non-negative so it might be zero the non-negative so it might be zero the non-negative so it might be zero the result this ... | Sqrt(x) | sqrtx | Given a non-negative integer `x`, return _the square root of_ `x` _rounded down to the nearest integer_. The returned integer should be **non-negative** as well.
You **must not use** any built-in exponent function or operator.
* For example, do not use `pow(x, 0.5)` in c++ or `x ** 0.5` in python.
**Example 1:**
... | Try exploring all integers. (Credits: @annujoshi) Use the sorted property of integers to reduced the search space. (Credits: @annujoshi) | Math,Binary Search | Easy | 50,367 |
235 | to look at a legal problem called lowest common ancestor of a binary search tree so company binary surgery find the lowest common ancestor of two given nodes in the binary search tree so basically we're given a two nodes p and q as the lower lowest note in t that has both p and q right so we want to find the lowest um ... | 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 |
1,786 | hi everyone welcome back to the channel today let's solve a very good question from the weekly contest number of restricted path from first to last note and before we start don't forget to subscribe to my channel i'll be constantly solving good and classic legal questions with clear explanation animation and visualizat... | Number of Restricted Paths From First to Last Node | count-the-number-of-consistent-strings | There is an undirected weighted connected graph. You are given a positive integer `n` which denotes that the graph has `n` nodes labeled from `1` to `n`, and an array `edges` where each `edges[i] = [ui, vi, weighti]` denotes that there is an edge between nodes `ui` and `vi` with weight equal to `weighti`.
A path from ... | A string is incorrect if it contains a character that is not allowed Constraints are small enough for brute force | Array,Hash Table,String,Bit Manipulation | Easy | null |
1,703 | hey everybody this is larry this is me going over q4 of the bi-weekly me going over q4 of the bi-weekly me going over q4 of the bi-weekly contest 42 uh minimum adjacent swaps 4k consecutive ones uh so hit the like button it's a subscriber and join me on this card let me know what you think about this problem uh so the ... | Minimum Adjacent Swaps for K Consecutive Ones | put-boxes-into-the-warehouse-i | You are given an integer array, `nums`, and an integer `k`. `nums` comprises of only `0`'s and `1`'s. In one move, you can choose two **adjacent** indices and swap their values.
Return _the **minimum** number of moves required so that_ `nums` _has_ `k` _**consecutive**_ `1`_'s_.
**Example 1:**
**Input:** nums = \[1,... | Sort the boxes in ascending order, try to process the box with the smallest height first. | Array,Greedy,Sorting | Medium | 1719 |
1,456 | Hai gas welcome and welcome back to my channel so today our problem is maximum number of vowels in a substring of life length so in this problem you have given name one sting s and one ints k given ok you have to find the maximum. Number of vowels latest in other substituting of s with length of so all the possible siz... | Maximum Number of Vowels in a Substring of Given Length | find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance | Given a string `s` and an integer `k`, return _the maximum number of vowel letters in any substring of_ `s` _with length_ `k`.
**Vowel letters** in English are `'a'`, `'e'`, `'i'`, `'o'`, and `'u'`.
**Example 1:**
**Input:** s = "abciiidef ", k = 3
**Output:** 3
**Explanation:** The substring "iii " contains 3 vow... | Use Floyd-Warshall's algorithm to compute any-point to any-point distances. (Or can also do Dijkstra from every node due to the weights are non-negative). For each city calculate the number of reachable cities within the threshold, then search for the optimal city. | Dynamic Programming,Graph,Shortest Path | Medium | 2171 |
957 | Jai hind is problem wear giver nurses us embassy rimi pimples one of these rocks that android desires will wither chaupai like this a prisoner inside and 10th mp3 there inner inside us but rather condition for preserving occupied is given is so is to-do to-do to-do subscribe Both in this will provide a 231 Hello Busy H... | Prison Cells After N Days | minimum-add-to-make-parentheses-valid | There are `8` prison cells in a row and each cell is either occupied or vacant.
Each day, whether the cell is occupied or vacant changes according to the following rules:
* If a cell has two adjacent neighbors that are both occupied or both vacant, then the cell becomes occupied.
* Otherwise, it becomes vacant.
... | null | String,Stack,Greedy | Medium | 2095 |
651 | hey everybody this is Larry this is me doing the weekly premium uh problem uh hit the like button hit the Subscribe button drop me on Discord let me know what you think about this problem uh even if you don't have premium okay so today's spam is 651 for Keys key Point okay let's see if we have a special keyboard with t... | 4 Keys Keyboard | 4-keys-keyboard | Imagine you have a special keyboard with the following keys:
* A: Print one `'A'` on the screen.
* Ctrl-A: Select the whole screen.
* Ctrl-C: Copy selection to buffer.
* Ctrl-V: Print buffer on screen appending it after what has already been printed.
Given an integer n, return _the maximum number of_ `'A'` _y... | null | Math,Dynamic Programming | Medium | 650 |
1,046 | hey guys welcome back to my channel and I'm back again with another really interesting coding interview question video this time guys we are going to solve question number 1046 the last stone weight before I start with the problem statement guys just want to request you that if you have not yet subscribed to my channel... | Last Stone Weight | max-consecutive-ones-iii | You are given an array of integers `stones` where `stones[i]` is the weight of the `ith` stone.
We are playing a game with the stones. On each turn, we choose the **heaviest two stones** and smash them together. Suppose the heaviest two stones have weights `x` and `y` with `x <= y`. The result of this smash is:
* I... | One thing's for sure, we will only flip a zero if it extends an existing window of 1s. Otherwise, there's no point in doing it, right? Think Sliding Window! Since we know this problem can be solved using the sliding window construct, we might as well focus in that direction for hints. Basically, in a given window, we c... | Array,Binary Search,Sliding Window,Prefix Sum | Medium | 340,424,485,487,2134 |
449 | hello everyone welcome to clean coder youtube channel if you are new to this channel i will highly recommend you to subscribe to this channel as i make tutorials related to data structures and algorithms software engineering and system design so today we are going to solve this lead code problem number 449 serialize an... | Serialize and Deserialize BST | serialize-and-deserialize-bst | Serialization is converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection link to be reconstructed later in the same or another computer environment.
Design an algorithm to serialize and deserialize a **binary search t... | null | String,Tree,Depth-First Search,Breadth-First Search,Design,Binary Search Tree,Binary Tree | Medium | 297,652,765 |
1,224 | hello friends firstly Merry Christmas so today let's of 1224 maximum equal frequency we're given array numbers of positive integers when did you return the longest possible length of an array prefix of numbers such that it is possible to remove exactly one element from this prefix so that every number that has appeared... | Maximum Equal Frequency | minimum-falling-path-sum-ii | Given an array `nums` of positive integers, return the longest possible length of an array prefix of `nums`, such that it is possible to remove **exactly one** element from this prefix so that every number that has appeared in it will have the same number of occurrences.
If after removing one element there are no rema... | Use dynamic programming. Let dp[i][j] be the answer for the first i rows such that column j is chosen from row i. Use the concept of cumulative array to optimize the complexity of the solution. | Array,Dynamic Programming,Matrix | Hard | 967 |
1,463 | hey everybody this is Larry I'm doing this problem as part of a contest so you're gonna watch me live as I go through my daughter's I'm coding they've been explanation near the end and for more context they'll be a link below on this actual screen cats of the contest how did you do let me know you do hit the like butto... | Cherry Pickup II | the-k-weakest-rows-in-a-matrix | You are given a `rows x cols` matrix `grid` representing a field of cherries where `grid[i][j]` represents the number of cherries that you can collect from the `(i, j)` cell.
You have two robots that can collect cherries for you:
* **Robot #1** is located at the **top-left corner** `(0, 0)`, and
* **Robot #2** is... | Sort the matrix row indexes by the number of soldiers and then row indexes. | Array,Binary Search,Sorting,Heap (Priority Queue),Matrix | Easy | null |
872 | Hi gas welcome and welcome back tu my channel so today our problem is live similar trees so in this problem statement mein humse kya de rakha hai hume yahan pe na do binary tree ka root note de rakha hai root van end root tu humme kya karna hai Here we have to check whether the leaf note in both the binary trees is you... | Leaf-Similar Trees | split-array-into-fibonacci-sequence | Consider all the leaves of a binary tree, from left to right order, the values of those leaves form a **leaf value sequence**_._
For example, in the given tree above, the leaf value sequence is `(6, 7, 4, 9, 8)`.
Two binary trees are considered _leaf-similar_ if their leaf value sequence is the same.
Return `true` i... | null | String,Backtracking | Medium | 306,1013 |
1,020 | everyone welcome back to the channel and thank you from lead code to any challenge problem number 1020 number of employees so uh you know we will just skip this part and I'll explain you the problem using this example so basically what we'll have to do is we have to figure out the number of ones in this given Matrix wh... | Number of Enclaves | longest-turbulent-subarray | You are given an `m x n` binary matrix `grid`, where `0` represents a sea cell and `1` represents a land cell.
A **move** consists of walking from one land cell to another adjacent (**4-directionally**) land cell or walking off the boundary of the `grid`.
Return _the number of land cells in_ `grid` _for which we cann... | null | Array,Dynamic Programming,Sliding Window | Medium | 53 |
338 | hey guys how's it going in this video i'm gonna go through his legal number 338 counting bit this problem is less as easy but i don't think that's so easy of a problem i think it's a bit tricky actually um this problem was asked by google and adobe in the past six months so what this is asking is to count the number on... | 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 |
386 | hello welcome to the new video today we're going to solve this problem called let's go graphical numbers 386 it is a medium probably code and I did solve already but I would like to Showcase of like how I kind of solved it and my problem solving process um so yeah let's just get right into it um so we have it I already... | Lexicographical Numbers | lexicographical-numbers | Given an integer `n`, return all the numbers in the range `[1, n]` sorted in lexicographical order.
You must write an algorithm that runs in `O(n)` time and uses `O(1)` extra space.
**Example 1:**
**Input:** n = 13
**Output:** \[1,10,11,12,13,2,3,4,5,6,7,8,9\]
**Example 2:**
**Input:** n = 2
**Output:** \[1,2\]
*... | null | Depth-First Search,Trie | Medium | null |
1,992 | hello everyone welcome to coding culture this channel will contain those programs whose explanation is either not present on youtube or the explanation is present but not up to the mark so without wasting time let's get started so this is a new question of the lead code and it appears in the bi-weekly contest of it app... | Find All Groups of Farmland | sort-linked-list-already-sorted-using-absolute-values | You are given a **0-indexed** `m x n` binary matrix `land` where a `0` represents a hectare of forested land and a `1` represents a hectare of farmland.
To keep the land organized, there are designated rectangular areas of hectares that consist **entirely** of farmland. These rectangular areas are called **groups**. N... | The nodes with positive values are already in the correct order. Nodes with negative values need to be moved to the front. Nodes with negative values are in reversed order. | Linked List,Two Pointers,Sorting | Medium | 148 |
304 | all right let's talk about rinse some curry 2d immutable so given a metric 2d matrix so you just have to calculate the sum of the elementary inside the rectangle defined by its upper left corner and lower right corner so this is like you have to define in the entry and this is from upper left to lower right so two one ... | 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 |
1,413 | hey everybody this is larry this is day 11 of the leeco daily challenge hit the like button the subscribe button join me on discord let me know what you think about today's problem is minimum value to get positive step by step sum so what does that mean uh it means you should hit the like button to subscribe and join m... | Minimum Value to Get Positive Step by Step Sum | maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold | Given an array of integers `nums`, you start with an initial **positive** value _startValue__._
In each iteration, you calculate the step by step sum of _startValue_ plus elements in `nums` (from left to right).
Return the minimum **positive** value of _startValue_ such that the step by step sum is never less than 1.... | Store prefix sum of all grids in another 2D array. Try all possible solutions and if you cannot find one return -1. If x is a valid answer then any y < x is also valid answer. Use binary search to find answer. | Array,Binary Search,Matrix,Prefix Sum | Medium | null |
1,342 | Hello Hi Guys Welcome To Our Dhundhi See The Question Number Of Video then subscribe to the obscene take into account only to condition with numbers even lord will take anti through bill account Speech will initially be 200 and will look like number is grated ginger roll number 201 number with 12 number is award and so... | Number of Steps to Reduce a Number to Zero | queens-that-can-attack-the-king | Given an integer `num`, return _the number of steps to reduce it to zero_.
In one step, if the current number is even, you have to divide it by `2`, otherwise, you have to subtract `1` from it.
**Example 1:**
**Input:** num = 14
**Output:** 6
**Explanation:**
Step 1) 14 is even; divide by 2 and obtain 7.
Step 2) 7... | Check 8 directions around the King. Find the nearest queen in each direction. | Array,Matrix,Simulation | Medium | null |
309 | Everyone welcome to my channel, so go ahead, we are going to do question number 10 of the playlist and the name of the question is Best time to buy and sell stock with cool down period, a little notification has been done, general stock, there are many variations, okay so What did Google do by adding another different ... | 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 |
830 | Hello, today we will solve a simple problem of position 8, position 10, and there is no sub yet. What we are given in this problem is a string consisting of only lowercase letters, except for the word Es. In this string, consecutive characters like this are the same character. It's a problem of finding something that a... | Positions of Large Groups | largest-triangle-area | In a string `s` of lowercase letters, these letters form consecutive groups of the same character.
For example, a string like `s = "abbxxxxzyy "` has the groups `"a "`, `"bb "`, `"xxxx "`, `"z "`, and `"yy "`.
A group is identified by an interval `[start, end]`, where `start` and `end` denote the start and end indice... | null | Array,Math,Geometry | Easy | 1018 |
1,512 | hello guys and welcome back to the video so today we look at the problem name number of good pairs so given the array here you have to find a good pair which is when your number is equal and the index is i less than j for example this one when you look through the array one two three four this one is equal right and th... | Number of Good Pairs | design-underground-system | Given an array of integers `nums`, return _the number of **good pairs**_.
A pair `(i, j)` is called _good_ if `nums[i] == nums[j]` and `i` < `j`.
**Example 1:**
**Input:** nums = \[1,2,3,1,1,3\]
**Output:** 4
**Explanation:** There are 4 good pairs (0,3), (0,4), (3,4), (2,5) 0-indexed.
**Example 2:**
**Input:** nu... | Use two hash tables. The first to save the check-in time for a customer and the second to update the total time between two stations. | Hash Table,String,Design | Medium | 2285 |
1,685 | So Hello Friends Welcome Back In This Video Here In This Channel Equal In Solid Appeared In The Weekly Contact Problem To Anil Zinc Voice Mail Third 400 The Problem Is States Of Water Harvesting And Are Presented In This Feeling Order Which Means That Deposited In Increasing Oil Import Skin Every Possibility of Increas... | Sum of Absolute Differences in a Sorted Array | stone-game-v | You are given an integer array `nums` sorted in **non-decreasing** order.
Build and return _an integer array_ `result` _with the same length as_ `nums` _such that_ `result[i]` _is equal to the **summation of absolute differences** between_ `nums[i]` _and all the other elements in the array._
In other words, `result[i... | We need to try all possible divisions for the current row to get the max score. As calculating all possible divisions will lead us to calculate some sub-problems more than once, we need to think of dynamic programming. | Array,Math,Dynamic Programming,Game Theory | Hard | 909,1240,1522,1617,1788,1808,2002,2156 |
1,312 | hey so welcome back and there's another daily code problem so today it was a dynamic programming one and it's called minimum insertion steps to make a string pound drone and it's a harder level problem and so what you're given here is a string s it just has some number of characters and so once again you just want to d... | Minimum Insertion Steps to Make a String Palindrome | count-artifacts-that-can-be-extracted | Given a string `s`. In one step you can insert any character at any index of the string.
Return _the minimum number of steps_ to make `s` palindrome.
A **Palindrome String** is one that reads the same backward as well as forward.
**Example 1:**
**Input:** s = "zzazz "
**Output:** 0
**Explanation:** The string "zz... | Check if each coordinate of each artifact has been excavated. How can we do this quickly without iterating over the dig array every time? Consider marking all excavated cells in a 2D boolean array. | Array,Hash Table,Simulation | Medium | 221 |
86 | hello everyone welcome to coders camp and today we are the 14th day of april lead code challenge and the problem we are going to cover is partition list so the input given here is a head of a linked list and an integer variable x where x point at the partition of the linked list we have to arrange the elements in such ... | Partition List | partition-list | Given the `head` of a linked list and a value `x`, partition it such that all nodes **less than** `x` come before nodes **greater than or equal** to `x`.
You should **preserve** the original relative order of the nodes in each of the two partitions.
**Example 1:**
**Input:** head = \[1,4,3,2,5,2\], x = 3
**Output:**... | null | Linked List,Two Pointers | Medium | 2265 |
5 | so i'm going to show you an easy way to solve this little problem that says the longest palindromic substring so given a string s return the longest palindromic substring in a so the easy way to solve it of course there are different ways uh the easier most the easiest most efficient way to solve it is use is to use th... | Longest Palindromic Substring | longest-palindromic-substring | Given a string `s`, return _the longest_ _palindromic_ _substring_ in `s`.
**Example 1:**
**Input:** s = "babad "
**Output:** "bab "
**Explanation:** "aba " is also a valid answer.
**Example 2:**
**Input:** s = "cbbd "
**Output:** "bb "
**Constraints:**
* `1 <= s.length <= 1000`
* `s` consist of only dig... | How can we reuse a previously computed palindrome to compute a larger palindrome? If “aba” is a palindrome, is “xabax” a palindrome? Similarly is “xabay” a palindrome? Complexity based hint:
If we use brute-force and check whether for every start and end position a substring is a palindrome we have O(n^2) start - end ... | String,Dynamic Programming | Medium | 214,266,336,516,647 |
1,690 | hey what's up guys this is chung here so this time let's take a look at this one 1690 stone game number seven i believe so another stone game so alice and bob take turns playing a game with alice starting first so this is another like game problem and for this problem there are end stones arranged in a row and each pla... | Stone Game VII | maximum-length-of-subarray-with-positive-product | Alice and Bob take turns playing a game, with **Alice starting first**.
There are `n` stones arranged in a row. On each player's turn, they can **remove** either the leftmost stone or the rightmost stone from the row and receive points equal to the **sum** of the remaining stones' values in the row. The winner is the ... | Split the whole array into subarrays by zeroes since a subarray with positive product cannot contain any zero. If the subarray has even number of negative numbers, the whole subarray has positive product. Otherwise, we have two choices, either - remove the prefix till the first negative element in this subarray, or rem... | Array,Dynamic Programming,Greedy | Medium | null |
122 | is persistent programmer here and welcome to my channel so in this channel we solve a lot of algos and go through a lot of legal questions so if you haven't subscribed already go ahead and hit that subscribe button under this video and let's go ahead and get started today with our question best time to buy and sell sto... | Best Time to Buy and Sell Stock II | best-time-to-buy-and-sell-stock-ii | You are given an integer array `prices` where `prices[i]` is the price of a given stock on the `ith` day.
On each day, you may decide to buy and/or sell the stock. You can only hold **at most one** share of the stock at any time. However, you can buy it then immediately sell it on the **same day**.
Find and return _t... | null | Array,Dynamic Programming,Greedy | Medium | 121,123,188,309,714 |
88 | hi guys in the video merge two SED lead one of the least important problem let's get AR a so n plus m equal to X so X log of x in the intu is not going to work for us next okay crein so next we found out we are going to use three pointers poin was thir question9 in same 4 problem so it's not a problem going to same thr... | Merge Sorted Array | merge-sorted-array | You are given two integer arrays `nums1` and `nums2`, sorted in **non-decreasing order**, and two integers `m` and `n`, representing the number of elements in `nums1` and `nums2` respectively.
**Merge** `nums1` and `nums2` into a single array sorted in **non-decreasing order**.
The final sorted array should not be re... | You can easily solve this problem if you simply think about two elements at a time rather than two arrays. We know that each of the individual arrays is sorted. What we don't know is how they will intertwine. Can we take a local decision and arrive at an optimal solution? If you simply consider one element each at a ti... | Array,Two Pointers,Sorting | Easy | 21,1019,1028 |
530 | hey everybody this is Larry this is me doing the uh leeco daily child day 14 uh yeah hit the like button hit the Subscribe button join me on Discord let me know what you think about today's pop and also hope you enjoyed the drum video as I've been trying to do them as I am traveling I am currently at a city of Albany u... | 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,921 | hey everybody this is larry this is me going over q2 of the weekly contest 248 on lead code obviously you eliminate maximum number of monsters hit the like button hit the subscribe button join me on discord give me a little support because i had tears over this one really should have been i feel like should have been e... | Eliminate Maximum Number of Monsters | eliminate-maximum-number-of-monsters | You are playing a video game where you are defending your city from a group of `n` monsters. You are given a **0-indexed** integer array `dist` of size `n`, where `dist[i]` is the **initial distance** in kilometers of the `ith` monster from the city.
The monsters walk toward the city at a **constant** speed. The speed... | null | null | Medium | null |
495 | hello everyone in today's video we will see lead quot problem 495 Teo attacking and it is a easy problem so in this problem uh there's a hero called Teemo and he's attacking an enemy ASE with a poison attack and it is said that uh the Ash gets poisoned for exactly duration second duration is a second so he's getting af... | Teemo Attacking | teemo-attacking | Our hero Teemo is attacking an enemy Ashe with poison attacks! When Teemo attacks Ashe, Ashe gets poisoned for a exactly `duration` seconds. More formally, an attack at second `t` will mean Ashe is poisoned during the **inclusive** time interval `[t, t + duration - 1]`. If Teemo attacks again **before** the poison effe... | null | Array,Simulation | Easy | 56,605,649 |
415 | hey everyone welcome back and today we'll be doing another lead code 415 add to string given to non-negative integers to string given to non-negative integers to string given to non-negative integers num1 and num2 represent it as strange rate and the sum of num1 and num2 as a string you must solve the problem without u... | Add Strings | add-strings | Given two non-negative integers, `num1` and `num2` represented as string, return _the sum of_ `num1` _and_ `num2` _as a string_.
You must solve the problem without using any built-in library for handling large integers (such as `BigInteger`). You must also not convert the inputs to integers directly.
**Example 1:**
... | null | Math,String,Simulation | Easy | 2,43,1031 |
54 | hello everybody this is Edie today we're going to go through a LICO challenge your favorite spiral matrix problem so the instructions are as follows given a matrix of n by n elements return all elements of the matrix in spiral order let's illustrate this problem on our interactive whiteboard / paintbrush interactive wh... | Spiral Matrix | spiral-matrix | Given an `m x n` `matrix`, return _all elements of the_ `matrix` _in spiral order_.
**Example 1:**
**Input:** matrix = \[\[1,2,3\],\[4,5,6\],\[7,8,9\]\]
**Output:** \[1,2,3,6,9,8,7,4,5\]
**Example 2:**
**Input:** matrix = \[\[1,2,3,4\],\[5,6,7,8\],\[9,10,11,12\]\]
**Output:** \[1,2,3,4,8,12,11,10,9,5,6,7\]
**Const... | Well for some problems, the best way really is to come up with some algorithms for simulation. Basically, you need to simulate what the problem asks us to do. We go boundary by boundary and move inwards. That is the essential operation. First row, last column, last row, first column and then we move inwards by 1 and th... | Array,Matrix,Simulation | Medium | 59,921 |
36 | hey guys Greg here let's solve valid sidoku so our job is to determine if a 9x9 sodoku board is valid and only the filled cells need to be validated according to the following rules so basically each row column and the nine 3x3 subboxes of the grid they must contain the digits 1 to 9 without any repetition and these no... | Valid Sudoku | valid-sudoku | Determine if a `9 x 9` Sudoku board is valid. Only the filled cells need to be validated **according to the following rules**:
1. Each row must contain the digits `1-9` without repetition.
2. Each column must contain the digits `1-9` without repetition.
3. Each of the nine `3 x 3` sub-boxes of the grid must contain... | null | Array,Hash Table,Matrix | Medium | 37,2254 |
1,630 | hi everyone today we are going to solve the Ral equation arithmetic subarrays okay so first of all description said we need to keep this formula so what does this formula mean so this means um all two adjacent numbers are same difference so let's say we have three and five so in this case what is the next number if we ... | Arithmetic Subarrays | count-odd-numbers-in-an-interval-range | A sequence of numbers is called **arithmetic** if it consists of at least two elements, and the difference between every two consecutive elements is the same. More formally, a sequence `s` is arithmetic if and only if `s[i+1] - s[i] == s[1] - s[0]` for all valid `i`.
For example, these are **arithmetic** sequences:
1... | If the range (high - low + 1) is even, the number of even and odd numbers in this range will be the same. If the range (high - low + 1) is odd, the solution will depend on the parity of high and low. | Math | Easy | null |
399 | hello and welcome back to decoding here we discuss problems which are frequently asked in programming interviews and try to build a step-by-step solution to build a step-by-step solution to build a step-by-step solution to those problems of course discussing this space at the time complexity today we're here with a pro... | Evaluate Division | evaluate-division | You are given an array of variable pairs `equations` and an array of real numbers `values`, where `equations[i] = [Ai, Bi]` and `values[i]` represent the equation `Ai / Bi = values[i]`. Each `Ai` or `Bi` is a string that represents a single variable.
You are also given some `queries`, where `queries[j] = [Cj, Dj]` rep... | Do you recognize this as a graph problem? | Array,Depth-First Search,Breadth-First Search,Union Find,Graph,Shortest Path | Medium | null |
1,833 | hey everybody this is larry this is me going with q2 of the weekly contest 237 maximum ice cream bars so this one's a little bit weird to be honest my first instinct when i saw this uh was dynamic programming uh so hit the like button the subscriber and join me on discord let me know what you think but it turns out tha... | Maximum Ice Cream Bars | find-the-highest-altitude | It is a sweltering summer day, and a boy wants to buy some ice cream bars.
At the store, there are `n` ice cream bars. You are given an array `costs` of length `n`, where `costs[i]` is the price of the `ith` ice cream bar in coins. The boy initially has `coins` coins to spend, and he wants to buy as many ice cream bar... | Let's note that the altitude of an element is the sum of gains of all the elements behind it Getting the altitudes can be done by getting the prefix sum array of the given array | Array,Prefix Sum | Easy | null |
713 | hey guys welcome back to another video and today we're going to be solving the lead cloud question sub area product less than k all right so in this question we're given an array of positive integers called nums and when we count and print the number of contiguous sub areas where the product of all the elements in the ... | Subarray Product Less Than K | subarray-product-less-than-k | Given an array of integers `nums` and an integer `k`, return _the number of contiguous subarrays where the product of all the elements in the subarray is strictly less than_ `k`.
**Example 1:**
**Input:** nums = \[10,5,2,6\], k = 100
**Output:** 8
**Explanation:** The 8 subarrays that have product less than 100 are:
... | For each j, let opt(j) be the smallest i so that nums[i] * nums[i+1] * ... * nums[j] is less than k. opt is an increasing function. | Array,Sliding Window | Medium | 152,325,560,1083,2233 |
342 | hello everyone Aaron here and welcome back to leaked code today we are doing the power of four problem given an integer n return true if it is a power of four otherwise return false and enter N is a power of four if there exists an integer X such that n is equal to x 4 to the power of x so here we say 16 is 4 squared 5... | Power of Four | power-of-four | Given an integer `n`, return _`true` if it is a power of four. Otherwise, return `false`_.
An integer `n` is a power of four, if there exists an integer `x` such that `n == 4x`.
**Example 1:**
**Input:** n = 16
**Output:** true
**Example 2:**
**Input:** n = 5
**Output:** false
**Example 3:**
**Input:** n = 1
**O... | null | Math,Bit Manipulation,Recursion | Easy | 231,326 |
1,481 | Welcome to my channel code Sorry with Mike So today we are going to do video number 27 of Greedy's playlist. Okay lead is marked number 1481 medium but will make it quite easy. Three different approachable number of unique int's after removals means you will get a You have to find the least number of unique integers af... | Least Number of Unique Integers after K Removals | students-with-invalid-departments | Given an array of integers `arr` and an integer `k`. Find the _least number of unique integers_ after removing **exactly** `k` elements**.**
**Example 1:**
**Input:** arr = \[5,5,4\], k = 1
**Output:** 1
**Explanation**: Remove the single 4, only 5 is left.
**Example 2:**
**Input:** arr = \[4,3,1,1,3,3,2\], k = 3
*... | null | Database | Easy | null |
343 | welcome to joey's tech in this video of my dynamic programming tutorial we'll look into the integer break problem which i have taken from the lead code website you can find the link in the description box below this video i found this problem really interesting and what makes it more interesting is that we can solve it... | Integer Break | integer-break | Given an integer `n`, break it into the sum of `k` **positive integers**, where `k >= 2`, and maximize the product of those integers.
Return _the maximum product you can get_.
**Example 1:**
**Input:** n = 2
**Output:** 1
**Explanation:** 2 = 1 + 1, 1 \* 1 = 1.
**Example 2:**
**Input:** n = 10
**Output:** 36
**Exp... | There is a simple O(n) solution to this problem. You may check the breaking results of n ranging from 7 to 10 to discover the regularities. | Math,Dynamic Programming | Medium | 1936 |
45 | everyone welcome back and let's write some more neat code today so today let's solve jump game two so you might remember recently we solved the first jump game problem and i would recommend watching that video or solving that problem yourself before looking at this one because this one is actually very similar the main... | Jump Game II | jump-game-ii | You are given a **0-indexed** array of integers `nums` of length `n`. You are initially positioned at `nums[0]`.
Each element `nums[i]` represents the maximum length of a forward jump from index `i`. In other words, if you are at `nums[i]`, you can jump to any `nums[i + j]` where:
* `0 <= j <= nums[i]` and
* `i +... | null | Array,Dynamic Programming,Greedy | Medium | 55,1428,2001 |
52 | hey everybody this is larry this is day five the june nico day challenge hit the like button hit the subscribe button join me on discord let me know what you think about today's farm okay uh that's weird right isn't it um this is literally like yesterday's form but now we have to do the count instead um in theory there... | N-Queens II | n-queens-ii | The **n-queens** puzzle is the problem of placing `n` queens on an `n x n` chessboard such that no two queens attack each other.
Given an integer `n`, return _the number of distinct solutions to the **n-queens puzzle**_.
**Example 1:**
**Input:** n = 4
**Output:** 2
**Explanation:** There are two distinct solutions ... | null | Backtracking | Hard | 51 |
35 | hi guys and welcome again to my channel in today's video i'm gonna start um a new series uh in which i will be solving uh in each video like uh one lead code problem and i'm going to show you how i'm going to explain the question for you and we're going to solve it together uh also like just to mention that lead code 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 |
297 | hello friends today wealth of serialize and deserialize binary tree okay actually the problem asked us to use a string to represent a binary tree and then we convert that string to banner tree again so that's the two functions well we call it a civilized actuaries convert tree note the two string another function is th... | Serialize and Deserialize Binary Tree | serialize-and-deserialize-binary-tree | Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection link to be reconstructed later in the same or another computer environment.
Design an algorithm to serialize and deserialize a bi... | null | String,Tree,Depth-First Search,Breadth-First Search,Design,Binary Tree | Hard | 271,449,652,765 |
482 | hey everyone welcome back and today I'll be doing another delete code 482 license key formatting and easy one you are given a license key represented as string s that consists of only alpha numeric characters and dashes the string is separated into n plus one groups by n dashes you are also given an integer K we want t... | License Key Formatting | license-key-formatting | You are given a license key represented as a string `s` that consists of only alphanumeric characters and dashes. The string is separated into `n + 1` groups by `n` dashes. You are also given an integer `k`.
We want to reformat the string `s` such that each group contains exactly `k` characters, except for the first g... | null | String | Easy | null |
269 | hello welcome to my channel today we have leeco 269 alien dictionary and this question is rated as hard but it's really uh helpful for learning the algorithm let's take a look at this question so there's a new alien language that use english alphabet however the order amount of letter is unknown to you so basically say... | Alien Dictionary | alien-dictionary | There is a new alien language that uses the English alphabet. However, the order among the letters is unknown to you.
You are given a list of strings `words` from the alien language's dictionary, where the strings in `words` are **sorted lexicographically** by the rules of this new language.
Return _a string of the u... | null | Array,String,Depth-First Search,Breadth-First Search,Graph,Topological Sort | Hard | 210 |
38 | hello everyone welcome to learn overflow in this video we'll discuss another electric problem that is the count inside this is a middle level problem and we will understand how we can solve this question easily and by understanding the question better so before moving on if you haven't subscribed to this channel make s... | Count and Say | count-and-say | The **count-and-say** sequence is a sequence of digit strings defined by the recursive formula:
* `countAndSay(1) = "1 "`
* `countAndSay(n)` is the way you would "say " the digit string from `countAndSay(n-1)`, which is then converted into a different digit string.
To determine how you "say " a digit string, spli... | The following are the terms from n=1 to n=10 of the count-and-say sequence:
1. 1
2. 11
3. 21
4. 1211
5. 111221
6. 312211
7. 13112221
8. 1113213211
9. 31131211131221
10. 13211311123113112211 To generate the nth term, just count and say the n-1th term. | String | Medium | 271,443 |
171 | hi everyone in this video we will be solving another lead code problem excel sheet column number so we are given with a string called column title that represents the column title that appears in excel sheet and we has to return the corresponding column number so this is the example a is the first column b is the secon... | Excel Sheet Column Number | excel-sheet-column-number | Given a string `columnTitle` that represents the column title as appears in an Excel sheet, return _its corresponding column number_.
For example:
A -> 1
B -> 2
C -> 3
...
Z -> 26
AA -> 27
AB -> 28
...
**Example 1:**
**Input:** columnTitle = "A "
**Output:** 1
**Example 2:**
**Input:** columnTitle = "AB "
**Ou... | null | Math,String | Easy | 168,2304 |
1,463 | hey what's up guys chung here again so today I want to talk about another at least called problem here 1463 cherry peak number two hard problem okay so let's take a look at this problem description so you're given like a 2d matrix here great with rows and columns and then you have two robots so one robot starts from th... | Cherry Pickup II | the-k-weakest-rows-in-a-matrix | You are given a `rows x cols` matrix `grid` representing a field of cherries where `grid[i][j]` represents the number of cherries that you can collect from the `(i, j)` cell.
You have two robots that can collect cherries for you:
* **Robot #1** is located at the **top-left corner** `(0, 0)`, and
* **Robot #2** is... | Sort the matrix row indexes by the number of soldiers and then row indexes. | Array,Binary Search,Sorting,Heap (Priority Queue),Matrix | Easy | null |
823 | Hello Everyone Welcome to Date 30th March Switzerland Today's Question is My Negative Effects Lips Try to Understand the Problem Faith in this Question Was Given You Character of Winners in the Form of Energy and Order in Tears in the Tarzan Wonder Means Numbers and Positive Nature and Greater Than What Do We Need To M... | Binary Trees With Factors | split-array-with-same-average | Given an array of unique integers, `arr`, where each integer `arr[i]` is strictly greater than `1`.
We make a binary tree using these integers, and each number may be used for any number of times. Each non-leaf node's value should be equal to the product of the values of its children.
Return _the number of binary tre... | null | Array,Math,Dynamic Programming,Bit Manipulation,Bitmask | Hard | 2162 |
45 | All this has happened Frustrated Hello Guys Anurag website so basically you see back with other site questions and questions the question is jump game two and hard category question the question is easy but there is a scene of complexity in it if like this then turn off the mode If you do, then it is a very easy questi... | Jump Game II | jump-game-ii | You are given a **0-indexed** array of integers `nums` of length `n`. You are initially positioned at `nums[0]`.
Each element `nums[i]` represents the maximum length of a forward jump from index `i`. In other words, if you are at `nums[i]`, you can jump to any `nums[i + j]` where:
* `0 <= j <= nums[i]` and
* `i +... | null | Array,Dynamic Programming,Greedy | Medium | 55,1428,2001 |
397 | hey what's up guys this is chung here so this time let's take a look at lead called problem number 397 integer replacement so given like a positive integer and you can apply one of the following two options the first one is that if n is an even number you can replace the n with m divided by two basically if that is an ... | 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,227 | welcome guys so today we want to talk about is called the airplane seats assignment uh probability so this problem is really famous in uh the brain teaser and the interview okay so i also personally got this uh same problems okay in the interview question so let me teach you how to solve it very quickly okay so this is... | Airplane Seat Assignment Probability | number-of-equivalent-domino-pairs | `n` passengers board an airplane with exactly `n` seats. The first passenger has lost the ticket and picks a seat randomly. But after that, the rest of the passengers will:
* Take their own seat if it is still available, and
* Pick other seats randomly when they find their seat occupied
Return _the probability th... | For each domino j, find the number of dominoes you've already seen (dominoes i with i < j) that are equivalent. You can keep track of what you've seen using a hashmap. | Array,Hash Table,Counting | Easy | null |
906 | hey everybody this is larry this is day eight of the may league daily challenge first day of the second week hit the like button to subscribe or enjoy me on discord let me know what you think uh and it's mother's day weekend here in the us so happy mother's day do your mother's out there but anyway uh today's problem i... | Super Palindromes | walking-robot-simulation | Let's say a positive integer is a **super-palindrome** if it is a palindrome, and it is also the square of a palindrome.
Given two positive integers `left` and `right` represented as strings, return _the number of **super-palindromes** integers in the inclusive range_ `[left, right]`.
**Example 1:**
**Input:** left ... | null | Array,Simulation | Medium | 2178 |
377 | welcome to april's legal challenge today's problem is combination sum four given an array of distinct integers and a target integer target return the number of possible combinations that add up to target the numbers guaranteed to fit in a third two bit integer we're given a list of numbers that are all going to be dist... | Combination Sum IV | combination-sum-iv | Given an array of **distinct** integers `nums` and a target integer `target`, return _the number of possible combinations that add up to_ `target`.
The test cases are generated so that the answer can fit in a **32-bit** integer.
**Example 1:**
**Input:** nums = \[1,2,3\], target = 4
**Output:** 7
**Explanation:**
Th... | null | Array,Dynamic Programming | Medium | 39 |
1,945 | hello so this question is sum of digits of Str after convert so you basically you give it the string and then you convert to the integer so I represent 99 and then the K represent how many um like iteration of addition you're going to have so when K to one you just know do it once if k equal to two so when you got the ... | Sum of Digits of String After Convert | finding-the-users-active-minutes | You are given a string `s` consisting of lowercase English letters, and an integer `k`.
First, **convert** `s` into an integer by replacing each letter with its position in the alphabet (i.e., replace `'a'` with `1`, `'b'` with `2`, ..., `'z'` with `26`). Then, **transform** the integer by replacing it with the **sum ... | Try to find the number of different minutes when action happened for each user. For each user increase the value of the answer array index which matches the UAM for this user. | Array,Hash Table | Medium | null |
338 | Hello guys welcome back to take devotion in this video you will see accounting this problem wishes from list dated 28th challenge 16 personal problem statement the problems the giver negativity born for every number white range of do to calculate the number of waves in the Representation And Toys For Example In To-Do L... | 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 |
108 | hello everyone welcome back to the channel today we are going to do convert sorted array to binary search tree let's understand the question first then we'll move to the approach given an integer array nums where the elements are sorted in ascending order convert it to a height balanced binary search tree a height bala... | Convert Sorted Array to Binary Search Tree | convert-sorted-array-to-binary-search-tree | Given an integer array `nums` where the elements are sorted in **ascending order**, convert _it to a_ **_height-balanced_** _binary search tree_.
**Example 1:**
**Input:** nums = \[-10,-3,0,5,9\]
**Output:** \[0,-3,9,-10,null,5\]
**Explanation:** \[0,-10,5,null,-3,null,9\] is also accepted:
**Example 2:**
**Input... | null | Array,Divide and Conquer,Tree,Binary Search Tree,Binary Tree | Easy | 109 |
1,402 | Do that Awadhi kaise saare berry lover point welcome recharge nakul help we have reached but number 181 maximum has been reached here we are broken heart problem if I say then don't be afraid we want to say hard that today EMP Such problems of 2002 BDP which have been hot marked on the lead are going to solve this diff... | Reducing Dishes | count-square-submatrices-with-all-ones | A chef has collected data on the `satisfaction` level of his `n` dishes. Chef can cook any dish in 1 unit of time.
**Like-time coefficient** of a dish is defined as the time taken to cook that dish including previous dishes multiplied by its satisfaction level i.e. `time[i] * satisfaction[i]`.
Return _the maximum sum... | Create an additive table that counts the sum of elements of submatrix with the superior corner at (0,0). Loop over all subsquares in O(n^3) and check if the sum make the whole array to be ones, if it checks then add 1 to the answer. | Array,Dynamic Programming,Matrix | Medium | 2192,2193 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.