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 |
|---|---|---|---|---|---|---|---|---|
485 | Hello guys welcome to new video I hope you all are well. In the last lecture we had found out the missing number in an array. If you have not seen that video then you can check it out by going to the link description in today's video. We are solving a new problem. It is easy level, it is a good problem, it is a simple ... | Max Consecutive Ones | max-consecutive-ones | Given a binary array `nums`, return _the maximum number of consecutive_ `1`_'s in the array_.
**Example 1:**
**Input:** nums = \[1,1,0,1,1,1\]
**Output:** 3
**Explanation:** The first two digits or the last three digits are consecutive 1s. The maximum number of consecutive 1s is 3.
**Example 2:**
**Input:** nums = ... | You need to think about two things as far as any window is concerned. One is the starting point for the window. How do you detect that a new window of 1s has started? The next part is detecting the ending point for this window.
How do you detect the ending point for an existing window? If you figure these two things... | Array | Easy | 487,1046,1542,1999 |
1,499 | hey what's up guys this is chung here so uh today i would like to talk about this uh 1499 max value of equation this is a hard problem but i think this is a good one okay so let's take a look you're given like an array a list of points containing the coordinates of a point on a 2d point plane here which is the x i and ... | Max Value of Equation | maximum-performance-of-a-team | You are given an array `points` containing the coordinates of points on a 2D plane, sorted by the x-values, where `points[i] = [xi, yi]` such that `xi < xj` for all `1 <= i < j <= points.length`. You are also given an integer `k`.
Return _the maximum value of the equation_ `yi + yj + |xi - xj|` where `|xi - xj| <= k` ... | Keep track of the engineers by their efficiency in decreasing order. Starting from one engineer, to build a team, it suffices to bring K-1 more engineers who have higher efficiencies as well as high speeds. | Array,Greedy,Sorting,Heap (Priority Queue) | Hard | 2229 |
424 | hello welcome to my Channel today we are going to solve lead code problem 424 longest repeating character replacement so this means we are giving us 3s and we are also giving a integral T this key means we can exchange K integers for example this is a b we can exchange the B to a another B to a and then we're going to ... | Longest Repeating Character Replacement | longest-repeating-character-replacement | You are given a string `s` and an integer `k`. You can choose any character of the string and change it to any other uppercase English character. You can perform this operation at most `k` times.
Return _the length of the longest substring containing the same letter you can get after performing the above operations_.
... | null | Hash Table,String,Sliding Window | Medium | 340,1046,2119,2134,2319 |
3 | let's take a look at leap code question three longest substring without repeating characters and this is a great question to practice your string algorithms even a string s find the length of the longest substring without repeating characters and then we have this note a substring is a contiguous non-empty a substring ... | Longest Substring Without Repeating Characters | longest-substring-without-repeating-characters | Given a string `s`, find the length of the **longest** **substring** without repeating characters.
**Example 1:**
**Input:** s = "abcabcbb "
**Output:** 3
**Explanation:** The answer is "abc ", with the length of 3.
**Example 2:**
**Input:** s = "bbbbb "
**Output:** 1
**Explanation:** The answer is "b ", with t... | null | Hash Table,String,Sliding Window | Medium | 159,340,1034,1813,2209 |
43 | foreign list multiply strings you will be given with two non-native you will be given with two non-native you will be given with two non-native integers M1 and M2 representing as strings and return the product of these two numbers also represented as a string so here you can see that here number one is two number two i... | Multiply Strings | multiply-strings | Given two non-negative integers `num1` and `num2` represented as strings, return the product of `num1` and `num2`, also represented as a string.
**Note:** You must not use any built-in BigInteger library or convert the inputs to integer directly.
**Example 1:**
**Input:** num1 = "2", num2 = "3"
**Output:** "6"
**Ex... | null | Math,String,Simulation | Medium | 2,66,67,415 |
20 | in this video we'll be going over Elite code question number 20. valid parentheses we're given a string that consists of six different characters the opening and closing parentheses square brackets and curly braces given this string we have to return true if the string is valid and false if it's invalid now the problem... | Valid Parentheses | valid-parentheses | Given a string `s` containing just the characters `'('`, `')'`, `'{'`, `'}'`, `'['` and `']'`, determine if the input string is valid.
An input string is valid if:
1. Open brackets must be closed by the same type of brackets.
2. Open brackets must be closed in the correct order.
3. Every close bracket has a corres... | An interesting property about a valid parenthesis expression is that a sub-expression of a valid expression should also be a valid expression. (Not every sub-expression) e.g.
{ { } [ ] [ [ [ ] ] ] } is VALID expression
[ [ [ ] ] ] is VALID sub-expression
{ } [ ] is VALID sub-express... | String,Stack | Easy | 22,32,301,1045,2221 |
1,201 | coat fell you're one ugly number three the problem is that write a program to find an ugly number ugly numbers are defined as positive integers which are due to rise above by a party or see here's an example of help and you could a threeway you have a pc he would to signify how to find those sweet number the right iran... | Ugly Number III | delete-tree-nodes | An **ugly number** is a positive integer that is divisible by `a`, `b`, or `c`.
Given four integers `n`, `a`, `b`, and `c`, return the `nth` **ugly number**.
**Example 1:**
**Input:** n = 3, a = 2, b = 3, c = 5
**Output:** 4
**Explanation:** The ugly numbers are 2, 3, 4, 5, 6, 8, 9, 10... The 3rd is 4.
**Example 2:... | Traverse the tree using depth first search. Find for every node the sum of values of its sub-tree. Traverse the tree again from the root and return once you reach a node with zero sum of values in its sub-tree. | Tree,Depth-First Search,Breadth-First Search | Medium | null |
1,751 | hi folks let's stop maximum number of events that can be attended too it's actually a hard problem so we are given an array of events the event has a study and an ending the value and we can choose at most k events and they cannot be overlapped it asks us to give the maximum value we can get so there are some examples ... | Maximum Number of Events That Can Be Attended II | slowest-key | You are given an array of `events` where `events[i] = [startDayi, endDayi, valuei]`. The `ith` event starts at `startDayi` and ends at `endDayi`, and if you attend this event, you will receive a value of `valuei`. You are also given an integer `k` which represents the maximum number of events you can attend.
You can o... | Get for each press its key and amount of time taken. Iterate on the presses, maintaining the answer so far. The current press will change the answer if and only if its amount of time taken is longer than that of the previous answer, or they are equal but the key is larger than that of the previous answer. | Array,String | Easy | null |
835 | in this problem we are given two binary images so by binary we mean that their pixels are either zero or one values and these are square images so uh width is same as height and we have two images so you can see one of them is a one of them is b and uh you are allowed to shift one image over other you can also keep it ... | Image Overlap | linked-list-components | You are given two images, `img1` and `img2`, represented as binary, square matrices of size `n x n`. A binary matrix has only `0`s and `1`s as values.
We **translate** one image however we choose by sliding all the `1` bits left, right, up, and/or down any number of units. We then place it on top of the other image. W... | null | Hash Table,Linked List | Medium | 2299 |
93 | video I will be discussing about lead code problem number 93 that is restore IP addresses in this problem you are given a string and you have to produce all the strings that have a valid IP address so you have to insert three dots in the string and it will form IP address you have to check whether it is valid or not fo... | Restore IP Addresses | restore-ip-addresses | A **valid IP address** consists of exactly four integers separated by single dots. Each integer is between `0` and `255` (**inclusive**) and cannot have leading zeros.
* For example, `"0.1.2.201 "` and `"192.168.1.1 "` are **valid** IP addresses, but `"0.011.255.245 "`, `"192.168.1.312 "` and `"192.168@1.1 "` are **... | null | String,Backtracking | Medium | 752 |
1,880 | That welcome back to my channel so today we are going to discuss the problem of elite contest 243 in the morning the problem is this check in wordy total summation of two words so this is easy problem Meena so what to do in this why do we need the first word you like friend Rickshaw convert is a string and a target is ... | Check if Word Equals Summation of Two Words | largest-merge-of-two-strings | The **letter value** of a letter is its position in the alphabet **starting from 0** (i.e. `'a' -> 0`, `'b' -> 1`, `'c' -> 2`, etc.).
The **numerical value** of some string of lowercase English letters `s` is the **concatenation** of the **letter values** of each letter in `s`, which is then **converted** into an inte... | Build the result character by character. At each step, you choose a character from one of the two strings. If the next character of the first string is larger than that of the second string, or vice versa, it's optimal to use the larger one. If both are equal, think of a criteria that lets you decide which string to co... | Two Pointers,String,Greedy | Medium | null |
338 | all right so this is lead code 338 counting bits um so it says given an integer n return the array uh return an array answer of length n plus 1 such that for each I uh I is going to be uh greater than or equal to zero and it's also going to be less than or equal to n um in that instance every basically every value is t... | Counting Bits | counting-bits | Given an integer `n`, return _an array_ `ans` _of length_ `n + 1` _such that for each_ `i` (`0 <= i <= n`)_,_ `ans[i]` _is the **number of**_ `1`_**'s** in the binary representation of_ `i`.
**Example 1:**
**Input:** n = 2
**Output:** \[0,1,1\]
**Explanation:**
0 --> 0
1 --> 1
2 --> 10
**Example 2:**
**Input:** n =... | You should make use of what you have produced already. Divide the numbers in ranges like [2-3], [4-7], [8-15] and so on. And try to generate new range from previous. Or does the odd/even status of the number help you in calculating the number of 1s? | Dynamic Programming,Bit Manipulation | Easy | 191 |
1,750 | Hello Hi Friends Welcome Back Today We Are Going To Solve Their Problems 1715 Minimum Balance Offspring After Deleting Similar Lines Subha Purvi Gurudev Description And Through The Examples For I Just Want To Mention That My Channel Focus Is On Helping People While Preparing For Coding In Service And Jawa Interview Sun... | 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 |
498 | hey everybody this is larry this is december 25th under uh so happy holidays of christmas whatever you like to celebrate uh hit the like button hit the subscribe button join me on discord let me know what you think about today's prom diagonal traverse i do solve this live so it may be a little bit slow on the solution ... | Diagonal Traverse | diagonal-traverse | Given an `m x n` matrix `mat`, return _an array of all the elements of the array in a diagonal order_.
**Example 1:**
**Input:** mat = \[\[1,2,3\],\[4,5,6\],\[7,8,9\]\]
**Output:** \[1,2,4,7,5,3,6,8,9\]
**Example 2:**
**Input:** mat = \[\[1,2\],\[3,4\]\]
**Output:** \[1,2,3,4\]
**Constraints:**
* `m == mat.leng... | null | Array,Matrix,Simulation | Medium | 2197 |
91 | hey what's up guys this is chung here so um let's take a look at today's daily challenge problem number 91 d called waze so i mean this one is one of those very classic dp problem you know okay basically you're given like uh a string of digits okay and each letter each digit represents might represent one of the uh the... | Decode Ways | decode-ways | A message containing letters from `A-Z` can be **encoded** into numbers using the following mapping:
'A' -> "1 "
'B' -> "2 "
...
'Z' -> "26 "
To **decode** an encoded message, all the digits must be grouped then mapped back into letters using the reverse of the mapping above (there may be multiple ways). For examp... | null | String,Dynamic Programming | Medium | 639,2091 |
926 | hi everyone welcome back my name is in this video we will try to solve this question uh flip string to a monotone increasing this question is basically from lead code and it is question number 926 basically this question involves dynamic programming but we will try to see its solution without dynamic programming and we... | 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 |
442 | in this video we're gonna solve this coding interview question find all duplicates in an array this is the problem statement in this problem given an integer array nums of length in where all the integers of nums are in the range inclusive from 1 to n this is the range and is integer appears once or twice written an ar... | 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 |
228 | hey guys welcome back to another video and today we're going to be solving the leak code question summary ranges you are so in this question we're given a sorted unique integer area called nums so what we want to do is we want to return the smallest sorted list of ranges that cover all the numbers in the array exactly ... | Summary Ranges | summary-ranges | You are given a **sorted unique** integer array `nums`.
A **range** `[a,b]` is the set of all integers from `a` to `b` (inclusive).
Return _the **smallest sorted** list of ranges that **cover all the numbers in the array exactly**_. That is, each element of `nums` is covered by exactly one of the ranges, and there is... | null | Array | Easy | 163,352 |
47 | hello guys I'm back right we figured out um fortnite one and um we figured out was a couple of different solutions supposedly I've attempted quite a few Solutions so we did figure this out yeah we had a look there was you know all these different you know solutions to it and uh I'm gonna go through that in another vide... | Permutations II | permutations-ii | Given a collection of numbers, `nums`, that might contain duplicates, return _all possible unique permutations **in any order**._
**Example 1:**
**Input:** nums = \[1,1,2\]
**Output:**
\[\[1,1,2\],
\[1,2,1\],
\[2,1,1\]\]
**Example 2:**
**Input:** nums = \[1,2,3\]
**Output:** \[\[1,2,3\],\[1,3,2\],\[2,1,3\],\[2,3,... | null | Array,Backtracking | Medium | 31,46,267,1038 |
992 | Hello everyone and welcome back to my channel Algorithm H K Today I am going to write the code and also explain to you all the algorithm to solve all this is with different integers problem which is there on lead code it is a hard level problem And we are going to solve this using sliding window and two pointer approac... | Subarrays with K Different Integers | delete-columns-to-make-sorted-ii | Given an integer array `nums` and an integer `k`, return _the number of **good subarrays** of_ `nums`.
A **good array** is an array where the number of different integers in that array is exactly `k`.
* For example, `[1,2,3,1,2]` has `3` different integers: `1`, `2`, and `3`.
A **subarray** is a **contiguous** par... | null | Array,String,Greedy | Medium | null |
198 | hello guys and welcome back to lead Logics this is the House robber problem from lead code this is the lead Cod medium and the number for this is98 so in this problem we are given with a professional robber planning to rob houses along the street and each house had a certain amount of money stashed in it and the only c... | House Robber | house-robber | You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security systems connected and **it will automatically contact the police if two adjacent houses were broken into... | null | Array,Dynamic Programming | Medium | 152,213,256,276,337,600,656,740,2262 |
326 | Will hand over to everyone welcome back so friend this was our problem 24th August so we see that this power of three lights which we have seen behind the problem of power off and so this is similar to it just in this we started checking onem this power of three four note So in that we used to check whether it is power... | Power of Three | power-of-three | Given an integer `n`, return _`true` if it is a power of three. Otherwise, return `false`_.
An integer `n` is a power of three, if there exists an integer `x` such that `n == 3x`.
**Example 1:**
**Input:** n = 27
**Output:** true
**Explanation:** 27 = 33
**Example 2:**
**Input:** n = 0
**Output:** false
**Explanat... | null | Math,Recursion | Easy | 231,342,1889 |
318 | how are you Well now I'm going to try to explain this code challenge Not that code challenge that actually has been put as medium but I could see it as a little complicated no because at first glance it seems easy No but it appears in quotes easy No but when you really break it down you find that there is a certain dif... | Maximum Product of Word Lengths | maximum-product-of-word-lengths | Given a string array `words`, return _the maximum value of_ `length(word[i]) * length(word[j])` _where the two words do not share common letters_. If no such two words exist, return `0`.
**Example 1:**
**Input:** words = \[ "abcw ", "baz ", "foo ", "bar ", "xtfn ", "abcdef "\]
**Output:** 16
**Explanation:** The two ... | null | Array,String,Bit Manipulation | Medium | null |
41 | foreign is called First missing positive we are given an unsorted integer array called nums and we have to return the smallest missing positive integer we have to implement an algorithm that runs in linear time and we cannot create any additional space so we our space complexity should be constant now for the first exa... | First Missing Positive | first-missing-positive | Given an unsorted integer array `nums`, return the smallest missing positive integer.
You must implement an algorithm that runs in `O(n)` time and uses constant extra space.
**Example 1:**
**Input:** nums = \[1,2,0\]
**Output:** 3
**Explanation:** The numbers in the range \[1,2\] are all in the array.
**Example 2:*... | Think about how you would solve the problem in non-constant space. Can you apply that logic to the existing space? We don't care about duplicates or non-positive integers Remember that O(2n) = O(n) | Array,Hash Table | Hard | 268,287,448,770 |
1,815 | hey what's up guys uh this is chung here so today um number 1815 maximum number of groups getting fresh donuts um this one is a quite difficult problem so basically you're given like uh a groups of people right so and there's a donut shop that bakes donuts in the batch and batches of the batch size right and then they ... | Maximum Number of Groups Getting Fresh Donuts | checking-existence-of-edge-length-limited-paths | There is a donuts shop that bakes donuts in batches of `batchSize`. They have a rule where they must serve **all** of the donuts of a batch before serving any donuts of the next batch. You are given an integer `batchSize` and an integer array `groups`, where `groups[i]` denotes that there is a group of `groups[i]` cust... | All the queries are given in advance. Is there a way you can reorder the queries to avoid repeated computations? | Array,Union Find,Graph,Sorting | Hard | 1865 |
1,198 | That's what has happened Hello friends this Ramkumar Mantri welcome to our channel fitness Guru group Next question read smallest element in all row from this matrix rights given so during number of Research Institute of Management in subscribe and what is the smallest subscribe list number 198 subscribe The Road Eleme... | Find Smallest Common Element in All Rows | unpopular-books | Given an `m x n` matrix `mat` where every row is sorted in **strictly** **increasing** order, return _the **smallest common element** in all rows_.
If there is no common element, return `-1`.
**Example 1:**
**Input:** mat = \[\[1,2,3,4,5\],\[2,4,5,8,10\],\[3,5,7,9,11\],\[1,3,5,7,9\]\]
**Output:** 5
**Example 2:**
... | null | Database | Medium | null |
1,824 | all right let's do lead code have i done this question no okay oh looks lots of text i don't like lots of texts there are three lane through the invert of what there's a three lane word of length n that consists of n plus one points level zero to n okay a frog starts at point zero in second lane and wants to jump to po... | Minimum Sideway Jumps | maximum-number-of-eaten-apples | There is a **3 lane road** of length `n` that consists of `n + 1` **points** labeled from `0` to `n`. A frog **starts** at point `0` in the **second** lane and wants to jump to point `n`. However, there could be obstacles along the way.
You are given an array `obstacles` of length `n + 1` where each `obstacles[i]` (**... | It's optimal to finish the apples that will rot first before those that will rot last You need a structure to keep the apples sorted by their finish time | Array,Greedy,Heap (Priority Queue) | Medium | null |
1,575 | Hello everyone welcome you are going to me channel 42 ok and as always I also start watching the playlist of starting questions if you want to understand DP from scratch ok and code service mic is available in Facebook Instagram you can check date out Liquid number 1575, this question is not at all hard from any angle,... | Count All Possible Routes | maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts | You are given an array of **distinct** positive integers locations where `locations[i]` represents the position of city `i`. You are also given integers `start`, `finish` and `fuel` representing the starting city, ending city, and the initial amount of fuel you have, respectively.
At each step, if you are at city `i`,... | Sort the arrays, then compute the maximum difference between two consecutive elements for horizontal cuts and vertical cuts. The answer is the product of these maximum values in horizontal cuts and vertical cuts. | Array,Greedy,Sorting | Medium | null |
82 | Hello Hi Everyone Welcome To My Channel It's All The Problem Remove Duplicates From Shot At Least Two-Thirds Of Life Problem Shot At Least Two-Thirds Of Life Problem Shot At Least Two-Thirds Of Life Problem Of Remove Duplicates From Tip Toe Give This Liquid Will Not Difficult Number Only Distance From The Original On R... | 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 |
326 | um hello so today we are going to do this problem called power of three which is part of fleet code daily challenge um so the problem says we get a number n and we wanna return true if it's a power of three false otherwise um and so power of 3 just means that n is equal to 3 to the power of x for some value of x um yea... | Power of Three | power-of-three | Given an integer `n`, return _`true` if it is a power of three. Otherwise, return `false`_.
An integer `n` is a power of three, if there exists an integer `x` such that `n == 3x`.
**Example 1:**
**Input:** n = 27
**Output:** true
**Explanation:** 27 = 33
**Example 2:**
**Input:** n = 0
**Output:** false
**Explanat... | null | Math,Recursion | Easy | 231,342,1889 |
1,557 | Hello hi guys we will be doing minimum number of questions but it's to-read call minimum number of questions but it's to-read call minimum number of questions but it's to-read call log production makes questions and it seems to be difficult for us but so you language of launching its tradition reflects that way Bagru s... | Minimum Number of Vertices to Reach All Nodes | check-if-a-string-contains-all-binary-codes-of-size-k | Given a **directed acyclic graph**, with `n` vertices numbered from `0` to `n-1`, and an array `edges` where `edges[i] = [fromi, toi]` represents a directed edge from node `fromi` to node `toi`.
Find _the smallest set of vertices from which all nodes in the graph are reachable_. It's guaranteed that a unique solution ... | We need only to check all sub-strings of length k. The number of distinct sub-strings should be exactly 2^k. | Hash Table,String,Bit Manipulation,Rolling Hash,Hash Function | Medium | null |
279 | hey everyone welcome back and let's write some more neat code today so today let's solve perfect squares this is going to be a dynamic programming problem and it's pretty similar to the problem coin change which i've already solved and i would say that this is a very similar problem to coin change it's nearly identical... | Perfect Squares | perfect-squares | Given an integer `n`, return _the least number of perfect square numbers that sum to_ `n`.
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. For example, `1`, `4`, `9`, and `16` are perfect squares while `3` and `11` are not.
**Example ... | null | Math,Dynamic Programming,Breadth-First Search | Medium | 204,264 |
1,773 | hey guys ben here so today i'm going to talk about question 1773 english code count items matching the rule see how we can approach this problem so given this a list of list items so basically it's like this list of lists and whatever string low key and your value so what i want to do is let's look at example so basica... | Count Items Matching a Rule | percentage-of-users-attended-a-contest | You are given an array `items`, where each `items[i] = [typei, colori, namei]` describes the type, color, and name of the `ith` item. You are also given a rule represented by two strings, `ruleKey` and `ruleValue`.
The `ith` item is said to match the rule if **one** of the following is true:
* `ruleKey == "type "` ... | null | Database | Easy | 1338 |
1,796 | Show More Hello Friends Today I Will Have To Solve This 1796 Question Of The White Tiger Technologist Visit In Aaf Dekhre Ko Mili To Question Subscribe This Channel Printer Input Festival Shab-O-Roz Ajay 10 Solution Of This Question Just Only For The Learning How To Code This Question Solution With Multiple Subscribe I... | Second Largest Digit in a String | correct-a-binary-tree | Given an alphanumeric string `s`, return _the **second largest** numerical digit that appears in_ `s`_, or_ `-1` _if it does not exist_.
An **alphanumeric** string is a string consisting of lowercase English letters and digits.
**Example 1:**
**Input:** s = "dfa12321afd "
**Output:** 2
**Explanation:** The digits t... | If you traverse the tree from right to left, the invalid node will point to a node that has already been visited. | Hash Table,Tree,Depth-First Search,Breadth-First Search,Binary Tree | Medium | 114,766 |
208 | Hello hello guys welcome back to back division in this video you will see how to implement it differs from digit code for the match challenge so let's not look at the problem statement the problems but they need to implement right to information adhvansh sex to S2 subscribe The Channel Please subscribe and subscribe th... | Implement Trie (Prefix Tree) | implement-trie-prefix-tree | A [**trie**](https://en.wikipedia.org/wiki/Trie) (pronounced as "try ") or **prefix tree** is a tree data structure used to efficiently store and retrieve keys in a dataset of strings. There are various applications of this data structure, such as autocomplete and spellchecker.
Implement the Trie class:
* `Trie()` ... | null | Hash Table,String,Design,Trie | Medium | 211,642,648,676,1433,1949 |
116 | Hello friends welcome to my YouTube channel I am Kumar Singh so and difficult series what will you pick up question family like a job portal where questions on daily basis with vipin question will go through the algorithm in turn will decide the issue heart Samai question mein hai Ramoli and modifications of ok leader ... | 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 |
1,057 | hey everybody this is Larry this is me forgetting to do week one of the Leo da challenge so or weekly challenge premium challenge hit the like button hit the Subscribe button join me on Discord let me know what you think about today's farm and I'm still in koshima uh you can see from my shadow that I don't my lighting ... | Campus Bikes | numbers-with-repeated-digits | On a campus represented on the X-Y plane, there are `n` workers and `m` bikes, with `n <= m`.
You are given an array `workers` of length `n` where `workers[i] = [xi, yi]` is the position of the `ith` worker. You are also given an array `bikes` of length `m` where `bikes[j] = [xj, yj]` is the position of the `jth` bike... | How many numbers with no duplicate digits? How many numbers with K digits and no duplicates? How many numbers with same length as N? How many numbers with same prefix as N? | Math,Dynamic Programming | Hard | null |
350 | hello friends in today's video we are going to discuss lead code problem intersection of two rs part two we will also discuss its part one after this problem is done any problem what you have to do you are given two integers are in numbers and numbers too and we have to written an array of their intersection such that ... | Intersection of Two Arrays II | intersection-of-two-arrays-ii | Given two integer arrays `nums1` and `nums2`, return _an array of their intersection_. Each element in the result must appear as many times as it shows in both arrays and you may return the result in **any order**.
**Example 1:**
**Input:** nums1 = \[1,2,2,1\], nums2 = \[2,2\]
**Output:** \[2,2\]
**Example 2:**
**I... | null | Array,Hash Table,Two Pointers,Binary Search,Sorting | Easy | 349,1044,1392,2282 |
39 | hey guys let's take a look at number 39 combination Sun we're given a set of candidate numbers without duplicates and let's target I'm target find all unique combinations of candidates where they sum up to target the same repeating number may be chosen from candidates for the for example 2 3 6 7 taki 7 of course 7 coul... | 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,721 | hey everyone welcome back today we are going to see problem number 1721 swapping notes in a linked list first we will see the expression of the problem statement then the logic and the code now let's dive into the solution so here I've taken the first example from the lake website so we are given a linked list where we... | 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 |
790 | Hello friends welcome back tu de stylish code youtube channel so today our question is a medium level problem of late code isko aur usko given hoga tu types of tile tu cross van domino app like agar hum baat ka board of question like tu agar hamara If there is a van then our boat I think will be like this. If there is ... | Domino and Tromino Tiling | global-and-local-inversions | You have two types of tiles: a `2 x 1` domino shape and a tromino shape. You may rotate these shapes.
Given an integer n, return _the number of ways to tile an_ `2 x n` _board_. Since the answer may be very large, return it **modulo** `109 + 7`.
In a tiling, every square must be covered by a tile. Two tilings are dif... | Where can the 0 be placed in an ideal permutation? What about the 1? | Array,Math | Medium | null |
1,091 | and welcome back to the cracking fang youtube channel today we're going to be solving lead code problem 1091 shortest path in a binary matrix before we jump into this problem i just want to ask you please to subscribe to my channel i have a goal of hitting 1 000 subscribers by the end of may and i need your help to get... | 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 |
482 | hi guys this is Nikesh here so today I'm back with an another Google interview problem so the problem name is license key formatting so in this problem you have been given instinct yes and it is okay this thing is something like this so if you can observe the string has been divided into n plus 1 pipes by n number of d... | 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 |
1,269 | all right let's take a look at elite code 1269 number of ways to stay in the same place after some steps so we're given in a steps so the number of moves or turns we can take and then a length of the array that we're working with and then our goal is to return the number of ways there are to stay at index zero so we st... | Number of Ways to Stay in the Same Place After Some Steps | market-analysis-ii | You have a pointer at index `0` in an array of size `arrLen`. At each step, you can move 1 position to the left, 1 position to the right in the array, or stay in the same place (The pointer should not be placed outside the array at any time).
Given two integers `steps` and `arrLen`, return the number of ways such that... | null | Database | Hard | null |
965 | hello everyone so in this video let us talk about an easy problem from lead code the problem name is uni valued binary so you are given a binary tree and you just have to check that whether it is uni valued which means that all the nodes have the same value now you can check it out it's very simple you just do a whatev... | Univalued Binary Tree | unique-email-addresses | A binary tree is **uni-valued** if every node in the tree has the same value.
Given the `root` of a binary tree, return `true` _if the given tree is **uni-valued**, or_ `false` _otherwise._
**Example 1:**
**Input:** root = \[1,1,1,1,1,null,1\]
**Output:** true
**Example 2:**
**Input:** root = \[2,2,2,5,2\]
**Outpu... | null | Array,Hash Table,String | Easy | null |
23 | hello and welcome back to the cracking fan YouTube channel today we're going to be solving lead code problem number 23 merge case sorted lists before we do I just want to ask if you're enjoying the content please leave a like and a comment it really helps me out with the YouTube algorithm and a subscription really help... | Merge k Sorted Lists | merge-k-sorted-lists | You are given an array of `k` linked-lists `lists`, each linked-list is sorted in ascending order.
_Merge all the linked-lists into one sorted linked-list and return it._
**Example 1:**
**Input:** lists = \[\[1,4,5\],\[1,3,4\],\[2,6\]\]
**Output:** \[1,1,2,3,4,4,5,6\]
**Explanation:** The linked-lists are:
\[
1->4... | null | Linked List,Divide and Conquer,Heap (Priority Queue),Merge Sort | Hard | 21,264 |
1,403 | Hello Hi Guys How Are You I Hollywood Doing Good Welcome To The Land Cruiser Gai 100 Dushman Ko Turnoff And Playlist Saudi Se Minimal Subsequently Interact On Increasing Order Qualification I Hope You Are Also Doing So Doing His Words From Website Traffic In This Before Proceeding If You R YouTube Channel Please Like S... | Minimum Subsequence in Non-Increasing Order | palindrome-partitioning-iii | Given the array `nums`, obtain a subsequence of the array whose sum of elements is **strictly greater** than the sum of the non included elements in such subsequence.
If there are multiple solutions, return the subsequence with **minimum size** and if there still exist multiple solutions, return the subsequence with t... | For each substring calculate the minimum number of steps to make it palindrome and store it in a table. Create a dp(pos, cnt) which means the minimum number of characters changed for the suffix of s starting on pos splitting the suffix on cnt chunks. | String,Dynamic Programming | Hard | 1871 |
766 | hello don't want to miss today's upload so i'm going to set this to easy it's getting late i swear i've done this okay i haven't toplets matrix given the n by n times n matrix return true if the matrix is toplets otherwise return false i measures toe splits if every diagonal from top left to bottom right has the same e... | Toeplitz Matrix | flatten-a-multilevel-doubly-linked-list | Given an `m x n` `matrix`, return _`true` if the matrix is Toeplitz. Otherwise, return `false`._
A matrix is **Toeplitz** if every diagonal from top-left to bottom-right has the same elements.
**Example 1:**
**Input:** matrix = \[\[1,2,3,4\],\[5,1,2,3\],\[9,5,1,2\]\]
**Output:** true
**Explanation:**
In the above gr... | null | Linked List,Depth-First Search,Doubly-Linked List | Medium | 114,1796 |
448 | all right this is leak code 448 find all numbers disappeared in an array in javascript essentially uh what they're asking to do is look through this array of numbers and find the numbers that should be in the sequence that aren't so in this case going from 1 to 7 there's no five and there's no six so the way that i did... | Find All Numbers Disappeared in an Array | find-all-numbers-disappeared-in-an-array | Given an array `nums` of `n` integers where `nums[i]` is in the range `[1, n]`, return _an array of all the integers in the range_ `[1, n]` _that do not appear in_ `nums`.
**Example 1:**
**Input:** nums = \[4,3,2,7,8,2,3,1\]
**Output:** \[5,6\]
**Example 2:**
**Input:** nums = \[1,1\]
**Output:** \[2\]
**Constrain... | This is a really easy problem if you decide to use additional memory. For those trying to write an initial solution using additional memory, think counters! However, the trick really is to not use any additional space than what is already available to use. Sometimes, multiple passes over the input array help find the s... | Array,Hash Table | Easy | 41,442,2107,2305 |
108 | Hello Hi Everyone Welcome To My Channel It's All The Problem Convert A Shot At Least To Minor Research Service Problem Do Facebook Microsoft Interview Language Problem In Terms Of Knowledge And Subscribe Key Request To All Notes Values In Celebs Ko Request To All Notes Values In Celebs Ko Request To All Notes Value... | 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 |
105 | welcome back to our Jess today's question is leak code105 construct binary tree from pre-order and in order binary tree from pre-order and in order binary tree from pre-order and in order traversal so given two integer arrays pre-order and in order where pre-order pre-order and in order where pre-order pre-order and in... | 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 |
22 | Hello guys welcome to another video Nasbi everything suggestion or any problem generate balance thing with him from let's get started share and subscribe function generate something all combination of wealth from paralysis pluto example think one person generate even more special thing so let's see how Can They Reduce ... | Generate Parentheses | generate-parentheses | Given `n` pairs of parentheses, write a function to _generate all combinations of well-formed parentheses_.
**Example 1:**
**Input:** n = 3
**Output:** \["((()))","(()())","(())()","()(())","()()()"\]
**Example 2:**
**Input:** n = 1
**Output:** \["()"\]
**Constraints:**
* `1 <= n <= 8` | null | String,Dynamic Programming,Backtracking | Medium | 17,20,2221 |
1,921 | hi everyone let's solve today's daily challenge that is eliminate maximum number of monsters so in this question uh it is said that you are playing a video game right where you're defending your City from a group of n monsters and here an AR disc of size n is given to you and distoy is what it is the initial distance i... | 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 |
1,616 | Hello Hi Everyone Welcome To My Channel In This Video Will Fall Key Problem So To Speak To Make Paper Enron So Posted Key Problem Statement Opportunity Shoulder Basic The Problem Is Given Two Strings In This Can Be Split String Exams Page Subscribe Video subscribe The Channel Please subscribe and subscribe A Plus A Suf... | Split Two Strings to Make Palindrome | minimum-difference-between-largest-and-smallest-value-in-three-moves | You are given two strings `a` and `b` of the same length. Choose an index and split both strings **at the same index**, splitting `a` into two strings: `aprefix` and `asuffix` where `a = aprefix + asuffix`, and splitting `b` into two strings: `bprefix` and `bsuffix` where `b = bprefix + bsuffix`. Check if `aprefix + bs... | The minimum difference possible is is obtained by removing 3 elements between the 3 smallest and 3 largest values in the array. | Array,Greedy,Sorting | Medium | null |
1,723 | hey what's up guys this is jung so this time 1723 find the minimum time to finish all jobs so you're given like an integer array jobs and where jobs i is the amount of time it takes to complete the ice job and you're also given like a case work k workers that you can assign jobs to and each job should be assigned to ex... | Find Minimum Time to Finish All Jobs | maximum-number-of-achievable-transfer-requests | You are given an integer array `jobs`, where `jobs[i]` is the amount of time it takes to complete the `ith` job.
There are `k` workers that you can assign jobs to. Each job should be assigned to **exactly** one worker. The **working time** of a worker is the sum of the time it takes to complete all jobs assigned to th... | Think brute force When is a subset of requests okay? | Array,Backtracking,Bit Manipulation,Enumeration | Hard | null |
336 | welcome to june 13th leco challenge palindrome pairs given a list of unique words return all the pairs of distinct indices i j in the given list so that the concatenation of the two words worded i and worded jay is a palindrome so let's go to our first example here so let's see we have um all right let's go we have a w... | Palindrome Pairs | palindrome-pairs | You are given a **0-indexed** array of **unique** strings `words`.
A **palindrome pair** is a pair of integers `(i, j)` such that:
* `0 <= i, j < words.length`,
* `i != j`, and
* `words[i] + words[j]` (the concatenation of the two strings) is a palindrome.
Return _an array of all the **palindrome pairs** of_ `... | null | Array,Hash Table,String,Trie | Hard | 5,214,2237 |
474 | Jhaal Hello Viewers Welcome Tak Bharat Middling Question Adhir Van subscribe and subscribe And subscribe The Amazing Loot-Loot It's More Vinod The Amazing Loot-Loot It's More Vinod The Amazing Loot-Loot It's More Vinod Kushwah How To Find Largest Subscribe Button Adhir Way Possible Loot Subscribe subscribe this Video g... | Ones and Zeroes | ones-and-zeroes | You are given an array of binary strings `strs` and two integers `m` and `n`.
Return _the size of the largest subset of `strs` such that there are **at most**_ `m` `0`_'s and_ `n` `1`_'s in the subset_.
A set `x` is a **subset** of a set `y` if all elements of `x` are also elements of `y`.
**Example 1:**
**Input:**... | null | Array,String,Dynamic Programming | Medium | 510,600,2261 |
7 | if you are preparing for a coding interview make sure to check out these videos you will find it helpful hi everybody welcome back let's dive into today's leeco problem reverse integer we're given a signed 32-bit integer x we're given a signed 32-bit integer x we're given a signed 32-bit integer x and we have to return... | Reverse Integer | reverse-integer | Given a signed 32-bit integer `x`, return `x` _with its digits reversed_. If reversing `x` causes the value to go outside the signed 32-bit integer range `[-231, 231 - 1]`, then return `0`.
**Assume the environment does not allow you to store 64-bit integers (signed or unsigned).**
**Example 1:**
**Input:** x = 123
... | null | Math | Medium | 8,190,2238 |
1,941 | welcome back everyone we're gonna be solving Elite code 1941 check if all characters have an equal number of occurrences so we're given a string s and we want to return true if that string is considered a good string or false otherwise and they consider a string good if all the characters that appear in s have the same... | Check if All Characters Have Equal Number of Occurrences | minimum-number-of-operations-to-make-string-sorted | Given a string `s`, return `true` _if_ `s` _is a **good** string, or_ `false` _otherwise_.
A string `s` is **good** if **all** the characters that appear in `s` have the **same** number of occurrences (i.e., the same frequency).
**Example 1:**
**Input:** s = "abacbc "
**Output:** true
**Explanation:** The character... | Note that the operations given describe getting the previous permutation of s To solve this problem you need to solve every suffix separately | Math,String,Combinatorics | Hard | null |
68 | hello and welcome to another video in this video we're going to be working on test justification so in this problem you're given an array of strings words and a width Max width and you want to format such that the line is possibly matched with characters and is fully left and right Justified entry Packard is an ingredi... | Text Justification | text-justification | Given an array of strings `words` and a width `maxWidth`, format the text such that each line has exactly `maxWidth` characters and is fully (left and right) justified.
You should pack your words in a greedy approach; that is, pack as many words as you can in each line. Pad extra spaces `' '` when necessary so that ea... | null | Array,String,Simulation | Hard | 1714,2260 |
135 | all right so this question is candy you have any children and then you want to give out all of candy to the children and you choose a massive candy at least one candy and children with a higher rating get more candy so return the minimum number for candies you need to distribute right so this question is straightforwar... | Candy | candy | There are `n` children standing in a line. Each child is assigned a rating value given in the integer array `ratings`.
You are giving candies to these children subjected to the following requirements:
* Each child must have at least one candy.
* Children with a higher rating get more candies than their neighbors.... | null | Array,Greedy | Hard | null |
1,903 | hey everybody this is lry this is day seven Leo day challenge hit the like button hit the Subscribe button join me on Discord let me know what you think about today's far I'm here in kenting National Park in a cave that's all I have so let's get to the problem yeah uh hope you like the intro I'm actually now in uh Kash... | Largest Odd Number in String | design-most-recently-used-queue | You are given a string `num`, representing a large integer. Return _the **largest-valued odd** integer (as a string) that is a **non-empty substring** of_ `num`_, or an empty string_ `" "` _if no odd integer exists_.
A **substring** is a contiguous sequence of characters within a string.
**Example 1:**
**Input:** nu... | You can store the data in an array and apply each fetch by moving the ith element to the end of the array (i.e, O(n) per operation). A better way is to use the square root decomposition technique. You can build chunks of size sqrt(n). For each fetch operation, You can search for the chunk which has the ith element and ... | Array,Hash Table,Stack,Design,Binary Indexed Tree,Ordered Set | Medium | 146 |
48 | hello boys and girls and welcome to another episode of your favorite algorithm channel my name is Ryan powers and today I'm gonna be taking you through leet code 48 rotate image so this is gonna be a fun problem depending on where your mind goes when you start this it could be extremely frustrating or really easy I don... | 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 |
168 | hey everybody today we'll be doing another lead cod18168 excel sheet column title this is an easy one given an integer column number return its corresponding column title as it appears in excel sheet so they are giving us an integer like this in an example we can see here 28 we have to return it in the form of excel sh... | Excel Sheet Column Title | excel-sheet-column-title | Given an integer `columnNumber`, return _its corresponding column title as it appears in an Excel sheet_.
For example:
A -> 1
B -> 2
C -> 3
...
Z -> 26
AA -> 27
AB -> 28
...
**Example 1:**
**Input:** columnNumber = 1
**Output:** "A "
**Example 2:**
**Input:** columnNumber = 28
**Output:** "AB "
**Example 3:**... | null | Math,String | Easy | 171,2304 |
72 | uh today we're gonna be working on youth code question number 72 edit added distance now given two strings word one and word to return the minimum number of operations required to convert word one to word two you have the following three operations permitted on a word insert a character delete a character and replace a... | Edit Distance | edit-distance | Given two strings `word1` and `word2`, return _the minimum number of operations required to convert `word1` to `word2`_.
You have the following three operations permitted on a word:
* Insert a character
* Delete a character
* Replace a character
**Example 1:**
**Input:** word1 = "horse ", word2 = "ros "
**O... | null | String,Dynamic Programming | Hard | 161,583,712,1105,2311 |
1,819 | Hello friends small in this video will be going through and problems from list to return for latest weekly contest to three 500 heart problem net problem number of different sub sequence like piece this statement is not difficult to understand but understood in these countries will lead you find The answer is very simp... | Number of Different Subsequences GCDs | construct-the-lexicographically-largest-valid-sequence | You are given an array `nums` that consists of positive integers.
The **GCD** of a sequence of numbers is defined as the greatest integer that divides **all** the numbers in the sequence evenly.
* For example, the GCD of the sequence `[4,6,16]` is `2`.
A **subsequence** of an array is a sequence that can be formed... | Heuristic algorithm may work. | Array,Backtracking | Medium | null |
1,208 | See, in this video we are going to do the question of Lead Co, Get Equal Substance with in Budget, you will be given two strings and a max cost integer will be given, the question is you have to convert one string into another string, now like mother, I will convert another one. If I am in B, what will be its cost? The... | Get Equal Substrings Within Budget | maximum-nesting-depth-of-two-valid-parentheses-strings | You are given two strings `s` and `t` of the same length and an integer `maxCost`.
You want to change `s` to `t`. Changing the `ith` character of `s` to `ith` character of `t` costs `|s[i] - t[i]|` (i.e., the absolute difference between the ASCII values of the characters).
Return _the maximum length of a substring of... | null | String,Stack | Medium | 1737 |
347 | Hello guys welcome back kids in english useful proven top frequent element problem write that system number three four 700 latest real problem statement in this problem give non-tariff barriers and give non-tariff barriers and give non-tariff barriers and win the most frequent element constraints very important this is... | Top K Frequent Elements | top-k-frequent-elements | Given an integer array `nums` and an integer `k`, return _the_ `k` _most frequent elements_. You may return the answer in **any order**.
**Example 1:**
**Input:** nums = \[1,1,1,2,2,3\], k = 2
**Output:** \[1,2\]
**Example 2:**
**Input:** nums = \[1\], k = 1
**Output:** \[1\]
**Constraints:**
* `1 <= nums.lengt... | null | Array,Hash Table,Divide and Conquer,Sorting,Heap (Priority Queue),Bucket Sort,Counting,Quickselect | Medium | 192,215,451,659,692,1014,1919 |
94 | today we're going to be going over the Java solution for lead code 94 binary tree and Order traversal given the root of a binary tree return the inorder traversal of its node's values so here we're just going to be given a binary tree and we're going to perform the inner traversal of it and add the values of the nodes ... | 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 |
70 | hello and welcome today we're doing a question from lee code called climbing stairs it isn't easy let's get right into it you are climbing a staircase it takes n steps to reach the top each time you can either climb one or two steps in how many distinct ways can you climb to the top example one we want to reach step tw... | 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 |
116 | hey everybody this is larry this is day 13 of the leeco day challenge hit the like button hit the subscribe button join me on discord and let me know what you think about today's form populating next right pointers in each note okay you give it a perfect binary tree that's something to notice i misread this at some poi... | 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 |
204 | hello everyone in this video we are going to solve the lead code question number 204 count primes given an integer n return the number of prime numbers that are strictly less than n the prime numbers which are less than 10 are 2 3 5 and 7 so the output should be 4 in the second example n is zero so the output should be... | Count Primes | count-primes | Given an integer `n`, return _the number of prime numbers that are strictly less than_ `n`.
**Example 1:**
**Input:** n = 10
**Output:** 4
**Explanation:** There are 4 prime numbers less than 10, they are 2, 3, 5, 7.
**Example 2:**
**Input:** n = 0
**Output:** 0
**Example 3:**
**Input:** n = 1
**Output:** 0
**Co... | Let's start with a isPrime function. To determine if a number is prime, we need to check if it is not divisible by any number less than n. The runtime complexity of isPrime function would be O(n) and hence counting the total prime numbers up to n would be O(n2). Could we do better? As we know the number must not be div... | Array,Math,Enumeration,Number Theory | Medium | 263,264,279 |
98 | hello everyone welcome to pseudocoder my name is raveena and today we are going to solve problem number 98 that is validate binary search tree so let's start by reading the problem statement it says that given the root of the binary tree determine if it's a valid binary search tree a weld binary search tree is defined ... | Validate Binary Search Tree | validate-binary-search-tree | Given the `root` of a binary tree, _determine if it is a valid binary search tree (BST)_.
A **valid BST** is defined as follows:
* The left subtree of a node contains only nodes with keys **less than** the node's key.
* The right subtree of a node contains only nodes with keys **greater than** the node's key.
* ... | null | Tree,Depth-First Search,Binary Search Tree,Binary Tree | Medium | 94,501 |
1,653 | hey everybody this is larry this is me going over to two of the bi-weekly contest 39 two of the bi-weekly contest 39 two of the bi-weekly contest 39 uh minimum deletion to make string balance so this one is a little bit tricky to unders to i mean the understanding is not that hard uh and i actually can clean up the cod... | Minimum Deletions to Make String Balanced | number-of-good-leaf-nodes-pairs | You are given a string `s` consisting only of characters `'a'` and `'b'`.
You can delete any number of characters in `s` to make `s` **balanced**. `s` is **balanced** if there is no pair of indices `(i,j)` such that `i < j` and `s[i] = 'b'` and `s[j]= 'a'`.
Return _the **minimum** number of deletions needed to ma... | Start DFS from each leaf node. stop the DFS when the number of steps done > distance. If you reach another leaf node within distance steps, add 1 to the answer. Note that all pairs will be counted twice so divide the answer by 2. | Tree,Depth-First Search,Binary Tree | Medium | null |
1,840 | hello everyone let's take a look at this lego problem maximum building height it's the last question in the weekly context and it's a hard problem let's take a look like how to solve this problem the problem is like the description is pretty long so if you haven't read the description you can read it basically like we ... | Maximum Building Height | minimize-hamming-distance-after-swap-operations | You want to build `n` new buildings in a city. The new buildings will be built in a line and are labeled from `1` to `n`.
However, there are city restrictions on the heights of the new buildings:
* The height of each building must be a non-negative integer.
* The height of the first building **must** be `0`.
* ... | The source array can be imagined as a graph where each index is a node and each allowedSwaps[i] is an edge. Nodes within the same component can be freely swapped with each other. For each component, find the number of common elements. The elements that are not in common will contribute to the total Hamming distance. | Array,Depth-First Search,Union Find | Medium | 1308 |
825 | hey everybody this is Larry this is March 8th of the Leo day challenge hit the like button hit the subscri oh I mean it's not the daily challenge but it's the extra PR that I'm doing so hit the like button hit the Subscribe button join me on Discord let me know what you think about this one uh RNG take me to a good pro... | Friends Of Appropriate Ages | max-increase-to-keep-city-skyline | There are `n` persons on a social media website. You are given an integer array `ages` where `ages[i]` is the age of the `ith` person.
A Person `x` will not send a friend request to a person `y` (`x != y`) if any of the following conditions is true:
* `age[y] <= 0.5 * age[x] + 7`
* `age[y] > age[x]`
* `age[y] >... | null | Array,Greedy,Matrix | Medium | null |
295 | so let's do this question find medium from data stream as you probably would know the median is the middle value in an ordered into your list but for this question we're not given an integer list we're given just an add num function so how do we find the median if we're only given add num well the input is a bunch of c... | Find Median from Data Stream | find-median-from-data-stream | The **median** is the middle value in an ordered integer list. If the size of the list is even, there is no middle value, and the median is the mean of the two middle values.
* For example, for `arr = [2,3,4]`, the median is `3`.
* For example, for `arr = [2,3]`, the median is `(2 + 3) / 2 = 2.5`.
Implement the M... | null | Two Pointers,Design,Sorting,Heap (Priority Queue),Data Stream | Hard | 480,1953,2207 |
1,852 | well hello fans this is texas tim continuing my project to grind through leak code as you can see i've got some different seasons where i've been more involved in grinding and less involved depends on what's going on and i hope that i'm beginning to do some more grinding and i'm happy to have you along for the ride so ... | Distinct Numbers in Each Subarray | biggest-window-between-visits | Given an integer array `nums` and an integer `k`, you are asked to construct the array `ans` of size `n-k+1` where `ans[i]` is the number of **distinct** numbers in the subarray `nums[i:i+k-1] = [nums[i], nums[i+1], ..., nums[i+k-1]]`.
Return _the array_ `ans`.
**Example 1:**
**Input:** nums = \[1,2,3,2,2,1,3\], k =... | null | Database | Medium | 2370 |
735 | hello everyone welcome back uh here's when I'm saying and today we are going to tackle a fascinating problem uh involving asteroid collision and this time in JavaScript so let's dive into the problem we are given an array of integer that represent asteroids in a row and the absolute value of asteroid represents its siz... | Asteroid Collision | asteroid-collision | We are given an array `asteroids` of integers representing asteroids in a row.
For each asteroid, the absolute value represents its size, and the sign represents its direction (positive meaning right, negative meaning left). Each asteroid moves at the same speed.
Find out the state of the asteroids after all collisio... | Say a row of asteroids is stable. What happens when a new asteroid is added on the right? | Array,Stack | Medium | 605,2245,2317 |
349 | hey guys welcome back to my channel and in today's video we are going to solve one more leadid question that is question number 349 intersections of two arrays so this is an easy level question and this has been asked by these many companies you can see there is a lot of companies which are interested in this question ... | Intersection of Two Arrays | intersection-of-two-arrays | Given two integer arrays `nums1` and `nums2`, return _an array of their intersection_. Each element in the result must be **unique** and you may return the result in **any order**.
**Example 1:**
**Input:** nums1 = \[1,2,2,1\], nums2 = \[2,2\]
**Output:** \[2\]
**Example 2:**
**Input:** nums1 = \[4,9,5\], nums2 = \... | null | Array,Hash Table,Two Pointers,Binary Search,Sorting | Easy | 350,1149,1392,2190,2282 |
763 | hello everyone welcome to our channel code with sunny and in this video we will be talking about the problem partition labels its index is 763 and it is the medium problem of the lead code okay so we are given a string s and we want to partition this string into as many parts as possible so that each letter appears in ... | Partition Labels | special-binary-string | You are given a string `s`. We want to partition the string into as many parts as possible so that each letter appears in at most one part.
Note that the partition is done so that after concatenating all the parts in order, the resultant string should be `s`.
Return _a list of integers representing the size of these ... | Draw a line from (x, y) to (x+1, y+1) if we see a "1", else to (x+1, y-1).
A special substring is just a line that starts and ends at the same y-coordinate, and that is the lowest y-coordinate reached.
Call a mountain a special substring with no special prefixes - ie. only at the beginning and end is the lowest y-coo... | String,Recursion | Hard | 678 |
1,029 | 1029 to City scheduling so we are giving a ARR costs let me make a drawing first so about this cost array so for the first index that is the cost to City a yeah for the first person and the second index so index zero index one for this subar this 20 is for another person yeah let me check so yeah there are two people s... | Two City Scheduling | vertical-order-traversal-of-a-binary-tree | A company is planning to interview `2n` people. Given the array `costs` where `costs[i] = [aCosti, bCosti]`, the cost of flying the `ith` person to city `a` is `aCosti`, and the cost of flying the `ith` person to city `b` is `bCosti`.
Return _the minimum cost to fly every person to a city_ such that exactly `n` people... | null | Hash Table,Tree,Depth-First Search,Breadth-First Search,Binary Tree | Hard | null |
495 | uh-huh Teemo attacking okay fly I don't uh-huh Teemo attacking okay fly I don't uh-huh Teemo attacking okay fly I don't know what Teemo is so maybe is this like meme or something somewhere I John thanks for the trying League of Legends character okay well I mean yeah this is on the first line so I mean I'm with dota pe... | 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 |
328 | Loot Hello Everyone Welcome To My Channel Today's Question Is Audio Nikli Then Questions Given Link Group Cold Not To Be Followed By Not Pleased To Develop A Strike Rate Of Time E Aaj Ke Din Tak Sample Pure 12345 Se Zara Number Interesting And That To For Which Everyone around for this info which can save a this articl... | 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 |
222 | hello everybody is a male and today I'm gonna teach you how to solve the count complete three notes problem giving a complete binary tree count the number of nodes know the definition of a complete binary tree from Wikipedia in a complete binary tree every level except possibly the last is completely filled and all nod... | 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 |
1,740 | so uh currently we are trying to find out the distance between two values that has been given in a binary tree uh for this problem uh we are basically trying to find out the value of distance between the lowest common ancestor and p uh then we'll add it to the distance between the least common ancestor lowest common an... | Find Distance in a Binary Tree | count-subtrees-with-max-distance-between-cities | Given the root of a binary tree and two integers `p` and `q`, return _the **distance** between the nodes of value_ `p` _and value_ `q` _in the tree_.
The **distance** between two nodes is the number of edges on the path from one to the other.
**Example 1:**
**Input:** root = \[3,5,1,6,2,0,8,null,null,7,4\], p = 5, q... | Iterate through every possible subtree by doing a bitmask on which vertices to include. How can you determine if a subtree is valid (all vertices are connected)? To determine connectivity, count the number of reachable vertices starting from any included vertex and only traveling on edges connecting 2 vertices in the s... | Dynamic Programming,Bit Manipulation,Tree,Enumeration,Bitmask | Hard | 1177 |
215 | all right so disgusting us 215 case largest element in a array we want to return the case the largest element in the unsorted array and it's the question is asking for the case largest element in a sorted order not the case this thing - element so basically if we could thing - element so basically if we could thing - e... | Kth Largest Element in an Array | kth-largest-element-in-an-array | Given an integer array `nums` and an integer `k`, return _the_ `kth` _largest element in the array_.
Note that it is the `kth` largest element in the sorted order, not the `kth` distinct element.
You must solve it in `O(n)` time complexity.
**Example 1:**
**Input:** nums = \[3,2,1,5,6,4\], k = 2
**Output:** 5
**Ex... | null | Array,Divide and Conquer,Sorting,Heap (Priority Queue),Quickselect | Medium | 324,347,414,789,1014,2113,2204,2250 |
92 | hey hello there now i'm looking at a potential follow-up potential follow-up potential follow-up to the question 206 reverse linked list it's a 92 reverse linked list of two so instead of doing the whole linked list reversal as the previous exam question now we are given a starting position and end position all we want... | Reverse Linked List II | reverse-linked-list-ii | Given the `head` of a singly linked list and two integers `left` and `right` where `left <= right`, reverse the nodes of the list from position `left` to position `right`, and return _the reversed list_.
**Example 1:**
**Input:** head = \[1,2,3,4,5\], left = 2, right = 4
**Output:** \[1,4,3,2,5\]
**Example 2:**
**I... | null | Linked List | Medium | 206 |
1,535 | hi everyone my name is steve today we're going to talk about lego problem 1535 find the winner of an array game let's take a look at the problem first it's giving an integer array a of distinct integers and an integer k the how the game will be played is like between the first two elements of the array that means array... | Find the Winner of an Array Game | build-array-where-you-can-find-the-maximum-exactly-k-comparisons | Given an integer array `arr` of **distinct** integers and an integer `k`.
A game will be played between the first two elements of the array (i.e. `arr[0]` and `arr[1]`). In each round of the game, we compare `arr[0]` with `arr[1]`, the larger integer wins and remains at position `0`, and the smaller integer moves to t... | Use dynamic programming approach. Build dp table where dp[a][b][c] is the number of ways you can start building the array starting from index a where the search_cost = c and the maximum used integer was b. Recursively, solve the small sub-problems first. Optimize your answer by stopping the search if you exceeded k cha... | Dynamic Programming | Hard | null |
743 | Hey guys welcome to take dola I am Nivedita and this video they are going to solve network delete time so this problem I have given you what I have given here I have given a network of and not which has been leveled from 1 to and Till is fine and one is giving you the times list here, the to -do list which has the valu... | Network Delay Time | closest-leaf-in-a-binary-tree | You are given a network of `n` nodes, labeled from `1` to `n`. You are also given `times`, a list of travel times as directed edges `times[i] = (ui, vi, wi)`, where `ui` is the source node, `vi` is the target node, and `wi` is the time it takes for a signal to travel from source to target.
We will send a signal from a... | Convert the tree to a general graph, and do a breadth-first search. Alternatively, find the closest leaf for every node on the path from root to target. | Tree,Depth-First Search,Breadth-First Search,Binary Tree | Medium | null |
705 | That in this problem with design this set a problem has been cleared in Google interview servicing problem statement will also seen in general water colleges how to reduce colleges in the improvement of and subscribe statement soon without using any building and 285 rates on her private function but Subscribe incentive... | Design HashSet | design-hashset | Design a HashSet without using any built-in hash table libraries.
Implement `MyHashSet` class:
* `void add(key)` Inserts the value `key` into the HashSet.
* `bool contains(key)` Returns whether the value `key` exists in the HashSet or not.
* `void remove(key)` Removes the value `key` in the HashSet. If `key` do... | null | null | Easy | null |
764 | hey everybody this is larry this is september 9th the ninth day of the september leco day challenge because that's how you count stuff uh hit the like button hit the subscribe button join me on this card let me know what you think about today's prom largest plus sign um yeah remember join me on discord come hang out ni... | Largest Plus Sign | n-ary-tree-level-order-traversal | You are given an integer `n`. You have an `n x n` binary grid `grid` with all values initially `1`'s except for some indices given in the array `mines`. The `ith` element of the array `mines` is defined as `mines[i] = [xi, yi]` where `grid[xi][yi] == 0`.
Return _the order of the largest **axis-aligned** plus sign of_ ... | null | Tree,Breadth-First Search | Medium | 102,775,776,2151 |
99 | um hello so today we are going to do this lead code problem uh it's part of it called april daily challenge recovery binary research 3. so the problem says we get a root of a binary search tree where exactly only two nodes of the tree are were swapped by mistake and we want to recover the tree so that it respects binar... | Recover Binary Search Tree | recover-binary-search-tree | You are given the `root` of a binary search tree (BST), where the values of **exactly** two nodes of the tree were swapped by mistake. _Recover the tree without changing its structure_.
**Example 1:**
**Input:** root = \[1,3,null,null,2\]
**Output:** \[3,1,null,null,2\]
**Explanation:** 3 cannot be a left child of 1 ... | null | Tree,Depth-First Search,Binary Search Tree,Binary Tree | Medium | null |
1,773 | hi my name is david today we're going to do number 1773 count items matching a rule this is an easy level problem on lead code and we're going to solve it in javascript so the prop rating pretty much says as a summary it has a function that takes in an item and this item is an array of strings see in a very and uh this... | Count Items Matching a Rule | percentage-of-users-attended-a-contest | You are given an array `items`, where each `items[i] = [typei, colori, namei]` describes the type, color, and name of the `ith` item. You are also given a rule represented by two strings, `ruleKey` and `ruleValue`.
The `ith` item is said to match the rule if **one** of the following is true:
* `ruleKey == "type "` ... | null | Database | Easy | 1338 |
1,603 | hi everyone so welcome to the channel so we will today try to solve this problem known as design parking system and this is a very famous problem it's been asked in various companies like Amazon Bloomberg and Uber so let us try to read the problem statement first it states that we have to design a parking system for a ... | Design Parking System | running-sum-of-1d-array | Design a parking system for a parking lot. The parking lot has three kinds of parking spaces: big, medium, and small, with a fixed number of slots for each size.
Implement the `ParkingSystem` class:
* `ParkingSystem(int big, int medium, int small)` Initializes object of the `ParkingSystem` class. The number of slot... | Think about how we can calculate the i-th number in the running sum from the (i-1)-th number. | Array,Prefix Sum | Easy | null |
141 | hello guys welcome to algorithms made easy today we will be discussing the question linkedless cycle in this question we are given the head of the linked list and we need to determine if the linked list has cycle in it or not in the first example as we can see the linked list does have a cycle so we return true in the ... | 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 |
495 | hi i am ayushi rawat and welcome to my channel today we will discuss the september lead code challenge week 4 problem day 26 teemo attacking now let's have a look at the problem statement in lol world there is a hero called teemu and his attacking can make his enemy ash be in poisoned condition okay now given the teemo... | 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 |
804 | hi my name is Alexandra Lennon I'm experienced itself to our engineer today we will solve unique humours code words problem from lead code with JavaScript the plan for today is next we'll observe the problem and find what is meaningful for the task what is not second we will design or algorithm third will calculate com... | Unique Morse Code Words | rotated-digits | International Morse Code defines a standard encoding where each letter is mapped to a series of dots and dashes, as follows:
* `'a'` maps to `".- "`,
* `'b'` maps to `"-... "`,
* `'c'` maps to `"-.-. "`, and so on.
For convenience, the full table for the `26` letters of the English alphabet is given below:
\[ ... | null | Math,Dynamic Programming | Medium | null |
57 | Hi gas welcome back to my channel so today our problem is insert interval so what have you given us in this problem statement here we have been given an ad right by the name interval where your interval is represented by star t. And indirect i.e. the starting time of any interval indirect i.e. the starting time of any ... | Insert Interval | insert-interval | You are given an array of non-overlapping intervals `intervals` where `intervals[i] = [starti, endi]` represent the start and the end of the `ith` interval and `intervals` is sorted in ascending order by `starti`. You are also given an interval `newInterval = [start, end]` that represents the start and end of another i... | null | Array | Medium | 56,715 |
312 | hey everybody happy new year yay uh hit the like button hit the subscribe button join me on discord let me know what you think about you know what you're doing this year this channel whatever it is just you know i hope you're having a good time i hope you accomplish all your goals uh people in my discord has been kind ... | Burst Balloons | burst-balloons | You are given `n` balloons, indexed from `0` to `n - 1`. Each balloon is painted with a number on it represented by an array `nums`. You are asked to burst all the balloons.
If you burst the `ith` balloon, you will get `nums[i - 1] * nums[i] * nums[i + 1]` coins. If `i - 1` or `i + 1` goes out of bounds of the array, ... | null | Array,Dynamic Programming | Hard | 1042 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.