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
80
hello everyone welcome to my channel let's solve the problem remove duplicates from sorted array 2. so given a sorted array nums remove the duplicates in place such that duplicates appeared at most twice and returned the new length do not allocate extra space for another array you must do this by modifying the input ar...
Remove Duplicates from Sorted Array II
remove-duplicates-from-sorted-array-ii
Given an integer array `nums` sorted in **non-decreasing order**, remove some duplicates [**in-place**](https://en.wikipedia.org/wiki/In-place_algorithm) such that each unique element appears **at most twice**. The **relative order** of the elements should be kept the **same**. Since it is impossible to change the len...
null
Array,Two Pointers
Medium
26
868
all right let's talk about the binary gap so you are given positive integer and you have to finally return the longest distance between any two adjacent one in a binary representation of n so if there are no two edges on one return you right so this question is just a little bit challenge so let me just quickly draw a ...
Binary Gap
push-dominoes
Given a positive integer `n`, find and return _the **longest distance** between any two **adjacent**_ `1`_'s in the binary representation of_ `n`_. If there are no two adjacent_ `1`_'s, return_ `0`_._ Two `1`'s are **adjacent** if there are only `0`'s separating them (possibly no `0`'s). The **distance** between two `...
null
Two Pointers,String,Dynamic Programming
Medium
null
57
hey what's up YouTube you know what they say Elite code a day keeps the unemployment away so let's get to it for this problem we're given a list of intervals and we're told to insert a new interval and perform any operations necessary such that the new interval fits within the current intervals without overlapping let'...
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
1,004
hello Engineers welcome back in the previous video we solved a lead code question with a sliding window technique where the window size was fixed in this video we're going to solve another lead code question where the window size is not fixed okay I hope you're ready let's get started so this is the question that we're...
Max Consecutive Ones III
least-operators-to-express-number
Given a binary array `nums` and an integer `k`, return _the maximum number of consecutive_ `1`_'s in the array if you can flip at most_ `k` `0`'s. **Example 1:** **Input:** nums = \[1,1,1,0,0,0,1,1,1,1,0\], k = 2 **Output:** 6 **Explanation:** \[1,1,1,0,0,**1**,1,1,1,1,**1**\] Bolded numbers were flipped from 0 to 1....
null
Math,Dynamic Programming
Hard
null
92
hey everyone how's it going welcome back to another video today we'll be looking at this problem that is called reversing a sublist in a linked list and this is a pretty important problem so let's get right into it so this problem tells you that you're given a linked list and you need to reverse a portion of that linke...
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
529
hello friends today less of the minesweeper carbon that's first in a statement we are given to teach our metrics representing the game board M represents an revealed my it represents an unrevealed empty square B represents a revealed blank square that has no agent above below left-right agent above below left-right age...
Minesweeper
minesweeper
Let's play the minesweeper game ([Wikipedia](https://en.wikipedia.org/wiki/Minesweeper_(video_game)), [online game](http://minesweeperonline.com))! You are given an `m x n` char matrix `board` representing the game board where: * `'M'` represents an unrevealed mine, * `'E'` represents an unrevealed empty square, ...
null
Array,Depth-First Search,Breadth-First Search,Matrix
Medium
2206
489
okay so uh lead code practice problem uh robot group cleaner so two goals in this video the first one is to find the solution and do some coding the second one is to see how we are going to do in a real interview so let's get started um so remember the first step is always to try to understand the problem if there's an...
Robot Room Cleaner
kth-smallest-instructions
You are controlling a robot that is located somewhere in a room. The room is modeled as an `m x n` binary grid where `0` represents a wall and `1` represents an empty slot. The robot starts at an unknown location in the room that is guaranteed to be empty, and you do not have access to the grid, but you can move the r...
There are nCr(row + column, row) possible instructions to reach (row, column). Try building the instructions one step at a time. How many instructions start with "H", and how does this compare with k?
Array,Math,Dynamic Programming,Combinatorics
Hard
null
1,802
hi guys good morning welcome back to the new videos of firstly if you have been watching us for last one month or more for sure you should be able to through this question at least the logic okay what's going to be applied how gonna be applied because it is mixed of two concepts and both of them we have studied separat...
Maximum Value at a Given Index in a Bounded Array
number-of-students-unable-to-eat-lunch
You are given three positive integers: `n`, `index`, and `maxSum`. You want to construct an array `nums` (**0-indexed**) that satisfies the following conditions: * `nums.length == n` * `nums[i]` is a **positive** integer where `0 <= i < n`. * `abs(nums[i] - nums[i+1]) <= 1` where `0 <= i < n-1`. * The sum of a...
Simulate the given in the statement Calculate those who will eat instead of those who will not.
Array,Stack,Queue,Simulation
Easy
2195
1,292
hey what's up guys this is john here so and today uh let's take a look at 1292 maximum side length of a square with some less than or equal to threshold um so you're given like an m times i'm by n dimension 2d array here and the integer threshold and it asks you to return the maximum side length of a square with the su...
Maximum Side Length of a Square with Sum Less than or Equal to Threshold
immediate-food-delivery-ii
Given a `m x n` matrix `mat` and an integer `threshold`, return _the maximum side-length of a square with a sum less than or equal to_ `threshold` _or return_ `0` _if there is no such square_. **Example 1:** **Input:** mat = \[\[1,1,3,2,4,3,2\],\[1,1,3,2,4,3,2\],\[1,1,3,2,4,3,2\]\], threshold = 4 **Output:** 2 **Expl...
null
Database
Medium
null
448
alright this leaked code question is called find all numbers disappeared in an array it says given an array of integers basically from 1 to n where n is the size of an array some elements occur twice and others appear once find all of the elements of 1 to n inclusive that do not appear in this array could you do it wit...
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
403
hey what's up guys John here okay so today let's talk about another like dynamic programming problem number 403 frog jump yeah I think I like this problem so I'm gonna keep my own boat here so a frog is crossing a river and there are like bunch of stones right separated across the river and the value on the stone repre...
Frog Jump
frog-jump
A frog is crossing a river. The river is divided into some number of units, and at each unit, there may or may not exist a stone. The frog can jump on a stone, but it must not jump into the water. Given a list of `stones`' positions (in units) in sorted **ascending order**, determine if the frog can cross the river by...
null
Array,Dynamic Programming
Hard
1952,2262
1,648
okay so lead code practice question uh in this video we will go through this uh problem which is called cell diminishing valued colored balls and we will explain what the solution is and we will explain the procedure we should follow within a real interview so let's go through this problem so remember the first step in...
Sell Diminishing-Valued Colored Balls
minimum-insertions-to-balance-a-parentheses-string
You have an `inventory` of different colored balls, and there is a customer that wants `orders` balls of **any** color. The customer weirdly values the colored balls. Each colored ball's value is the number of balls **of that color** you currently have in your `inventory`. For example, if you own `6` yellow balls, the...
Use a stack to keep opening brackets. If you face single closing ')' add 1 to the answer and consider it as '))'. If you have '))' with empty stack, add 1 to the answer, If after finishing you have x opening remaining in the stack, add 2x to the answer.
String,Stack,Greedy
Medium
2095
337
Everyone, so today we are going to solve the question which is a tree structure immediate children cannot commit robbery. If he commits robbery then the police will be alerted. Okay, so now what we have to do is tell us how to take the maximum amount. It is possible that by doing a job in a house, if we look at this ex...
House Robber III
house-robber-iii
The thief has found himself a new place for his thievery again. There is only one entrance to this area, called `root`. Besides the `root`, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will automatically contact the police if ...
null
Dynamic Programming,Tree,Depth-First Search,Binary Tree
Medium
198,213
1,877
hey everyone uh today i'll be doing leap code 1877 minimize max pair sum in an array this is one of those ones that is medium simply because the description in my opinion is really easy so really all it's asking i'm going to get this list and explain it gives you a list of numbers and it wants you to pair them up in a ...
Minimize Maximum Pair Sum in Array
find-followers-count
The **pair sum** of a pair `(a,b)` is equal to `a + b`. The **maximum pair sum** is the largest **pair sum** in a list of pairs. * For example, if we have pairs `(1,5)`, `(2,3)`, and `(4,4)`, the **maximum pair sum** would be `max(1+5, 2+3, 4+4) = max(6, 5, 8) = 8`. Given an array `nums` of **even** length `n`, pai...
null
Database
Easy
null
86
hey everyone welcome back and let's write some more neat code today so today let's solve partition list or partition a linked list because we are given the head of a linked list and a particular value x and we want to partition the list such that every single value that's less than x is on the left side like over here ...
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
1
today i'm going to show you how to solve this problem very easily so there are actually two ways of approaching this problem the first one is the brute force that actually starts from here so we're going to check one and six one and five so what's this problem all about so we are trying to find two numbers from here th...
Two Sum
two-sum
Given an array of integers `nums` and an integer `target`, return _indices of the two numbers such that they add up to `target`_. You may assume that each input would have **_exactly_ one solution**, and you may not use the _same_ element twice. You can return the answer in any order. **Example 1:** **Input:** nums...
A really brute force way would be to search for all possible pairs of numbers but that would be too slow. Again, it's best to try out brute force solutions for just for completeness. It is from these brute force solutions that you can come up with optimizations. So, if we fix one of the numbers, say x, we have to scan ...
Array,Hash Table
Easy
15,18,167,170,560,653,1083,1798,1830,2116,2133,2320
417
welcome back to algojs today's question is leak code 417 pacific atlantic water flow so you have an m by m rectangular island that borders both the pacific ocean and atlantic ocean the pacific ocean touches the left and top edges and the atlantic ocean touches the right and bottom edges so the island is petitioned into...
Pacific Atlantic Water Flow
pacific-atlantic-water-flow
There is an `m x n` rectangular island that borders both the **Pacific Ocean** and **Atlantic Ocean**. The **Pacific Ocean** touches the island's left and top edges, and the **Atlantic Ocean** touches the island's right and bottom edges. The island is partitioned into a grid of square cells. You are given an `m x n` i...
null
Array,Depth-First Search,Breadth-First Search,Matrix
Medium
null
153
hello to Ajay, yes, make pakodas from this mixture, want to try surgical strike in this respect net question, whose name is point minimum in rooted, sorted in chick, then in this question she will ask for free, if you know the search, then sodium, then in one lot, you will get this target. I know how to pause the eleme...
Find Minimum in Rotated Sorted Array
find-minimum-in-rotated-sorted-array
Suppose an array of length `n` sorted in ascending order is **rotated** between `1` and `n` times. For example, the array `nums = [0,1,2,4,5,6,7]` might become: * `[4,5,6,7,0,1,2]` if it was rotated `4` times. * `[0,1,2,4,5,6,7]` if it was rotated `7` times. Notice that **rotating** an array `[a[0], a[1], a[2], ....
Array was originally in ascending order. Now that the array is rotated, there would be a point in the array where there is a small deflection from the increasing sequence. eg. The array would be something like [4, 5, 6, 7, 0, 1, 2]. You can divide the search space into two and see which direction to go. Can you think ...
Array,Binary Search
Medium
33,154
559
hello so today we are doing this problem called maximum depth of an array tree and so the problem says we get in an array tree and we're going to find just the maximum depth so the maximum depth is the number of nodes along the longest path from the root down to the farthest leaf node and so for example in this 3re tre...
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
1,632
hey what is up guys welcome back to another leak code problem today we're doing polymer 1632 rank transform of a matrix before i begin yeah come on man um thanks hey what is up guys welcome back to another league called problem today we're doing number 1632 ranked transform of a matrix given an n by n matrix return a n...
Rank Transform of a Matrix
number-of-good-ways-to-split-a-string
Given an `m x n` `matrix`, return _a new matrix_ `answer` _where_ `answer[row][col]` _is the_ _**rank** of_ `matrix[row][col]`. The **rank** is an **integer** that represents how large an element is compared to other elements. It is calculated using the following rules: * The rank is an integer starting from `1`. *...
Use two HashMap to store the counts of distinct letters in the left and right substring divided by the current index.
String,Dynamic Programming,Bit Manipulation
Medium
null
485
what's up everybody elto majin here and welcome back to yet another youtube video in today's video we'll be solving another easy lead code problem number 485 also called as max consecutive ones it is also the first problem of arrays 101 card of explorer fleet code and it has also been asked in amazon microsoft and goog...
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,710
hello coders welcome back to my channel of lead code problem 1710 maximum units on a truck here we are assigned to put some amount of boxes on the truck and we are given 2d array like we are given with number of boxes and number of units per box and what we have to do is we have to return the maximum of total units tha...
Maximum Units on a Truck
find-servers-that-handled-most-number-of-requests
You are assigned to put some amount of boxes onto **one truck**. You are given a 2D array `boxTypes`, where `boxTypes[i] = [numberOfBoxesi, numberOfUnitsPerBoxi]`: * `numberOfBoxesi` is the number of boxes of type `i`. * `numberOfUnitsPerBoxi` is the number of units in each box of the type `i`. You are also given...
To speed up the next available server search, keep track of the available servers in a sorted structure such as an ordered set. To determine if a server is available, keep track of the end times for each task in a heap and add the server to the available set once the soonest task ending time is less than or equal to th...
Array,Greedy,Heap (Priority Queue),Ordered Set
Hard
null
657
welcome back to Algiers today's question is leak code 657 robot return to origin so there is a robot starting at position zero the origin on a 2d plane given a sequence of its moves judge if the robot ends up at zero after it completes its moves you're given a string moves that represents the move sequence of the robot...
Robot Return to Origin
robot-return-to-origin
There is a robot starting at the position `(0, 0)`, the origin, on a 2D plane. Given a sequence of its moves, judge if this robot **ends up at** `(0, 0)` after it completes its moves. You are given a string `moves` that represents the move sequence of the robot where `moves[i]` represents its `ith` move. Valid moves a...
null
String,Simulation
Easy
547,2239
191
200 Hello friends Blind 75th let's move forward to a new day and today our 4138 is number one white so let's move on to it so the question is quick and for this let me tell you in advance that if you have not seen Defty that is the reverse beat of 175 I have not seen it because I have a belt in it, I have problems etc....
Number of 1 Bits
number-of-1-bits
Write a function that takes the binary representation of an unsigned integer and returns the number of '1' bits it has (also known as the [Hamming weight](http://en.wikipedia.org/wiki/Hamming_weight)). **Note:** * Note that in some languages, such as Java, there is no unsigned integer type. In this case, the input ...
null
Bit Manipulation
Easy
190,231,338,401,461,693,767
1,317
hey how's it going today we are going to go over the convert integer to the sum of two non-zero integers question in of two non-zero integers question in of two non-zero integers question in python it's given integer and non-zero python it's given integer and non-zero python it's given integer and non-zero integer is a...
Convert Integer to the Sum of Two No-Zero Integers
monthly-transactions-i
**No-Zero integer** is a positive integer that **does not contain any `0`** in its decimal representation. Given an integer `n`, return _a list of two integers_ `[a, b]` _where_: * `a` and `b` are **No-Zero integers**. * `a + b = n` The test cases are generated so that there is at least one valid solution. If th...
null
Database
Medium
1328
328
hi everyone I'm here to solve leeco problem number 328 odd even link list let's read the problem 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 ...
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
101
in this video we're going to take a look at a lethal problem called symmetric tree so given a binary tree so check whether it's a mirror of itself so symmetric around the center so for example this binary tree we have something like this and then we want to see if it's symmetric what we're going to do is we're going to...
Symmetric Tree
symmetric-tree
Given the `root` of a binary tree, _check whether it is a mirror of itself_ (i.e., symmetric around its center). **Example 1:** **Input:** root = \[1,2,2,3,4,4,3\] **Output:** true **Example 2:** **Input:** root = \[1,2,2,null,3,null,3\] **Output:** false **Constraints:** * The number of nodes in the tree is in...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Easy
null
299
Hello viewers welcome back to my YouTube channel today I am doing a very interesting one named Bhojan Ka Vaas A Kar Do To To To open this question you will have to go to the constable group on our portal and there will be this link. If you have to open it in English, then that question leaf will be given to you as a ph...
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
179
question 179 largest number given a list of non-negative integer given a list of non-negative integer given a list of non-negative integer norms arrange them so that form the largest number and the return the largest number since the result may be very large you need to retain a string instead of integer so if you look...
Largest Number
largest-number
Given a list of non-negative integers `nums`, arrange them such that they form the largest number and return it. Since the result may be very large, so you need to return a string instead of an integer. **Example 1:** **Input:** nums = \[10,2\] **Output:** "210 " **Example 2:** **Input:** nums = \[3,30,34,5,9\] *...
null
String,Greedy,Sorting
Medium
2284
371
hello hi everyone welcome back to the channel so today in this video lecture we'll be solving this problem sum of two integers so we are solving the blind 75 list so blind 75 list covers the most important patterns which are very useful for the interview coding interviews so in this section which is this binary section...
Sum of Two Integers
sum-of-two-integers
Given two integers `a` and `b`, return _the sum of the two integers without using the operators_ `+` _and_ `-`. **Example 1:** **Input:** a = 1, b = 2 **Output:** 3 **Example 2:** **Input:** a = 2, b = 3 **Output:** 5 **Constraints:** * `-1000 <= a, b <= 1000`
null
Math,Bit Manipulation
Medium
2
515
hey everyone today we are going to solve the question find the largest value in each three row okay first of all I think we have two difficulties one is how can you keep a max value at a single level and the second difficulty is how can you keep nodes at next down level so since we have to choose a max value at a singl...
Find Largest Value in Each Tree Row
find-largest-value-in-each-tree-row
Given the `root` of a binary tree, return _an array of the largest value in each row_ of the tree **(0-indexed)**. **Example 1:** **Input:** root = \[1,3,2,5,3,null,9\] **Output:** \[1,3,9\] **Example 2:** **Input:** root = \[1,2,3\] **Output:** \[1,3\] **Constraints:** * The number of nodes in the tree will be...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Medium
null
387
hello everyone welcome to cs4 all so today we are finally starting off with the very first question of the algo master sheet that is first unique character in a string but before we head over to this question i would like to take you into an adventure of hashing because we haven't covered that much of hashing in the in...
First Unique Character in a String
first-unique-character-in-a-string
Given a string `s`, _find the first non-repeating character in it and return its index_. If it does not exist, return `-1`. **Example 1:** **Input:** s = "leetcode" **Output:** 0 **Example 2:** **Input:** s = "loveleetcode" **Output:** 2 **Example 3:** **Input:** s = "aabb" **Output:** -1 **Constraints:** * `...
null
Hash Table,String,Queue,Counting
Easy
451
304
hey guys this is Jay sir are doing in this video I'm going to take a look at 3:04 ransom query 2d immutable we're 3:04 ransom query 2d immutable we're 3:04 ransom query 2d immutable we're given a 2d matrix find the sum of elements inside a rectangle defined by its upper left corner and lower right corner so in here rig...
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
460
provided with the capacity of the lfu cache that simply means whenever you have reached the full capacity and you want to do more insertion you have to perform some evictions from the cach first so as soon as you reach full capacity evict and then insert if there is capacity bending capacity you can simply go ahead and...
LFU Cache
lfu-cache
Design and implement a data structure for a [Least Frequently Used (LFU)](https://en.wikipedia.org/wiki/Least_frequently_used) cache. Implement the `LFUCache` class: * `LFUCache(int capacity)` Initializes the object with the `capacity` of the data structure. * `int get(int key)` Gets the value of the `key` if the...
null
Hash Table,Linked List,Design,Doubly-Linked List
Hard
146,588
207
Hello Everyone Welcome to my channel Today's Questions Schedule YouTube Channel Please Consider Subscribe Tak Hum Ise Zara Total Aaf Na Trysh-Try A Grade Level Form-002 Na Trysh-Try A Grade Level Form-002 Na Trysh-Try A Grade Level Form-002 Number Ko Trysh Maz For Example To Take 20 This First Ko Swarna Rath Express An...
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
1,268
That a hello everyone welcome to difficult chahiye bhringraj challenge to all boys subscribe to is dam more than free products finance minister tree tweet on the relax feel minimum products' idli the solution is minimum products' idli the solution is minimum products' idli the solution is a minute and lists person sugg...
Search Suggestions System
market-analysis-i
You are given an array of strings `products` and a string `searchWord`. Design a system that suggests at most three product names from `products` after each character of `searchWord` is typed. Suggested products should have common prefix with `searchWord`. If there are more than three products with a common prefix ret...
null
Database
Medium
null
159
hello so this question is longer substance with almost two distinct characters so you're giving a shunes the length of the longest option can only contain at most two distinct characters so this question is pretty straightforward so you are still traversing from the starting all the way to the end and then for every si...
Longest Substring with At Most Two Distinct Characters
longest-substring-with-at-most-two-distinct-characters
Given a string `s`, return _the length of the longest_ _substring_ _that contains at most **two distinct characters**_. **Example 1:** **Input:** s = "eceba " **Output:** 3 **Explanation:** The substring is "ece " which its length is 3. **Example 2:** **Input:** s = "ccaabbb " **Output:** 5 **Explanation:** The ...
null
Hash Table,String,Sliding Window
Medium
3,239,340,1034
1,015
Welcome To Day Shift Ne Absolutely Silent And Asked Questions Molested Divisible By K Also In This Question You Are Given Number K And You Need To Form New Number Three Do It Seervi Subscribe Thank You All Subscribe - 151 Question Number Idi Subscribe Combined 111 Will Be The Number Without Number Features Molested Sub...
Smallest Integer Divisible by K
smallest-integer-divisible-by-k
Given a positive integer `k`, you need to find the **length** of the **smallest** positive integer `n` such that `n` is divisible by `k`, and `n` only contains the digit `1`. Return _the **length** of_ `n`. If there is no such `n`, return -1. **Note:** `n` may not fit in a 64-bit signed integer. **Example 1:** **In...
null
null
Medium
null
1,450
hello viewers welcome back to my channel I hope you're doing great if you haven't subscribed to my channel yet please go ahead and subscribe I have created several playlists to cover various categories of the problem such as trees graphs tries linking lists binary search sorting dynamic programming and so on so please ...
Number of Students Doing Homework at a Given Time
delete-leaves-with-a-given-value
Given two integer arrays `startTime` and `endTime` and given an integer `queryTime`. The `ith` student started doing their homework at the time `startTime[i]` and finished it at time `endTime[i]`. Return _the number of students_ doing their homework at time `queryTime`. More formally, return the number of students wh...
Use the DFS to reconstruct the tree such that no leaf node is equal to the target. If the leaf node is equal to the target, return an empty object instead.
Tree,Depth-First Search,Binary Tree
Medium
null
111
welcome to october's elite code challenge today's problem is minimum depth of binary tree given a binary tree find its minimum depth the minimum depth is the number of nodes along the shortest path from the root node down to its nearest leaf node so leaf node is where it doesn't have any children no left no right and a...
Minimum Depth of Binary Tree
minimum-depth-of-binary-tree
Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. **Note:** A leaf is a node with no children. **Example 1:** **Input:** root = \[3,9,20,null,null,15,7\] **Output:** 2 **Example 2:** **Input:** root = \[2...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Easy
102,104
784
Hello Friends This is the Problem Parmesan Cheese You are in Boxing Time etc Time Different Problem Name Letter Communication Electronics Withdrawal and Coins Problem Did Not Stay Tuned for This 600 Bluetooth Subscribe Transform Thursday subscribe and subscribe the Channel Please subscribe and subscribe the subscribe s...
Letter Case Permutation
insert-into-a-binary-search-tree
Given a string `s`, you can transform every letter individually to be lowercase or uppercase to create another string. Return _a list of all possible strings we could create_. Return the output in **any order**. **Example 1:** **Input:** s = "a1b2 " **Output:** \[ "a1b2 ", "a1B2 ", "A1b2 ", "A1B2 "\] **Example 2:*...
null
Tree,Binary Search Tree,Binary Tree
Medium
783
468
Hello guys welcome back to tech division in this video also siddha validate ip address problem vismrit ko date 16th june challenge personal problem the giver validate it is the and otherwise is the veer is subscribe The Amazing This is the first floor This is not the statement latest novel on its own rules for etv imme...
Validate IP Address
validate-ip-address
Given a string `queryIP`, return `"IPv4 "` if IP is a valid IPv4 address, `"IPv6 "` if IP is a valid IPv6 address or `"Neither "` if IP is not a correct IP of any type. **A valid IPv4** address is an IP in the form `"x1.x2.x3.x4 "` where `0 <= xi <= 255` and `xi` **cannot contain** leading zeros. For example, `"192.16...
null
String
Medium
752
139
hello everyone welcome back here is when I'm sen today we are tackling a very interesting uh problem popular on coding interviews it's called work break problem from lead code so this problem is a medium level question that's been asked by a number of companies so if you are preparing for coding interview you will find...
Word Break
word-break
Given a string `s` and a dictionary of strings `wordDict`, return `true` if `s` can be segmented into a space-separated sequence of one or more dictionary words. **Note** that the same word in the dictionary may be reused multiple times in the segmentation. **Example 1:** **Input:** s = "leetcode ", wordDict = \[ "...
null
Hash Table,String,Dynamic Programming,Trie,Memoization
Medium
140
329
hello friends so today we're gonna discuss another problem from the latest series i'm working on dynamic programming so here in this series i will discuss very good problems on dp from various platforms so this is a hard problem from lead code name longest increasing path in a matrix so as you can see you are given an ...
Longest Increasing Path in a Matrix
longest-increasing-path-in-a-matrix
Given an `m x n` integers `matrix`, return _the length of the longest increasing path in_ `matrix`. From each cell, you can either move in four directions: left, right, up, or down. You **may not** move **diagonally** or move **outside the boundary** (i.e., wrap-around is not allowed). **Example 1:** **Input:** matr...
null
Dynamic Programming,Depth-First Search,Breadth-First Search,Graph,Topological Sort,Memoization
Hard
null
506
okay so welcome to the fourth episode not sorry fifth episode of date code so for today we are going to see the question number 506 so let me reduce my streaming yeah so let's read the question you are given an integer array rule of size n that is they are providing an integer array where score of I is a score of ith a...
Relative Ranks
relative-ranks
You are given an integer array `score` of size `n`, where `score[i]` is the score of the `ith` athlete in a competition. All the scores are guaranteed to be **unique**. The athletes are **placed** based on their scores, where the `1st` place athlete has the highest score, the `2nd` place athlete has the `2nd` highest ...
null
Array,Sorting,Heap (Priority Queue)
Easy
null
91
hello hi guys good morningi I hope that you guys are doing well in this 91 decode ways although it's marked as a medium problem but I'll consider this as a hard problem considering the edge cases which this problem can encounter and also the follow-ups how it can have it has been follow-ups how it can have it has been ...
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
51
hi everyone welcome to the loophead today in this video we will be solving june lead good challenge and the question for today is and queens it is a very standard problem and it is marked as hard i wouldn't disagree to that but let us see what the question states um it is given that the end queen's puzzle is the proble...
N-Queens
n-queens
The **n-queens** puzzle is the problem of placing `n` queens on an `n x n` chessboard such that no two queens attack each other. Given an integer `n`, return _all distinct solutions to the **n-queens puzzle**_. You may return the answer in **any order**. Each solution contains a distinct board configuration of the n-...
null
Array,Backtracking
Hard
52,1043
907
and today i'm gonna do little the medium question 907 sum of subarray minimum minimums i think this is the most interesting question so far for using one monotonic stack this question is asking you if you are given an array of integers which is doesn't have a pattern for all the possible subarrays which has to be conti...
Sum of Subarray Minimums
koko-eating-bananas
Given an array of integers arr, find the sum of `min(b)`, where `b` ranges over every (contiguous) subarray of `arr`. Since the answer may be large, return the answer **modulo** `109 + 7`. **Example 1:** **Input:** arr = \[3,1,2,4\] **Output:** 17 **Explanation:** Subarrays are \[3\], \[1\], \[2\], \[4\], \[3,1\], \...
null
Array,Binary Search
Medium
788,1335,2188
162
hello and welcome to another Elite code video today we're going to be working on fine Peak element and this is a similar problem to the one I did before which find Peak element in a mountain array however in this problem there's a difference in this problem your array can have multiple Peaks so let's go through these e...
Find Peak Element
find-peak-element
A peak element is an element that is strictly greater than its neighbors. Given a **0-indexed** integer array `nums`, find a peak element, and return its index. If the array contains multiple peaks, return the index to **any of the peaks**. You may imagine that `nums[-1] = nums[n] = -∞`. In other words, an element is...
null
Array,Binary Search
Medium
882,2047,2273,2316
305
hi everyone welcome back to algorithm simplified this week we are going over number 305 number of islands 2. there's a hard level question in particular that uses union find data structure as its solution and it's definitely a prerequisite for this video that you understand at least what the union find data structure i...
Number of Islands II
number-of-islands-ii
You are given an empty 2D binary grid `grid` of size `m x n`. The grid represents a map where `0`'s represent water and `1`'s represent land. Initially, all the cells of `grid` are water cells (i.e., all the cells are `0`'s). We may perform an add land operation which turns the water at position into a land. You are g...
null
Array,Union Find
Hard
200,2198
238
chances are that you have already tried this problem and you're wondering why you're getting a wrong answer how hard could it be you are given an array and you have to find the product of all the integers except that one number right well this is a really fun problem to solve and i really love it most of the interviewe...
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,850
hello guys today we are going to see the DAT for question 1850 that is minimum adjacent waps to reach the K smallest number you are given a string num representing a large number and an integer K we call some integer wonderful if the permutation of the digits in Num and is greater in value than the num there can be man...
Minimum Adjacent Swaps to Reach the Kth Smallest Number
minimum-length-of-string-after-deleting-similar-ends
You are given a string `num`, representing a large integer, and an integer `k`. We call some integer **wonderful** if it is a **permutation** of the digits in `num` and is **greater in value** than `num`. There can be many wonderful integers. However, we only care about the **smallest-valued** ones. * For example, ...
If both ends have distinct characters, no more operations can be made. Otherwise, the only operation is to remove all of the same characters from both ends. We will do this as many times as we can. Note that if the length is equal 1 the answer is 1
Two Pointers,String
Medium
null
881
you must have solved these kind of problems when you were young there are a certain set of individuals who either want to cross a river or they want to cross a bridge correct and then there are these certain conditions that you must satisfy and then come up with a solution right so there is one such problem on lead cod...
Boats to Save People
loud-and-rich
You are given an array `people` where `people[i]` is the weight of the `ith` person, and an **infinite number of boats** where each boat can carry a maximum weight of `limit`. Each boat carries at most two people at the same time, provided the sum of the weight of those people is at most `limit`. Return _the minimum n...
null
Array,Depth-First Search,Graph,Topological Sort
Medium
null
52
hey everyone welcome back and let's write some more neat code today so today let's solve the problem n queens2 now we did already solve the first one on this channel and i would say that this one is actually a little bit easier than the first one so i do recommend checking out the first video as well if you want to and...
N-Queens II
n-queens-ii
The **n-queens** puzzle is the problem of placing `n` queens on an `n x n` chessboard such that no two queens attack each other. Given an integer `n`, return _the number of distinct solutions to the **n-queens puzzle**_. **Example 1:** **Input:** n = 4 **Output:** 2 **Explanation:** There are two distinct solutions ...
null
Backtracking
Hard
51
1,456
problems on the sliding window algorithm are really fun to solve that is because you can actually see how the window is sliding and how are you coming up with the solution one such problem is finding the maximum number of vowels in a substring of a given length so let's see what we can do about it Hello friends welcome...
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
1,431
okay so this problem here is leak code number 1431 kids with the greatest numbers of candies so basically given an array of candies and the integer extra candies where candies at index i represents the number of candies that the ice kid has for each kid check if there's a way to distribute extra candies among the kids ...
Kids With the Greatest Number of Candies
all-ancestors-of-a-node-in-a-directed-acyclic-graph
There are `n` kids with candies. You are given an integer array `candies`, where each `candies[i]` represents the number of candies the `ith` kid has, and an integer `extraCandies`, denoting the number of extra candies that you have. Return _a boolean array_ `result` _of length_ `n`_, where_ `result[i]` _is_ `true` _i...
Consider how reversing each edge of the graph can help us. How can performing BFS/DFS on the reversed graph help us find the ancestors of every node?
Depth-First Search,Breadth-First Search,Graph,Topological Sort
Medium
1912
234
hello everyone let's solve the problem pali drum linked list so basically a palindrome is anything really that reads the same forward and backward a notable example is an example like mom so mom reading forward and backward is essentially the same thing but we want to check if this linked list is a palindrome and as yo...
Palindrome Linked List
palindrome-linked-list
Given the `head` of a singly linked list, return `true` _if it is a_ _palindrome_ _or_ `false` _otherwise_. **Example 1:** **Input:** head = \[1,2,2,1\] **Output:** true **Example 2:** **Input:** head = \[1,2\] **Output:** false **Constraints:** * The number of nodes in the list is in the range `[1, 105]`. * ...
null
Linked List,Two Pointers,Stack,Recursion
Easy
9,125,206,2236
312
Hello hello everyone welcome back to my YouTube channel special barrenness today we are going to do just the balance problem okay in this subscribe our page like in the beginning I will take it as if it is about the meaning in the now so this I will finish it then Now I would like to say that your gift is fine, I notic...
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
1,379
Jai Hind this problem is search for not in a given point will not give 1872 The Video then subscribe to the Channel and subscribe the Channel ko hai sonth approach vich can do me to return hai panch lootere example subscribe and subscribe the Channel subscribe our Supervisor Target And Let Us Know How We Can Do It So Y...
Find a Corresponding Node of a Binary Tree in a Clone of That Tree
reconstruct-a-2-row-binary-matrix
Given two binary trees `original` and `cloned` and given a reference to a node `target` in the original tree. The `cloned` tree is a **copy of** the `original` tree. Return _a reference to the same node_ in the `cloned` tree. **Note** that you are **not allowed** to change any of the two trees or the `target` node a...
You cannot do anything about colsum[i] = 2 case or colsum[i] = 0 case. Then you put colsum[i] = 1 case to the upper row until upper has reached. Then put the rest into lower row. Fill 0 and 2 first, then fill 1 in the upper row or lower row in turn but be careful about exhausting permitted 1s in each row.
Array,Greedy,Matrix
Medium
1711
744
Welcome back to my channel, so today's challenge is Find Smallest Letter &gt; Target, challenge is Find Smallest Letter &gt; Target, challenge is Find Smallest Letter &gt; Target, so in this problem statement, what have you given us? And you have been given a character from the target names and what you have to do is t...
Find Smallest Letter Greater Than Target
network-delay-time
You are given an array of characters `letters` that is sorted in **non-decreasing order**, and a character `target`. There are **at least two different** characters in `letters`. Return _the smallest character in_ `letters` _that is lexicographically greater than_ `target`. If such a character does not exist, return t...
We visit each node at some time, and if that time is better than the fastest time we've reached this node, we travel along outgoing edges in sorted order. Alternatively, we could use Dijkstra's algorithm.
Depth-First Search,Breadth-First Search,Graph,Heap (Priority Queue),Shortest Path
Medium
2151,2171
352
today we're gonna be working on lead code question number 352 and data stream as disjoint intervals uh given a data stream input of non-negative a data stream input of non-negative a data stream input of non-negative integers A1 A2 up to a and summarize and the numbers seen so far as a list of disjoint intervals so imp...
Data Stream as Disjoint Intervals
data-stream-as-disjoint-intervals
Given a data stream input of non-negative integers `a1, a2, ..., an`, summarize the numbers seen so far as a list of disjoint intervals. Implement the `SummaryRanges` class: * `SummaryRanges()` Initializes the object with an empty stream. * `void addNum(int value)` Adds the integer `value` to the stream. * `int...
null
Binary Search,Design,Ordered Set
Hard
228,436,715
1,029
The latest solution to two cities having problem in this problem is enter a particular company to call candidates for interview and this number of candidates actually and candidates can be divided between two cities of candidates can go to do subscribe list subscribe and subscribe the Video then Sainik Candidate one tw...
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
1,833
here I present the third of January lead code challenge the problem that we have in today is delete columns to make them sorted this question is an easy level question based on the concept of strings and I know most of my subscribers rather all of them would be able to solve this question by themselves for those who ar...
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
234
we are looking at lead code number two three four it's called palindrome linked list and this one can be a little bit confusing but we'll go through it step by step it's not too bad once we get our head around it okay so given the head of a single singly linked list return true if it's a palindrome example one we have ...
Palindrome Linked List
palindrome-linked-list
Given the `head` of a singly linked list, return `true` _if it is a_ _palindrome_ _or_ `false` _otherwise_. **Example 1:** **Input:** head = \[1,2,2,1\] **Output:** true **Example 2:** **Input:** head = \[1,2\] **Output:** false **Constraints:** * The number of nodes in the list is in the range `[1, 105]`. * ...
null
Linked List,Two Pointers,Stack,Recursion
Easy
9,125,206,2236
56
So hello friends, today we are going to solve a problem whose name is numbers interval and right, so what is there in this problem, we will have instruments given to us, okay what does entrance mean that entrance means any work which is Also, I started the work and what time did it start and what time did it finish? Fo...
Merge Intervals
merge-intervals
Given an array of `intervals` where `intervals[i] = [starti, endi]`, merge all overlapping intervals, and return _an array of the non-overlapping intervals that cover all the intervals in the input_. **Example 1:** **Input:** intervals = \[\[1,3\],\[2,6\],\[8,10\],\[15,18\]\] **Output:** \[\[1,6\],\[8,10\],\[15,18\]\...
null
Array,Sorting
Medium
57,252,253,495,616,715,761,768,1028,2297,2319
440
hello friends happy new year today we will solve the case smallest in lexicographic order this will be the last question we solved in the year of 2020 given integers n and k find the electrical graphically ace a case smallest integer in the range from 1 to n for example if the input n is 13 and case 2 we know that the ...
K-th Smallest in Lexicographical Order
k-th-smallest-in-lexicographical-order
Given two integers `n` and `k`, return _the_ `kth` _lexicographically smallest integer in the range_ `[1, n]`. **Example 1:** **Input:** n = 13, k = 2 **Output:** 10 **Explanation:** The lexicographical order is \[1, 10, 11, 12, 13, 2, 3, 4, 5, 6, 7, 8, 9\], so the second smallest number is 10. **Example 2:** **Inp...
null
Trie
Hard
null
208
it try is one of those data types you don't really get to hear too much but in this example I'm going to show you how we can use it and how it's really powerful so as you can see the imagine I was trying to store these words so I basically if Amazon amazing a poor a pain the prior application and applicant and as you c...
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
459
hey everyone welcome back and today we'll be doing another lead code four five nine repeated substring pattern an easy one given a string as check if it can be uh constructed by taking a substring of it and appending multiple of copies of a substring together so we have a string a b so if a b is a substring then we can...
Repeated Substring Pattern
repeated-substring-pattern
Given a string `s`, check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. **Example 1:** **Input:** s = "abab " **Output:** true **Explanation:** It is the substring "ab " twice. **Example 2:** **Input:** s = "aba " **Output:** false **Example 3:** ...
null
String,String Matching
Easy
28,686
485
Hello gas I am just Amrita welcome back to me channel technosys sonrly court series today bill b solving problem number four 85 date is max consecutive descent so let first understand d problem life en binary aernammas return d maximum number of consecutive once in the are so in the Example You can see they have bin Ji...
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
352
always welcome to deep codes and in today's video we will discuss liquid questions 352 that says data stream as disjoint intervals so this is the problem of the day uh and yeah I'm sorry for uh that I'm making a video very late uh usually I make the video of the daily question in the early morning but since I was trave...
Data Stream as Disjoint Intervals
data-stream-as-disjoint-intervals
Given a data stream input of non-negative integers `a1, a2, ..., an`, summarize the numbers seen so far as a list of disjoint intervals. Implement the `SummaryRanges` class: * `SummaryRanges()` Initializes the object with an empty stream. * `void addNum(int value)` Adds the integer `value` to the stream. * `int...
null
Binary Search,Design,Ordered Set
Hard
228,436,715
77
hi this is question combinations in this example n equal 4 and k equal to and these are all possible combinations and each combination has number between 1 and n and every compilation has exactly two numbers now we will use bitmask to solve this question now n equal 4 that means the possible numbers are between one and...
Combinations
combinations
Given two integers `n` and `k`, return _all possible combinations of_ `k` _numbers chosen from the range_ `[1, n]`. You may return the answer in **any order**. **Example 1:** **Input:** n = 4, k = 2 **Output:** \[\[1,2\],\[1,3\],\[1,4\],\[2,3\],\[2,4\],\[3,4\]\] **Explanation:** There are 4 choose 2 = 6 total combin...
null
Backtracking
Medium
39,46
1,679
hey everyone this is side hope you are doing good so let's start with the question so the question is maximum number of case sum pairs okay so what you are given an integer that in nums and an integer k what you have to do in one operation you can pick two numbers from the array whose sums equal k and basically you hav...
Max Number of K-Sum Pairs
shortest-subarray-to-be-removed-to-make-array-sorted
You are given an integer array `nums` and an integer `k`. In one operation, you can pick two numbers from the array whose sum equals `k` and remove them from the array. Return _the maximum number of operations you can perform on the array_. **Example 1:** **Input:** nums = \[1,2,3,4\], k = 5 **Output:** 2 **Explana...
The key is to find the longest non-decreasing subarray starting with the first element or ending with the last element, respectively. After removing some subarray, the result is the concatenation of a sorted prefix and a sorted suffix, where the last element of the prefix is smaller than the first element of the suffix...
Array,Two Pointers,Binary Search,Stack,Monotonic Stack
Medium
null
1,704
hey everyone today we are going to solve lead problem number 1 1704 which is determine if string halves are alike this problem has been asked in Amazon maybe it was asked in screen around because it's a pretty simple problem okay let's have a look on the problem statement in this problem we are given a string s of even...
Determine if String Halves Are Alike
special-positions-in-a-binary-matrix
You are given a string `s` of even length. Split this string into two halves of equal lengths, and let `a` be the first half and `b` be the second half. Two strings are **alike** if they have the same number of vowels (`'a'`, `'e'`, `'i'`, `'o'`, `'u'`, `'A'`, `'E'`, `'I'`, `'O'`, `'U'`). Notice that `s` contains uppe...
Keep track of 1s in each row and in each column. Then while iterating over matrix, if the current position is 1 and current row as well as current column contains exactly one occurrence of 1.
Array,Matrix
Easy
null
723
hey everybody this is Larry this is me going to do week four of the August weekly challenge hit the like button hit the Subscribe button join me on Discord let me know what you think about this Farm it is a premium Farm I haven't done it before yet apparently so let's take a look Candy Crush a game that I played a litt...
Candy Crush
candy-crush
This question is about implementing a basic elimination algorithm for Candy Crush. Given an `m x n` integer array `board` representing the grid of candy where `board[i][j]` represents the type of candy. A value of `board[i][j] == 0` represents that the cell is empty. The given board represents the state of the game f...
Carefully perform the "crush" and "gravity" steps. In the crush step, flag each candy that should be removed, then go through and crush each flagged candy. In the gravity step, collect the candy in each column and then rewrite the column appropriately. Do these steps repeatedly until there's no work left to do.
Array,Two Pointers,Matrix,Simulation
Medium
null
307
hi everyone my name is contributor i'm trying to solve the zero liquid challenge problem the problem is ransom query mutable so the problem is that given an integer add a number and handle the multiple query of following tabs there is an update of that element and there is the index has been given and all up to uh anot...
Range Sum Query - Mutable
range-sum-query-mutable
Given an integer array `nums`, handle multiple queries of the following types: 1. **Update** the value of an element in `nums`. 2. Calculate the **sum** of the elements of `nums` between indices `left` and `right` **inclusive** where `left <= right`. Implement the `NumArray` class: * `NumArray(int[] nums)` Initi...
null
Array,Design,Binary Indexed Tree,Segment Tree
Medium
303,308
426
hello guys now I try to solve the convert binary search tree to Sochi the doubly linked list this is our frequently asked question by Facebook convert the best teach you are so heater circular doublings the same place think of the left and right pointers at the till trick is the next point of in a doubly linked list le...
Convert Binary Search Tree to Sorted Doubly Linked List
convert-binary-search-tree-to-sorted-doubly-linked-list
Convert a **Binary Search Tree** to a sorted **Circular Doubly-Linked List** in place. You can think of the left and right pointers as synonymous to the predecessor and successor pointers in a doubly-linked list. For a circular doubly linked list, the predecessor of the first element is the last element, and the succe...
null
null
Medium
null
537
Loot Hello Everyone Welcome 24th After Speaker Channel Lotus Press Complex Number Krishna In This Question Veer And Complex Number To Subscribe The Answer Will Be Complex Numbers In Excel Video subscribe and subscribe A Much Better Solution By Giving Us Can Sit Alone Without Peer Wants To Basically Real And Imaginary T...
Complex Number Multiplication
complex-number-multiplication
A [complex number](https://en.wikipedia.org/wiki/Complex_number) can be represented as a string on the form `"**real**+**imaginary**i "` where: * `real` is the real part and is an integer in the range `[-100, 100]`. * `imaginary` is the imaginary part and is an integer in the range `[-100, 100]`. * `i2 == -1`. ...
null
Math,String,Simulation
Medium
null
92
hello everyone let's look at reverse linked list 2. if you didn't watch the first question for this series feel free to go back and look at it first that's question 206 and for this question we come up with a very easy solution and for this question we will refer to that solution let's look at the problem statement we ...
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
233
hello friends today let's solve number of digital one give an integer and count the total number of digital one appearing in on all non-negative integers less than or equal non-negative integers less than or equal non-negative integers less than or equal to an if an equal to 13 will output 6y because there is 1 10 11 1...
Number of Digit One
number-of-digit-one
Given an integer `n`, count _the total number of digit_ `1` _appearing in all non-negative integers less than or equal to_ `n`. **Example 1:** **Input:** n = 13 **Output:** 6 **Example 2:** **Input:** n = 0 **Output:** 0 **Constraints:** * `0 <= n <= 109`
Beware of overflow.
Math,Dynamic Programming,Recursion
Hard
172,1068
1,071
I lead code 1071 greatest common divisor of strings for two strings s t we say t divides s if and only if s equals t plus whatever Plus t i e t is concatenated with itself one or more times given two strings string one and string two return the largest string X such that X divides both string one and string two so esse...
Greatest Common Divisor of Strings
binary-prefix-divisible-by-5
For two strings `s` and `t`, we say "`t` divides `s` " if and only if `s = t + ... + t` (i.e., `t` is concatenated with itself one or more times). Given two strings `str1` and `str2`, return _the largest string_ `x` _such that_ `x` _divides both_ `str1` _and_ `str2`. **Example 1:** **Input:** str1 = "ABCABC ", str2...
If X is the first i digits of the array as a binary number, then 2X + A[i] is the first i+1 digits.
Array
Easy
null
344
our question is the reverse string question specifically the question asked the store versus string that is array of characters so this is a easy level question but this question asks us to reverse the string simply put when we think of a string as a data structure we can think about it almost as it can be broken up in...
Reverse String
reverse-string
Write a function that reverses a string. The input string is given as an array of characters `s`. You must do this by modifying the input array [in-place](https://en.wikipedia.org/wiki/In-place_algorithm) with `O(1)` extra memory. **Example 1:** **Input:** s = \["h","e","l","l","o"\] **Output:** \["o","l","l","e","h...
The entire logic for reversing a string is based on using the opposite directional two-pointer approach!
Two Pointers,String,Recursion
Easy
345,541
1,498
hey what's up guys uh this is chong here again so this time uh it called number 1498 number of subsequences that satisfy the given sum condition okay so you're given like a ray of integers right and the integer target so your task is to return the number of the non-empty the non-empty the non-empty subsequences from th...
Number of Subsequences That Satisfy the Given Sum Condition
find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree
You are given an array of integers `nums` and an integer `target`. Return _the number of **non-empty** subsequences of_ `nums` _such that the sum of the minimum and maximum element on it is less or equal to_ `target`. Since the answer may be too large, return it **modulo** `109 + 7`. **Example 1:** **Input:** nums =...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Medium
null
298
one welcome to Leo's Channel let's do some lead code today so this question is a binary tree longest consecutive sequence so now we were given the root of a binary tree return the length of the longest consecutive sequence path what does it mean by consecutive sequence path so a consecutive sequence path is a path wher...
Binary Tree Longest Consecutive Sequence
binary-tree-longest-consecutive-sequence
Given the `root` of a binary tree, return _the length of the longest **consecutive sequence path**_. A **consecutive sequence path** is a path where the values **increase by one** along the path. Note that the path can start **at any node** in the tree, and you cannot go from a node to its parent in the path. **Exam...
null
Tree,Depth-First Search,Binary Tree
Medium
128,549,1416
1,802
hi guys welcome to algorithms Made Easy my name is khushboo and in this video we are going to see the other approach for solving the question maximum value at a given index in a bounded array in the previous video we have already seen how we can go from Brute Force to a little optimized approach in order to solve this ...
Maximum Value at a Given Index in a Bounded Array
number-of-students-unable-to-eat-lunch
You are given three positive integers: `n`, `index`, and `maxSum`. You want to construct an array `nums` (**0-indexed**) that satisfies the following conditions: * `nums.length == n` * `nums[i]` is a **positive** integer where `0 <= i < n`. * `abs(nums[i] - nums[i+1]) <= 1` where `0 <= i < n-1`. * The sum of a...
Simulate the given in the statement Calculate those who will eat instead of those who will not.
Array,Stack,Queue,Simulation
Easy
2195
456
hey guys welcome back to another video and today we're going to be talking the lead code question 132 pattern all right so in this question we're going to be given an array of n integers called nums and a 132 pattern is a subsequence of three integer numbers so we have nums i nums j and nums k such that i is less than ...
132 Pattern
132-pattern
Given an array of `n` integers `nums`, a **132 pattern** is a subsequence of three integers `nums[i]`, `nums[j]` and `nums[k]` such that `i < j < k` and `nums[i] < nums[k] < nums[j]`. Return `true` _if there is a **132 pattern** in_ `nums`_, otherwise, return_ `false`_._ **Example 1:** **Input:** nums = \[1,2,3,4\] ...
null
Array,Binary Search,Stack,Monotonic Stack,Ordered Set
Medium
null
1,673
Loot hello late think that arvind c point most competitive most software alliance photo interior and interior's and that strat andher properties subsequent software details example latest 12345 v5 subscribe number two a for better understanding wicket on that vikram seth subscribe to consider all subscribe to A rhythm ...
Find the Most Competitive Subsequence
find-the-most-competitive-subsequence
Given an integer array `nums` and a positive integer `k`, return _the most **competitive** subsequence of_ `nums` _of size_ `k`. An array's subsequence is a resulting sequence obtained by erasing some (possibly zero) elements from the array. We define that a subsequence `a` is more **competitive** than a subsequence ...
null
null
Medium
null
938
hello hi guys good morning welcome back to a new video in this we're going to see problem range sum of PST although I have to hide the company Tax because Li could might strike it so for you it is my imagination again you know I know that uh it has been asked by Facebook Google and Amazon especially by Facebook in the ...
Range Sum of BST
numbers-at-most-n-given-digit-set
Given the `root` node of a binary search tree and two integers `low` and `high`, return _the sum of values of all nodes with a value in the **inclusive** range_ `[low, high]`. **Example 1:** **Input:** root = \[10,5,15,3,7,null,18\], low = 7, high = 15 **Output:** 32 **Explanation:** Nodes 7, 10, and 15 are in the ra...
null
Array,Math,Binary Search,Dynamic Programming
Hard
null
703
hey everyone welcome back and today we'll be doing another lead chord problem 703 K's largest element in a stream so stream means that the input is coming and we have to return the output likewise and this is an easy one design a class to find the kth element largest element in the Stream note that the case largest ele...
Kth Largest Element in a Stream
kth-largest-element-in-a-stream
Design a class to find the `kth` largest element in a stream. Note that it is the `kth` largest element in the sorted order, not the `kth` distinct element. Implement `KthLargest` class: * `KthLargest(int k, int[] nums)` Initializes the object with the integer `k` and the stream of integers `nums`. * `int add(int...
null
null
Easy
null
1,288
hey guys welcome back to another video and today we're going to be solving the leakout question remove covered intervals all right so this question is pretty similar to some other questions that we sold such as teemo attacking and a few other ones which i'll link down below if you do want to check out anyway so in this...
Remove Covered Intervals
maximum-subarray-sum-with-one-deletion
Given an array `intervals` where `intervals[i] = [li, ri]` represent the interval `[li, ri)`, remove all intervals that are covered by another interval in the list. The interval `[a, b)` is covered by the interval `[c, d)` if and only if `c <= a` and `b <= d`. Return _the number of remaining intervals_. **Example 1:...
How to solve this problem if no deletions are allowed ? Try deleting each element and find the maximum subarray sum to both sides of that element. To do that efficiently, use the idea of Kadane's algorithm.
Array,Dynamic Programming
Medium
null
383
That Welcome back friends today we are going to solve liquid problem 2017 currency note Please subscribe to the Channel If you are looking for material for laker java j2ee interviews where asking solutions for on this channel you have created a lift co dog solutions for the problems S Well S Computer Science Related Vi...
Ransom Note
ransom-note
Given two strings `ransomNote` and `magazine`, return `true` _if_ `ransomNote` _can be constructed by using the letters from_ `magazine` _and_ `false` _otherwise_. Each letter in `magazine` can only be used once in `ransomNote`. **Example 1:** **Input:** ransomNote = "a", magazine = "b" **Output:** false **Example ...
null
Hash Table,String,Counting
Easy
691
713
hey what's up guys think white here I detect encoding stuff on twitch and YouTube check the description for all my information I explained these algorithm the data structures problems for people that don't get them so I do them on leak code hacker Hank I got playlists maybe I'll do more platforms in the future this is ...
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
35
hello everyone let's look at search insert position the problem statement is we're giving a sorted array of distinct integers and the target value we want to return the index if the target is found if not we want to return the index where it would be if we insert it in order for the first example 1 3 5 6 target is 5 we...
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
96
uh discussions is unique binary surgery so you are given the integer answer return a number of the structurally unique PST so once again this question is really challenged and I'm going to just try my best to explain so when n equal to one you can have what the node for itself right so it could be a node one for the tr...
Unique Binary Search Trees
unique-binary-search-trees
Given an integer `n`, return _the number of structurally unique **BST'**s (binary search trees) which has exactly_ `n` _nodes of unique values from_ `1` _to_ `n`. **Example 1:** **Input:** n = 3 **Output:** 5 **Example 2:** **Input:** n = 1 **Output:** 1 **Constraints:** * `1 <= n <= 19`
null
Math,Dynamic Programming,Tree,Binary Search Tree,Binary Tree
Medium
95
1,624
Hello and welcome to channel again this is Shaur Awasti and today we will talk about easy level problem of lead quote which is largest sub string between two equal characters so basically what we have to do here is we are given a string in the input okay so we have to Taking that input string, we have to tell that the ...
Largest Substring Between Two Equal Characters
clone-binary-tree-with-random-pointer
Given a string `s`, return _the length of the longest substring between two equal characters, excluding the two characters._ If there is no such substring return `-1`. A **substring** is a contiguous sequence of characters within a string. **Example 1:** **Input:** s = "aa " **Output:** 0 **Explanation:** The optim...
Traverse the tree, keep a hashtable with you and create a nodecopy for each node in the tree. Start traversing the original tree again and connect the left, right and random pointers in the cloned tree the same way as the original tree with the help of the hashtable.
Hash Table,Tree,Depth-First Search,Breadth-First Search,Binary Tree
Medium
133,138,1634
116
hi guys hope you're doing great our today's question is populating next right pointers in each node so the question says you're given a perfect binary tree where all leaves are on the same level and every parent has two children so that's what the perfect binary tree means the binary tree has the following definition s...
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
40
hey guys how's everything going let's take a look at number 40 combination some tool actually we just finished 39 combination sound so there this is just like a slightly different version of the comp problem we're still given a collection of candidates numbers and target find all unique combinations blah but this is di...
Combination Sum II
combination-sum-ii
Given a collection of candidate numbers (`candidates`) and a target number (`target`), find all unique combinations in `candidates` where the candidate numbers sum to `target`. Each number in `candidates` may only be used **once** in the combination. **Note:** The solution set must not contain duplicate combinations....
null
Array,Backtracking
Medium
39
376
welcome to march's leeco challenge today's problem is wiggle subsequence given an integer array we turn the length of the longest wiggle sequence a wiggle sequence is a sequence where the difference was between successive numbers alternate between positive and negative in other words the difference from the previous ar...
Wiggle Subsequence
wiggle-subsequence
A **wiggle sequence** is a sequence where the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either positive or negative. A sequence with one element and a sequence with two non-equal elements are trivially wiggle sequences. * For ...
null
Array,Dynamic Programming,Greedy
Medium
2271
822
today i'm gonna do uh lead code 822 it's called card flipping game i'll be given uncards with a positive integer printed on the front and back of each card uh the front number and back number of each card could be different or could be the same and we'll try to flip any number of the cards and after the flip we will pi...
Card Flipping Game
unique-morse-code-words
You are given two **0-indexed** integer arrays `fronts` and `backs` of length `n`, where the `ith` card has the positive integer `fronts[i]` printed on the front and `backs[i]` printed on the back. Initially, each card is placed on a table such that the front number is facing up and the other is facing down. You may fl...
null
Array,Hash Table,String
Easy
null
1,002
find the common characters now the question says given an array a of strings made only from lower cases so our string is going to be made of lowercases return a list of all characters that show up in all strings within the list including duplicates so you want to find a character or a letter that occurs shows up and al...
Find Common Characters
maximum-width-ramp
Given a string array `words`, return _an array of all characters that show up in all strings within the_ `words` _(including duplicates)_. You may return the answer in **any order**. **Example 1:** **Input:** words = \["bella","label","roller"\] **Output:** \["e","l","l"\] **Example 2:** **Input:** words = \["cool"...
null
Array,Stack,Monotonic Stack
Medium
null
349
hey everyone today we'll be solving lead problem number 349 intersection of two arrays in this problem we are given two integer array nums one and nums two and we have to return the array which is intersection of these two and each element in the result must be unique and you may also return the result in any order oka...
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