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
237
okay so this problem is called delete node in a linked list and when you approach linked list problems just think about the different ways you can access a linked list or modify a linked list and just keep in mind it's just a data structure that we basically will write code to essentially connect one item to the next s...
Delete Node in a Linked List
delete-node-in-a-linked-list
There is a singly-linked list `head` and we want to delete a node `node` in it. You are given the node to be deleted `node`. You will **not be given access** to the first node of `head`. All the values of the linked list are **unique**, and it is guaranteed that the given node `node` is not the last node in the linke...
null
Linked List
Easy
203
819
all right this leaf code question is called most common word it says given a paragraph and a list of banned words returned the most frequent word that is not in the list of banned words it's guaranteed there's at least one word that isn't banned and that the answer is unique words in the list of banned words are given ...
Most Common Word
minimum-swaps-to-make-sequences-increasing
Given a string `paragraph` and a string array of the banned words `banned`, return _the most frequent word that is not banned_. It is **guaranteed** there is **at least one word** that is not banned, and that the answer is **unique**. The words in `paragraph` are **case-insensitive** and the answer should be returned ...
null
Array,Dynamic Programming
Hard
2234
890
alright hey everyone we're gonna get started with the next problem it is problem number 890 find and replace pattern has an acceptance rate of 69 and 7% nice treated as a meeting let's just 7% nice treated as a meeting let's just 7% nice treated as a meeting let's just get started so as we have a list of words in the p...
Find and Replace Pattern
lemonade-change
Given a list of strings `words` and a string `pattern`, return _a list of_ `words[i]` _that match_ `pattern`. You may return the answer in **any order**. A word matches the pattern if there exists a permutation of letters `p` so that after replacing every letter `x` in the pattern with `p(x)`, we get the desired word....
null
Array,Greedy
Easy
null
995
hey what's up guys John here and so this time let's take a look at this lead code problem number 995 minimum number of K consecutive beta flips it's a hard problem it's kind of yeah it's kind of hard if you are really want to get them to max the best performance solutions okay let's take a look at this problem right so...
Minimum Number of K Consecutive Bit Flips
minimum-number-of-k-consecutive-bit-flips
You are given a binary array `nums` and an integer `k`. A **k-bit flip** is choosing a **subarray** of length `k` from `nums` and simultaneously changing every `0` in the subarray to `1`, and every `1` in the subarray to `0`. Return _the minimum number of **k-bit flips** required so that there is no_ `0` _in the arra...
null
null
Hard
null
120
hey what is going on everyone today we are working on lead code number 120 it's called triangle this is a very good problem to get a good understanding of how dynamic programming works it uses a method called tabulation and it's uh it's a good way to kind of understand how to approach these types of problems when they ...
Triangle
triangle
Given a `triangle` array, return _the minimum path sum from top to bottom_. For each step, you may move to an adjacent number of the row below. More formally, if you are on index `i` on the current row, you may move to either index `i` or index `i + 1` on the next row. **Example 1:** **Input:** triangle = \[\[2\],\[...
null
Array,Dynamic Programming
Medium
null
141
given the links list write a program to determine whether this given linked list has a psycho in it how can you do that's today's video let's get into it hi everyone my name is Steve today we are going through a legal problem 141 linkless cycle very simple and straightforward problem but it's a very classic one it help...
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
143
today we are going to solve reorder list this is a medium kind of problem on lead code and this is another problem on linked list let's see our problem statement we are given a head of a single link list and we need to reorder the nodes of the linked list after reordering our first node will pair up with the last node ...
Reorder List
reorder-list
You are given the head of a singly linked-list. The list can be represented as: L0 -> L1 -> ... -> Ln - 1 -> Ln _Reorder the list to be on the following form:_ L0 -> Ln -> L1 -> Ln - 1 -> L2 -> Ln - 2 -> ... You may not modify the values in the list's nodes. Only nodes themselves may be changed. **Example 1:** **...
null
Linked List,Two Pointers,Stack,Recursion
Medium
2216
101
this binary tree question is one of the most asked by Fang companies so let's check it out the problem is called symmetric tree and it's pretty easy to understand we're given the root of a binary tree and we need to check whether it is a mirror of itself I.E symmetric it is a mirror of itself I.E symmetric it is a mirr...
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
71
hello welcome today let's try to solve another Lal problem 71 simplify pass so we're giving a pass so this pass is just a stram so there are many different kind of characters so one of the case is like there are two dots and there may also have two slashes and it can also have like three slashes but it doesn't matter s...
Simplify Path
simplify-path
Given a string `path`, which is an **absolute path** (starting with a slash `'/'`) to a file or directory in a Unix-style file system, convert it to the simplified **canonical path**. In a Unix-style file system, a period `'.'` refers to the current directory, a double period `'..'` refers to the directory up a level,...
null
String,Stack
Medium
null
1,877
okay let's do leak code uh 1877 minimize maximum pair sum in Array uh this is kind of a confusing intro to the question basically they want you to make pairs in this array and sum them and then find what the largest sum is but the pairs have to be the smallest pairs you can make so if you look at this example the easy ...
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
153
another day another problem so let's Solve IT hello guys I hope you are all doing well so in this video we're gonna solve the problem find the minimum and rotated sorted array so let's get started first what do we mean by rotated sorted array rotated sorted arrays when you grab a sorted array and rotated it at some piv...
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
1,846
so today we are going to solve problem number 1846 on lead code maximum element after decreasing and re rearranging the elements this problem is rated in medium but I don't think it is medium problem it is very easy problem and that we will solve in few minutes so the problem statement is you are given an array of posi...
Maximum Element After Decreasing and Rearranging
maximum-element-after-decreasing-and-rearranging
You are given an array of positive integers `arr`. Perform some operations (possibly none) on `arr` so that it satisfies these conditions: * The value of the **first** element in `arr` must be `1`. * The absolute difference between any 2 adjacent elements must be **less than or equal to** `1`. In other words, `abs...
null
null
Medium
null
202
hello all uh welcome to another real quick problem so today we are going to solve a problem with 202 happy numbers so in this problem basically uh it is given that if number is 19 then if you add every digit square of every digit of the number and then you keep doing that and unless you reach so finding a result but if...
Happy Number
happy-number
Write an algorithm to determine if a number `n` is happy. A **happy number** is a number defined by the following process: * Starting with any positive integer, replace the number by the sum of the squares of its digits. * Repeat the process until the number equals 1 (where it will stay), or it **loops endlessly ...
null
Hash Table,Math,Two Pointers
Easy
141,258,263,2076
1,675
hi everyone welcome back to the channel and today I'm going to look into lead code really challenge problem number 1675 minimize deviation in Array so uh this was a really hard problem which I you know honestly being also not able to tackle so I took a help of another Channel called meat code IO and I'm gonna link the ...
Minimize Deviation in Array
magnetic-force-between-two-balls
You are given an array `nums` of `n` positive integers. You can perform two types of operations on any element of the array any number of times: * If the element is **even**, **divide** it by `2`. * For example, if the array is `[1,2,3,4]`, then you can do this operation on the last element, and the array wil...
If you can place balls such that the answer is x then you can do it for y where y < x. Similarly if you cannot place balls such that the answer is x then you can do it for y where y > x. Binary search on the answer and greedily see if it is possible.
Array,Binary Search,Sorting
Medium
2188
628
hello in this video we are going to discuss the lead code problem number 628 maximum product of three numbers in this problem they will give you an array right they will give you an array like this ah to five then what there are two five three one four like this they will give you an array you need to return the maximu...
Maximum Product of Three Numbers
maximum-product-of-three-numbers
Given an integer array `nums`, _find three numbers whose product is maximum and return the maximum product_. **Example 1:** **Input:** nums = \[1,2,3\] **Output:** 6 **Example 2:** **Input:** nums = \[1,2,3,4\] **Output:** 24 **Example 3:** **Input:** nums = \[-1,-2,-3\] **Output:** -6 **Constraints:** * `3 <...
null
Array,Math,Sorting
Easy
152
211
hey guys welcome back hope you guys are doing well so today let's solve the problem from lead code platform daily challenges okay which is design ad and search words data structure okay let's read the question design a data structure that supports adding new words and finding if testing matches any previously added str...
Design Add and Search Words Data Structure
design-add-and-search-words-data-structure
Design a data structure that supports adding new words and finding if a string matches any previously added string. Implement the `WordDictionary` class: * `WordDictionary()` Initializes the object. * `void addWord(word)` Adds `word` to the data structure, it can be matched later. * `bool search(word)` Returns ...
You should be familiar with how a Trie works. If not, please work on this problem: Implement Trie (Prefix Tree) first.
String,Depth-First Search,Design,Trie
Medium
208,746
226
so today we would be looking at how to invert a binary tree on lead code so basically this question has come in many interviews like google facebook microsoft linkedin so we have been given the root of a binary and we have to invert the tree and return its root so from the figure itself you can see the root note would ...
Invert Binary Tree
invert-binary-tree
Given the `root` of a binary tree, invert the tree, and return _its root_. **Example 1:** **Input:** root = \[4,2,7,1,3,6,9\] **Output:** \[4,7,2,9,6,3,1\] **Example 2:** **Input:** root = \[2,1,3\] **Output:** \[2,3,1\] **Example 3:** **Input:** root = \[\] **Output:** \[\] **Constraints:** * The number of n...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Easy
null
1,293
hey everybody this is larry this is day 25th of the september lego daily challenge hit the like button to subscribe and join me on discord let me know what you think of this problem and in general uh and yeah especially discord because people are already find the india um yeah so today i'm still in spain in the city of...
Shortest Path in a Grid with Obstacles Elimination
three-consecutive-odds
You are given an `m x n` integer matrix `grid` where each cell is either `0` (empty) or `1` (obstacle). You can move up, down, left, or right from and to an empty cell in **one step**. Return _the minimum number of **steps** to walk from the upper left corner_ `(0, 0)` _to the lower right corner_ `(m - 1, n - 1)` _giv...
Check every three consecutive numbers in the array for parity.
Array
Easy
null
1,011
um hello so today we are going to do this problem which is part of lead code daily challenge so the problem is um capacity to ship packages within D days and so what this problem says is we get um sort of a conveyor belt that has packages that we need to ship from one port to another within a number of days right and s...
Capacity To Ship Packages Within D Days
flip-binary-tree-to-match-preorder-traversal
A conveyor belt has packages that must be shipped from one port to another within `days` days. The `ith` package on the conveyor belt has a weight of `weights[i]`. Each day, we load the ship with packages on the conveyor belt (in the order given by `weights`). We may not load more weight than the maximum weight capaci...
null
Tree,Depth-First Search,Binary Tree
Medium
null
128
as soon as you read this problem you feel that hey this is such a direct question and maybe with some thinking and some manipulations I will be able to arrive at an answer right but what happens when you try to form it you start running into problems and you realize how tricky this is it becomes even interesting when y...
Longest Consecutive Sequence
longest-consecutive-sequence
Given an unsorted array of integers `nums`, return _the length of the longest consecutive elements sequence._ You must write an algorithm that runs in `O(n)` time. **Example 1:** **Input:** nums = \[100,4,200,1,3,2\] **Output:** 4 **Explanation:** The longest consecutive elements sequence is `[1, 2, 3, 4]`. Therefor...
null
Array,Hash Table,Union Find
Medium
298,2278
82
this video we're going to look at a legal problem called remove lubricants from sorted list number two so given the head of the sorted linked list delete all the notes that have duplicate numbers right so you can see here we have a link list and note 3 has more is our is a duplicate nodes right so you can see here we h...
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
30
all right so today we'll be talking about the substring with concatenation of all words problem you are given a substring s and an array of strings words of the same length return all starting indices of substrings in s that is a concatenation of each word in words at least once in any order and without any intervening...
Substring with Concatenation of All Words
substring-with-concatenation-of-all-words
You are given a string `s` and an array of strings `words`. All the strings of `words` are of **the same length**. A **concatenated substring** in `s` is a substring that contains all the strings of any permutation of `words` concatenated. * For example, if `words = [ "ab ", "cd ", "ef "]`, then `"abcdef "`, `"abef...
null
Hash Table,String,Sliding Window
Hard
76
968
Ajay Hello friends from Rajneesh Kumar website on coding and today we are going to solve a problem whose name is Cameras in Binary Tree, so let me explain it to you once, after that we will move towards the solution, okay see. First of all, there will be a water yavan, so you have a note about where to maintain this tr...
Binary Tree Cameras
beautiful-array
You are given the `root` of a binary tree. We install cameras on the tree nodes where each camera at a node can monitor its parent, itself, and its immediate children. Return _the minimum number of cameras needed to monitor all nodes of the tree_. **Example 1:** **Input:** root = \[0,0,null,0,0\] **Output:** 1 **Exp...
null
Array,Math,Divide and Conquer
Medium
null
752
hey what's up guys look white here Tekken goading stuff on twitch in YouTube I don't even say that's what I do anymore I just say things just look at the description and you'll see my patreon where I have premium problems I'm sorry I do well I'm doing like at least 5 problems a day and I'm kind of getting sick of it ev...
Open the Lock
ip-to-cidr
You have a lock in front of you with 4 circular wheels. Each wheel has 10 slots: `'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'`. The wheels can rotate freely and wrap around: for example we can turn `'9'` to be `'0'`, or `'0'` to be `'9'`. Each move consists of turning one wheel one slot. The lock initially starts...
Convert the ip addresses to and from (long) integers. You want to know what is the most addresses you can put in this block starting from the "start" ip, up to n. It is the smallest between the lowest bit of start and the highest bit of n. Then, repeat this process with a new start and n.
String,Bit Manipulation
Medium
93,468
1,624
okay so hello so today we'll be solving lead Cod equation 1624 that is largest substring between two equally character and in this we are given a strength s and we have to return the length of the longest substring between two equal characters excluding that two characters and if there is no such substring we have to r...
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
315
count off smaller number after cell right click in this question we have a array and we need to print what is the count of smaller number after particular after every element of it every right what I mean to say is c41 there is no number present at the right side or I should say one is the large number so we will write...
Count of Smaller Numbers After Self
count-of-smaller-numbers-after-self
Given an integer array `nums`, return _an integer array_ `counts` _where_ `counts[i]` _is the number of smaller elements to the right of_ `nums[i]`. **Example 1:** **Input:** nums = \[5,2,6,1\] **Output:** \[2,1,1,0\] **Explanation:** To the right of 5 there are **2** smaller elements (2 and 1). To the right of 2 the...
null
Array,Binary Search,Divide and Conquer,Binary Indexed Tree,Segment Tree,Merge Sort,Ordered Set
Hard
327,406,493,1482,2280
1,267
to be very honest these kind of problem statements seem very tricky in the beginning you are given some kind of a grid and it has some components now you have to determine a component X is connected to some other component y through some of the other means right now this connection can be in any form in this particular...
Count Servers that Communicate
remove-zero-sum-consecutive-nodes-from-linked-list
You are given a map of a server center, represented as a `m * n` integer matrix `grid`, where 1 means that on that cell there is a server and 0 means that it is no server. Two servers are said to communicate if they are on the same row or on the same column. Return the number of servers that communicate with any o...
Convert the linked list into an array. While you can find a non-empty subarray with sum = 0, erase it. Convert the array into a linked list.
Hash Table,Linked List
Medium
1618
454
Hua Tha Everyone Welcome To My Channel It's All The Problem Of And Shampoo Forgiven For Less Computer Share And Subscribe Problem 250 22225 Video Subscribe Result For Example Appointed Like Comment Subscribe 602 From All The Possible Temples And See How Many People Sir Hai Vinati subscribe and subscribe the Channel sub...
4Sum II
4sum-ii
Given four integer arrays `nums1`, `nums2`, `nums3`, and `nums4` all of length `n`, return the number of tuples `(i, j, k, l)` such that: * `0 <= i, j, k, l < n` * `nums1[i] + nums2[j] + nums3[k] + nums4[l] == 0` **Example 1:** **Input:** nums1 = \[1,2\], nums2 = \[-2,-1\], nums3 = \[-1,2\], nums4 = \[0,2\] **Ou...
null
Array,Hash Table
Medium
18
505
hey welcome back and let's continue our journey to bfs so we have three problems in our sequence and let's go ahead and read the second problem the maze number two and there's a ball in the maze with the empty spaces and the walls and the ball can go through the empty spaces by rolling up down left or right but it won'...
The Maze II
the-maze-ii
There is a ball in a `maze` with empty spaces (represented as `0`) and walls (represented as `1`). The ball can go through the empty spaces by rolling **up, down, left or right**, but it won't stop rolling until hitting a wall. When the ball stops, it could choose the next direction. Given the `m x n` `maze`, the ball...
null
Depth-First Search,Breadth-First Search,Graph,Heap (Priority Queue),Shortest Path
Medium
490,499
278
hello guys I hope you are all doing well in this video I'll show you how to solve the problem needs code first bad version so let's get started so the problem is that they give us a number n that represent the amount of version of the product and also we have a function that accepts a number and return whether it's a b...
First Bad Version
first-bad-version
You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the previous version, all the versions after a bad version are also bad. Suppose you have `n` versions `[1, 2, ..., n]` an...
null
Binary Search,Interactive
Easy
34,35,374
278
hey everyone welcome back and today we'll be doing another lead code 278 first bad version this is an easy one you are a product manager you are currently leading a team to develop a new product unfortunately the latest version of the product fails the quality checks since each version is developed based on the previou...
First Bad Version
first-bad-version
You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the previous version, all the versions after a bad version are also bad. Suppose you have `n` versions `[1, 2, ..., n]` an...
null
Binary Search,Interactive
Easy
34,35,374
189
welcome back to another video here in the unknown go to YouTube channel today we are doing the legal problem 189 rotate array as you can see this is another medium problem that is actually relatively simple once you figure out the actual pattern that we're going to talk about a little bit so this problem states that gi...
Rotate Array
rotate-array
Given an integer array `nums`, rotate the array to the right by `k` steps, where `k` is non-negative. **Example 1:** **Input:** nums = \[1,2,3,4,5,6,7\], k = 3 **Output:** \[5,6,7,1,2,3,4\] **Explanation:** rotate 1 steps to the right: \[7,1,2,3,4,5,6\] rotate 2 steps to the right: \[6,7,1,2,3,4,5\] rotate 3 steps to...
The easiest solution would use additional memory and that is perfectly fine. The actual trick comes when trying to solve this problem without using any additional memory. This means you need to use the original array somehow to move the elements around. Now, we can place each element in its original location and shift ...
Array,Math,Two Pointers
Medium
61,186
552
hey everybody this is Larry this is me doing an extra problem on November 8th of 2022 hit the like button hit the Subscribe button join me on Discord let me know what you think about this poem um so I think I forgot to advertising I want to talk about in The Daily prompt hopefully you find this video if not that's okay...
Student Attendance Record II
student-attendance-record-ii
An attendance record for a student can be represented as a string where each character signifies whether the student was absent, late, or present on that day. The record only contains the following three characters: * `'A'`: Absent. * `'L'`: Late. * `'P'`: Present. Any student is eligible for an attendance awar...
null
Dynamic Programming
Hard
551
692
hello everyone so let's talk about the top k frequency words so you're given a real string and an integer k so you have to return the k frequency word so uh you want to return the array when the array is already sorted and also it has to be elastic graphical order so what does this mean like for example for i like this...
Top K Frequent Words
top-k-frequent-words
Given an array of strings `words` and an integer `k`, return _the_ `k` _most frequent strings_. Return the answer **sorted** by **the frequency** from highest to lowest. Sort the words with the same frequency by their **lexicographical order**. **Example 1:** **Input:** words = \[ "i ", "love ", "leetcode ", "i ", "...
null
Hash Table,String,Trie,Sorting,Heap (Priority Queue),Bucket Sort,Counting
Medium
347,1014,1919
53
in this video we'll go over lead code question number 53 maximum subarray given an integer array nums we need to find the subarray with the largest sum and return that sum for example let's say this is the given array the answer would then be six since we could take this subarray and the sum is 5 - 2 + 3 this subarray ...
Maximum Subarray
maximum-subarray
Given an integer array `nums`, find the subarray with the largest sum, and return _its sum_. **Example 1:** **Input:** nums = \[-2,1,-3,4,-1,2,1,-5,4\] **Output:** 6 **Explanation:** The subarray \[4,-1,2,1\] has the largest sum 6. **Example 2:** **Input:** nums = \[1\] **Output:** 1 **Explanation:** The subarray \...
null
Array,Divide and Conquer,Dynamic Programming
Easy
121,152,697,1020,1849,1893
1,046
all right let's talk about the last stone weights so you are given array of integer stones where stone eyes the weight of the ice stone so basically you have to compare the two heaviest stone and then if they are equal then you both of them will destroy if they are not equal you have to generate a new number based on t...
Last Stone Weight
max-consecutive-ones-iii
You are given an array of integers `stones` where `stones[i]` is the weight of the `ith` stone. We are playing a game with the stones. On each turn, we choose the **heaviest two stones** and smash them together. Suppose the heaviest two stones have weights `x` and `y` with `x <= y`. The result of this smash is: * I...
One thing's for sure, we will only flip a zero if it extends an existing window of 1s. Otherwise, there's no point in doing it, right? Think Sliding Window! Since we know this problem can be solved using the sliding window construct, we might as well focus in that direction for hints. Basically, in a given window, we c...
Array,Binary Search,Sliding Window,Prefix Sum
Medium
340,424,485,487,2134
1,299
The Dream II bike has a family. I know I 'm in this row. I'll wear it and solve a 'm in this row. I'll wear it and solve a 'm in this row. I'll wear it and solve a math problem. For more detailed information, please go to the list of available dislikes. I'll put it on both sides to understand. okay how we work this num...
Replace Elements with Greatest Element on Right Side
k-concatenation-maximum-sum
Given an array `arr`, replace every element in that array with the greatest element among the elements to its right, and replace the last element with `-1`. After doing so, return the array. **Example 1:** **Input:** arr = \[17,18,5,4,6,1\] **Output:** \[18,6,6,6,1,-1\] **Explanation:** - index 0 --> the greatest e...
How to solve the problem for k=1 ? Use Kadane's algorithm for k=1. What are the possible cases for the answer ? The answer is the maximum between, the answer for k=1, the sum of the whole array multiplied by k, or the maximum suffix sum plus the maximum prefix sum plus (k-2) multiplied by the whole array sum for k > 1.
Array,Dynamic Programming
Medium
null
64
Hey how's it going guys in this video we'll discuss about this problem minimum part sum so given an M cross and rate filled with non-negative numbers find a filled with non-negative numbers find a filled with non-negative numbers find a path from top left to bottom right which mean you might as sum of all the numbers a...
Minimum Path Sum
minimum-path-sum
Given a `m x n` `grid` filled with non-negative numbers, find a path from top left to bottom right, which minimizes the sum of all numbers along its path. **Note:** You can only move either down or right at any point in time. **Example 1:** **Input:** grid = \[\[1,3,1\],\[1,5,1\],\[4,2,1\]\] **Output:** 7 **Explanat...
null
Array,Dynamic Programming,Matrix
Medium
62,174,741,2067,2192
1,870
hey everyone today we are going to solve the little question minimum speed to arrive on time so you are given floating Point number hour representing the amount of time you have to reach the office to commute the office you must take and train in the sequential order and you are also given integer array test of links a...
Minimum Speed to Arrive on Time
minimum-speed-to-arrive-on-time
You are given a floating-point number `hour`, representing the amount of time you have to reach the office. To commute to the office, you must take `n` trains in sequential order. You are also given an integer array `dist` of length `n`, where `dist[i]` describes the distance (in kilometers) of the `ith` train ride. E...
null
null
Medium
null
11
hi folks let's solve the equality level so it's a very typical um two-pointed so it's a very typical um two-pointed so it's a very typical um two-pointed problem let's take a look at what this problem is so um problem is um we're given integer which represents a line and we need to choose any of the two lines to make a...
Container With Most Water
container-with-most-water
You are given an integer array `height` of length `n`. There are `n` vertical lines drawn such that the two endpoints of the `ith` line are `(i, 0)` and `(i, height[i])`. Find two lines that together with the x-axis form a container, such that the container contains the most water. Return _the maximum amount of water...
The aim is to maximize the area formed between the vertical lines. The area of any container is calculated using the shorter line as length and the distance between the lines as the width of the rectangle. Area = length of shorter vertical line * distance between lines We can definitely get the maximum width ...
Array,Two Pointers,Greedy
Medium
42
1,491
hey everybody this is Larry this is when I wanted to prompt I sell for the PI weekly contest 29 I'm gonna put the explanation in the beginning and then I'm gonna do the live coding of it afterwards let me know what you think about this format I'm still playing with it and here we yeah q1 ouch sorry excluding the minimu...
Average Salary Excluding the Minimum and Maximum Salary
number-of-times-binary-string-is-prefix-aligned
You are given an array of **unique** integers `salary` where `salary[i]` is the salary of the `ith` employee. Return _the average salary of employees excluding the minimum and maximum salary_. Answers within `10-5` of the actual answer will be accepted. **Example 1:** **Input:** salary = \[4000,3000,1000,2000\] **Ou...
If in the step x all bulb shines then bulbs 1,2,3,..,x should shines too.
Array
Medium
319,672
1,605
hey guys today we're going to solve lethal number 1605 find valid matrix given row and column sums so yeah that's basically the whole problem so we're given the row sums and the column sums of a certain matrix and we need to return any matrix that satisfies those conditions and keep in mind we can only use non-negative...
Find Valid Matrix Given Row and Column Sums
minimum-number-of-days-to-make-m-bouquets
You are given two arrays `rowSum` and `colSum` of non-negative integers where `rowSum[i]` is the sum of the elements in the `ith` row and `colSum[j]` is the sum of the elements of the `jth` column of a 2D matrix. In other words, you do not know the elements of the matrix, but you do know the sums of each row and column...
If we can make m or more bouquets at day x, then we can still make m or more bouquets at any day y > x. We can check easily if we can make enough bouquets at day x if we can get group adjacent flowers at day x.
Array,Binary Search
Medium
2134,2257
1,531
hey everyone welcome back and let's write some more neat code today so today let's solve the problem string compression 2 I'm not going to lie this is definitely a really hard problem easily the hardest of the month so don't feel bad if you are not able to solve it the premise of the problem is that we can compress str...
String Compression II
number-of-ways-to-wear-different-hats-to-each-other
[Run-length encoding](http://en.wikipedia.org/wiki/Run-length_encoding) is a string compression method that works by replacing consecutive identical characters (repeated 2 or more times) with the concatenation of the character and the number marking the count of the characters (length of the run). For example, to compr...
Dynamic programming + bitmask. dp(peopleMask, idHat) number of ways to wear different hats given a bitmask (people visited) and used hats from 1 to idHat-1.
Array,Dynamic Programming,Bit Manipulation,Bitmask
Hard
2105
74
hi guys welcome to channel this is vaga we are going to do another literal question and the question in question is such a 2d matrix number 74. you're given a matrix where the numbers are increasing in every row and the first number of each row is greater than the number of the row after it right so for example we have...
Search a 2D Matrix
search-a-2d-matrix
You are given an `m x n` integer matrix `matrix` with the following two properties: * Each row is sorted in non-decreasing order. * The first integer of each row is greater than the last integer of the previous row. Given an integer `target`, return `true` _if_ `target` _is in_ `matrix` _or_ `false` _otherwise_. ...
null
Array,Binary Search,Matrix
Medium
240
1,679
um hello so today we are going to do this problem uh called max number of case and pairs it's part of late code um may challenge so the problem says we get a number array and we get an integer k and what we want is to pick two numbers that have a sum equal to k and remove them from the array and we want to try to do th...
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,822
hey so welcome back in this another daily kill problem so today it was called um let's see here sign of the product of an array and I just did this one a minute ago so it's an easy level problem and we're going to solve this in O of n time and of one space complexity so basically you just want to implement this functio...
Sign of the Product of an Array
longest-palindromic-subsequence-ii
There is a function `signFunc(x)` that returns: * `1` if `x` is positive. * `-1` if `x` is negative. * `0` if `x` is equal to `0`. You are given an integer array `nums`. Let `product` be the product of all values in the array `nums`. Return `signFunc(product)`. **Example 1:** **Input:** nums = \[-1,-2,-3,-4,...
As with any good dp problem that uses palindromes, try building the palindrome from the edges The prime point is to check that no two adjacent characters are equal, so save the past character while building the palindrome.
String,Dynamic Programming
Medium
516
621
Hello Everyone Welcome to my Channel Today's Date Month and Problems Transit Will Also Give the Character Repairing - Chinese to Also Give the Character Repairing - Chinese to Also Give the Character Repairing - Chinese to 1 Hour Differences subscribe The Channel and subscribe the Channel And subscribe The Amazing Peri...
Task Scheduler
task-scheduler
Given a characters array `tasks`, representing the tasks a CPU needs to do, where each letter represents a different task. Tasks could be done in any order. Each task is done in one unit of time. For each unit of time, the CPU could complete either one task or just be idle. However, there is a non-negative integer `n`...
null
Array,Hash Table,Greedy,Sorting,Heap (Priority Queue),Counting
Medium
358,778,2084
482
alright guys this is another problem last time we did a hard problem and dynamics programming it's about a 30 minute explanation go check that out if you're interested they're gonna be long if they're hard and dynamic programming problems though this one's a lot easier it's just easy it's license key formatting you wer...
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
228
Hello Controversial rotation is going to be done Liquid's problem but 220 is a prominent name Summary Rangers The problem is that we have an egg white, this egg is that we have to write the numbers which are continuous in a range and which are not salt and decays. They have us space science today in this easy way like ...
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
143
hello everyone uh in today's video we will try to solve this reorder list problem from the liquid okay so it is a medium level Croatia okay so let's just try to understand the question first so in this uh problem it is told us to so okay in this problem they have given us a link list over here right and what we have to...
Reorder List
reorder-list
You are given the head of a singly linked-list. The list can be represented as: L0 -> L1 -> ... -> Ln - 1 -> Ln _Reorder the list to be on the following form:_ L0 -> Ln -> L1 -> Ln - 1 -> L2 -> Ln - 2 -> ... You may not modify the values in the list's nodes. Only nodes themselves may be changed. **Example 1:** **...
null
Linked List,Two Pointers,Stack,Recursion
Medium
2216
523
this is a middle type problem and you will understand how you can solve this problem easily we'll understand it from the core before moving on if you haven't subscribed to this channel make sure to subscribe to learn workflow for regularly good videos like this the question says we are given an integer array nums and t...
Continuous Subarray Sum
continuous-subarray-sum
Given an integer array nums and an integer k, return `true` _if_ `nums` _has a **good subarray** or_ `false` _otherwise_. A **good subarray** is a subarray where: * its length is **at least two**, and * the sum of the elements of the subarray is a multiple of `k`. **Note** that: * A **subarray** is a contiguo...
null
Array,Hash Table,Math,Prefix Sum
Medium
560,2119,2240
876
Hello guys welcome back to my channel to TV in the discussion on the problem Hindi language problem is middle of the will be very simple problem right any to find the middle no feeling for this will be discussing to make them both are optimal right you Can use any method in Europe for individual life Twenty-20 so takes...
Middle of the Linked List
hand-of-straights
Given the `head` of a singly linked list, return _the middle node of the linked list_. If there are two middle nodes, return **the second middle** node. **Example 1:** **Input:** head = \[1,2,3,4,5\] **Output:** \[3,4,5\] **Explanation:** The middle node of the list is node 3. **Example 2:** **Input:** head = \[1,...
null
Array,Hash Table,Greedy,Sorting
Medium
null
1,019
hey welcome guys so let's summon this negative next great element know the ending list so this problem can be solved by using a very strange technique called moral timestamp which is a very strange okay so the idea is that the given thing list and you need to return the next greater element which is a straight to the d...
Next Greater Node In Linked List
squares-of-a-sorted-array
You are given the `head` of a linked list with `n` nodes. For each node in the list, find the value of the **next greater node**. That is, for each node, find the value of the first node that is next to it and has a **strictly larger** value than it. Return an integer array `answer` where `answer[i]` is the value of ...
null
Array,Two Pointers,Sorting
Easy
88,360
832
in this problem we have to flip a binary image so this is a binary image it is composed of 0 and 1. so this white denotes 1 and this dark region denotes 0. so we have to convert this to this but first we have to iterate through all the rows and reverse them that is flip horizontally so if we have let's say 1 0 then thi...
Flipping an Image
binary-tree-pruning
Given an `n x n` binary matrix `image`, flip the image **horizontally**, then invert it, and return _the resulting image_. To flip an image horizontally means that each row of the image is reversed. * For example, flipping `[1,1,0]` horizontally results in `[0,1,1]`. To invert an image means that each `0` is repla...
null
Tree,Depth-First Search,Binary Tree
Medium
null
133
read code problem number 133 clone graph so this problem gives us a reference to a node in a connected undirected graph so our job is to return a deep copy clone of the graph so here it gives us the information about the note so inside you have the value itself and a list of its name inverse okay and then here it gives...
Clone Graph
clone-graph
Given a reference of a node in a **[connected](https://en.wikipedia.org/wiki/Connectivity_(graph_theory)#Connected_graph)** undirected graph. Return a [**deep copy**](https://en.wikipedia.org/wiki/Object_copying#Deep_copy) (clone) of the graph. Each node in the graph contains a value (`int`) and a list (`List[Node]`)...
null
Hash Table,Depth-First Search,Breadth-First Search,Graph
Medium
138,1624,1634
1,390
220 Implement Random Function Time Using Random Functions 700 This function is included in it, RS 600, it can do this work for us, if it can generate this number randomly from 123 456, then any one of these seven numbers can be used in the random generator. The problem of subscribing all the numbers is to create a rand...
Four Divisors
average-selling-price
Given an integer array `nums`, return _the sum of divisors of the integers in that array that have exactly four divisors_. If there is no such integer in the array, return `0`. **Example 1:** **Input:** nums = \[21,4,7\] **Output:** 32 **Explanation:** 21 has 4 divisors: 1, 3, 7, 21 4 has 3 divisors: 1, 2, 4 7 has 2...
null
Database
Easy
null
743
Hello Friends Today In Dishas Robbers This Network Day Time Tak Problems Tally Give A Network Of Annual Awards Level For Want And Avoid Time TV Advertisements A Driver From YouTube Chief Okay New Year David Subscribe Note's Duty For All The Individual Width Maximum For The Post Of The Most Difficult To Minus One Is So ...
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
1,043
hey guys so today we will be solving rate code problem one zero four three partition array for maximum sum so in the given in problem statement we have an integer array arr and we need to partition the array into contiguous sub arrays of length at most k after partitioning each sub array has a value changed to become t...
Partition Array for Maximum Sum
grid-illumination
Given an integer array `arr`, partition the array into (contiguous) subarrays of length **at most** `k`. After partitioning, each subarray has their values changed to become the maximum value of that subarray. Return _the largest sum of the given array after partitioning. Test cases are generated so that the answer fi...
null
Array,Hash Table
Hard
51
917
hey everybody this is larry this is day 14 of the september league daily challenge hit the like button hit the subscribe button join me on discord you can see that i have a different background i'm in lisbon right now with this guy i don't know uh he's also wait should i tell people that you're lead coding whatever any...
Reverse Only Letters
boats-to-save-people
Given a string `s`, reverse the string according to the following rules: * All the characters that are not English letters remain in the same position. * All the English letters (lowercase or uppercase) should be reversed. Return `s` _after reversing it_. **Example 1:** **Input:** s = "ab-cd" **Output:** "dc-ba...
null
Array,Two Pointers,Greedy,Sorting
Medium
null
732
hello guys today I will solve the question my calendar 3. and I can understand that the question is little bit confusing the question the statement is already very confusing so it is saying booking happens when K events have some non-empty intersection that is there is non-empty intersection that is there is non-empty ...
My Calendar III
my-calendar-iii
A `k`\-booking happens when `k` events have some non-empty intersection (i.e., there is some time that is common to all `k` events.) You are given some events `[startTime, endTime)`, after each given event, return an integer `k` representing the maximum `k`\-booking between all the previous events. Implement the `MyC...
Treat each interval [start, end) as two events "start" and "end", and process them in sorted order.
Design,Segment Tree,Ordered Set
Hard
729,731
252
hi friends as in the previous video i've already explained the logic and how to solve this problem let's uh go ahead and write the code for this so i'll be writing in c plus so again it's an easy level problem and if you've not watched my previous video how to solve this problem or how to come up with the solution for ...
Meeting Rooms
meeting-rooms
Given an array of meeting time `intervals` where `intervals[i] = [starti, endi]`, determine if a person could attend all meetings. **Example 1:** **Input:** intervals = \[\[0,30\],\[5,10\],\[15,20\]\] **Output:** false **Example 2:** **Input:** intervals = \[\[7,10\],\[2,4\]\] **Output:** true **Constraints:** * ...
null
Array,Sorting
Easy
56,253
232
hello everyone in the previous video we have implemented stack using queues and in this video we are doing exact opposite we are implementing the Q using stack so the functions we need to implement are push off peak and empty so for this uh problem what we can do is we will just declare two stacks stack integer so let'...
Implement Queue using Stacks
implement-queue-using-stacks
Implement a first in first out (FIFO) queue using only two stacks. The implemented queue should support all the functions of a normal queue (`push`, `peek`, `pop`, and `empty`). Implement the `MyQueue` class: * `void push(int x)` Pushes element x to the back of the queue. * `int pop()` Removes the element from th...
null
Stack,Design,Queue
Easy
225
1,579
guys good morning welcome back to the next lecture uh in this we're gonna see remove max number of edges to keep the graph fully trans traversal uh firstly if you have watched the last video yesterday's videos I highly recommend even code this easily if in worst case you have not got the logic I still recommend if even...
Remove Max Number of Edges to Keep Graph Fully Traversable
active-users
Alice and Bob have an undirected graph of `n` nodes and three types of edges: * Type 1: Can be traversed by Alice only. * Type 2: Can be traversed by Bob only. * Type 3: Can be traversed by both Alice and Bob. Given an array `edges` where `edges[i] = [typei, ui, vi]` represents a bidirectional edge of type `typ...
null
Database
Medium
null
216
everyone welcome to my channel so in this video i'm going to explain how we are going to solve this problem called combination sum three so let's first read through this problem so find all the valid combinations of k numbers that sum up to n such that the following conditions are true so only numbers from 1 through 9 ...
Combination Sum III
combination-sum-iii
Find all valid combinations of `k` numbers that sum up to `n` such that the following conditions are true: * Only numbers `1` through `9` are used. * Each number is used **at most once**. Return _a list of all possible valid combinations_. The list must not contain the same combination twice, and the combinations...
null
Array,Backtracking
Medium
39
240
hello friends analysis of the search a 2d mattress - problem as the a statement 2d mattress - problem as the a statement 2d mattress - problem as the a statement write an efficient algorithms a search is for valuing and M times and matrix these metrics have the following properties integers in each row has sorted are s...
Search a 2D Matrix II
search-a-2d-matrix-ii
Write an efficient algorithm that searches for a value `target` in an `m x n` integer matrix `matrix`. This matrix has the following properties: * Integers in each row are sorted in ascending from left to right. * Integers in each column are sorted in ascending from top to bottom. **Example 1:** **Input:** matri...
null
Array,Binary Search,Divide and Conquer,Matrix
Medium
74
395
our advanced problem for january the 28th for this problem we have long sub string with at least k repeating characters so what does this problem entail given a string as an integer k return the length of the longest substring of s such that the frequency of each character in the substring is greater than or equal to k...
Longest Substring with At Least K Repeating Characters
longest-substring-with-at-least-k-repeating-characters
Given a string `s` and an integer `k`, return _the length of the longest substring of_ `s` _such that the frequency of each character in this substring is greater than or equal to_ `k`. **Example 1:** **Input:** s = "aaabb ", k = 3 **Output:** 3 **Explanation:** The longest substring is "aaa ", as 'a' is repeated 3...
null
Hash Table,String,Divide and Conquer,Sliding Window
Medium
2140,2209
92
hey guys how's everything going I hope you are doing well today let's take a look at number in ninety-two reverse look at number in ninety-two reverse look at number in ninety-two reverse linked lists - mm-hmm linked lists - mm-hmm linked lists - mm-hmm I think I'm not sure where there we've done the easy one we're bur...
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
32
hello and welcome back to the cracking fang youtube channel today we're going to be solving lead code problem number 32 longest valid parenthesis before we get into the problem i would just like to kindly ask you to subscribe to my channel i have the goal of reaching a thousand subscribers by the end of may and i need ...
Longest Valid Parentheses
longest-valid-parentheses
Given a string containing just the characters `'('` and `')'`, return _the length of the longest valid (well-formed) parentheses_ _substring_. **Example 1:** **Input:** s = "(() " **Output:** 2 **Explanation:** The longest valid parentheses substring is "() ". **Example 2:** **Input:** s = ")()()) " **Output:** ...
null
String,Dynamic Programming,Stack
Hard
20
931
hello everyone so in this video let us talk about the problem from lead code it's a medium problem the problem name is minimum falling paths up so i had already made a video on minimum falling path sum two this is the first video actually so let's go with the problem statement goes like this that you're given an n cros...
Minimum Falling Path Sum
maximum-frequency-stack
Given an `n x n` array of integers `matrix`, return _the **minimum sum** of any **falling path** through_ `matrix`. A **falling path** starts at any element in the first row and chooses the element in the next row that is either directly below or diagonally left/right. Specifically, the next element from position `(ro...
null
Hash Table,Stack,Design,Ordered Set
Hard
null
1,320
Welcome back and I am going to do the question 1320 minimum distance you type a word ok this question is very difficult for me if you have done this question this is considered a hard problem in lead trust me this is not really hard problem if you Have Dan Preet Much Number of Like Recursive Questions Okay, so let me t...
Minimum Distance to Type a Word Using Two Fingers
remove-all-adjacent-duplicates-in-string-ii
You have a keyboard layout as shown above in the **X-Y** plane, where each English uppercase letter is located at some coordinate. * For example, the letter `'A'` is located at coordinate `(0, 0)`, the letter `'B'` is located at coordinate `(0, 1)`, the letter `'P'` is located at coordinate `(2, 3)` and the letter `...
Use a stack to store the characters, when there are k same characters, delete them. To make it more efficient, use a pair to store the value and the count of each character.
String,Stack
Medium
1128,2307
1,047
hey guys I hope you're doing well let's continue our journey to meet code this is 104 7 remove all adjacent duplicates in string we're given a string of letters duplicate removal consists of choosing two adjacent and equal nether and removing them for example we made a BBC a we met two a Jason and I Jason and duplicate...
Remove All Adjacent Duplicates In String
maximize-sum-of-array-after-k-negations
You are given a string `s` consisting of lowercase English letters. A **duplicate removal** consists of choosing two **adjacent** and **equal** letters and removing them. We repeatedly make **duplicate removals** on `s` until we no longer can. Return _the final string after all such duplicate removals have been made_...
null
Array,Greedy,Sorting
Easy
2204
1,716
hello everyone let's look at lead codee question 1760 calculate money in lead code bank at time of recording this question has 1.4 th000 up votes and 48 question has 1.4 th000 up votes and 48 question has 1.4 th000 up votes and 48 down votes the question is as follows hery wants to save money for his first car he puts ...
Calculate Money in Leetcode Bank
maximum-non-negative-product-in-a-matrix
Hercy wants to save money for his first car. He puts money in the Leetcode bank **every day**. He starts by putting in `$1` on Monday, the first day. Every day from Tuesday to Sunday, he will put in `$1` more than the day before. On every subsequent Monday, he will put in `$1` more than the **previous Monday**. Given...
Use Dynamic programming. Keep the highest value and lowest value you can achieve up to a point.
Array,Dynamic Programming,Matrix
Medium
null
784
today we are looking at lead code 784 it's a question called letter case permutation and so here we have a string s and we want to transform every letter individually to be lowercase or uppercase to create another string we're going to return a list of all possible strings that we can create we can return the output in...
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
541
yo what is up youtube i'm xavier elon today i'm going to be going over reverse string 2. it's an easy problem on leak code check out my channel and subscribe if you haven't already and if you guys have any questions feel free to leave them in the comments below and i'll see you guys in the video okay so this problem ac...
Reverse String II
reverse-string-ii
Given a string `s` and an integer `k`, reverse the first `k` characters for every `2k` characters counting from the start of the string. If there are fewer than `k` characters left, reverse all of them. If there are less than `2k` but greater than or equal to `k` characters, then reverse the first `k` characters and l...
null
Two Pointers,String
Easy
344,557
299
welcome to my channel so in this video there are two goals uh the first goal is to see how to solve this problem so you're going to do some problem solving work and do some coding work after that the second goal is to see how we should be having a real interview so let's get started so remember in a real interview the ...
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
47
Alarm Ko Tidda I Nivedita and this video were going to solve on Motion 200. In this problem we are going to talk about major station to dominant. What we have to do here is that we have to line up all the possible unique major tensions. Here you have to Given the patience of an in-fit input tailor, you have to Given th...
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
1,461
hey everybody this is larry it's march 12th uh hit the like button hit the subscribe button join me on discord let me know what you think about today's forum uh what was it my arch check if a string contains more binary codes of length chaos ice k uh okay cool um so i do this live so if it's a little bit slow just fast...
Check If a String Contains All Binary Codes of Size K
count-all-valid-pickup-and-delivery-options
Given a binary string `s` and an integer `k`, return `true` _if every binary code of length_ `k` _is a substring of_ `s`. Otherwise, return `false`. **Example 1:** **Input:** s = "00110110 ", k = 2 **Output:** true **Explanation:** The binary codes of length 2 are "00 ", "01 ", "10 " and "11 ". They can be all f...
Use the permutation and combination theory to add one (P, D) pair each time until n pairs.
Math,Dynamic Programming,Combinatorics
Hard
null
2
foreign this is the second one and their platform it's called add two numbers it's a medium let's get into it you are given two non-empty linked lists given two non-empty linked lists given two non-empty linked lists representing two non-negative integers representing two non-negative integers representing two non-nega...
Add Two Numbers
add-two-numbers
You are given two **non-empty** linked lists representing two non-negative integers. The digits are stored in **reverse order**, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list. You may assume the two numbers do not contain any leading zero, except the number 0 ...
null
Linked List,Math,Recursion
Medium
43,67,371,415,445,1031,1774
313
hello everyone hope you all are doing well so in this video we'll discuss the last problem of Lead Core weekly contest 313 it's a hard level problem uh I was not able to make a video for this uh question because uh just after the solution I was not able to fetch my latest code because of LC server being down so yeah it...
Super Ugly Number
super-ugly-number
A **super ugly number** is a positive integer whose prime factors are in the array `primes`. Given an integer `n` and an array of integers `primes`, return _the_ `nth` _**super ugly number**_. The `nth` **super ugly number** is **guaranteed** to fit in a **32-bit** signed integer. **Example 1:** **Input:** n = 12, ...
null
Array,Hash Table,Math,Dynamic Programming,Heap (Priority Queue)
Medium
264
966
hey guys has been going this is jay so in this video let's solve 966 vowel spell checker from lead code given a word list we want to implement a spell checker that converts a query word into a correct word forgive a given query word the spell checker handles two categories of spelling mistakes capitalization if query m...
Vowel Spellchecker
binary-subarrays-with-sum
Given a `wordlist`, we want to implement a spellchecker that converts a query word into a correct word. For a given `query` word, the spell checker handles two categories of spelling mistakes: * Capitalization: If the query matches a word in the wordlist (**case-insensitive**), then the query word is returned with ...
null
Array,Hash Table,Sliding Window,Prefix Sum
Medium
null
38
hello everyone let's try to be a cheat code ninja today this question is asked in today's daily challenge let's look at it given a number we have to find its count and a sequence and the count and a sequence is defined using a recursive formula where the base condition count and say of 1 is equal to 1 and in general th...
Count and Say
count-and-say
The **count-and-say** sequence is a sequence of digit strings defined by the recursive formula: * `countAndSay(1) = "1 "` * `countAndSay(n)` is the way you would "say " the digit string from `countAndSay(n-1)`, which is then converted into a different digit string. To determine how you "say " a digit string, spli...
The following are the terms from n=1 to n=10 of the count-and-say sequence: 1. 1 2. 11 3. 21 4. 1211 5. 111221 6. 312211 7. 13112221 8. 1113213211 9. 31131211131221 10. 13211311123113112211 To generate the nth term, just count and say the n-1th term.
String
Medium
271,443
979
Hello hello friends today in this video will discuss the problem list to problems deposited in the Indian soil which you are giving away every election 2014 like brand ambassadors and in this we just pluck a leaf can move what does not involve in 1231 likes Subscribe And Hai To Balak Such Scene Of Postal Order For Refo...
Distribute Coins in Binary Tree
di-string-match
You are given the `root` of a binary tree with `n` nodes where each `node` in the tree has `node.val` coins. There are `n` coins in total throughout the whole tree. In one move, we may choose two adjacent nodes and move one coin from one node to another. A move may be from parent to child, or from child to parent. Re...
null
Array,Math,Two Pointers,String,Greedy
Easy
null
1,725
lead code 1725 number of rectangles that can form the largest square this is one of the stuff that has this cheesy description somewhat but the idea is that we have an array of sides of a rectangle and we have to kind of cut a square out of them which basically means the biggest square that we can get from each rectang...
Number Of Rectangles That Can Form The Largest Square
number-of-sets-of-k-non-overlapping-line-segments
You are given an array `rectangles` where `rectangles[i] = [li, wi]` represents the `ith` rectangle of length `li` and width `wi`. You can cut the `ith` rectangle to form a square with a side length of `k` if both `k <= li` and `k <= wi`. For example, if you have a rectangle `[4,6]`, you can cut it to get a square wit...
Try to use dynamic programming where the current index and remaining number of line segments to form can describe any intermediate state. To make the computation of each state in constant time, we could add another flag to the state that indicates whether or not we are in the middle of placing a line (placed start poin...
Math,Dynamic Programming
Medium
null
785
Hello guys welcome to the video naseer volume lite co by tiger share gira resistance left over ground water conservation in this part is not so let's see what is the meaning of you are not able to give the The Week Is I Lash Add Member Half Minute Red Color Blue Problem 9999 That Emperor Leaders 1234 Five Snakes Someth...
Is Graph Bipartite?
basic-calculator-iii
There is an **undirected** graph with `n` nodes, where each node is numbered between `0` and `n - 1`. You are given a 2D array `graph`, where `graph[u]` is an array of nodes that node `u` is adjacent to. More formally, for each `v` in `graph[u]`, there is an undirected edge between node `u` and node `v`. The graph has ...
null
Math,String,Stack,Recursion
Hard
224,227,781,1736
708
in this video we're going to take a look at a legal problem called insert into a sorted circular linked list so given a node from a circular linked list which is sorted in a in sending a setting order so write a function to insert a value insert value into the list such that it remains a sorted circular linked list so ...
Insert into a Sorted Circular Linked List
insert-into-a-sorted-circular-linked-list
Given a Circular Linked List node, which is sorted in non-descending order, write a function to insert a value `insertVal` into the list such that it remains a sorted circular list. The given node can be a reference to any single node in the list and may not necessarily be the smallest value in the circular list. If t...
null
null
Medium
null
44
and the wild card matching there are two special characters in the pattern this is a question mark represent a single culture and the star match the sequence from a culture or empty and I found this method over again each ad if being a pattern they are is star and we can assuming in the stream also yeah programming als...
Wildcard Matching
wildcard-matching
Given an input string (`s`) and a pattern (`p`), implement wildcard pattern matching with support for `'?'` and `'*'` where: * `'?'` Matches any single character. * `'*'` Matches any sequence of characters (including the empty sequence). The matching should cover the **entire** input string (not partial). **Exam...
null
String,Dynamic Programming,Greedy,Recursion
Hard
10
987
okay so the lastly code practice question for today um so two goals the first one still is to find the solution and putting some solid code after that and the second one is to see how to solve this problem properly during interview so in the interview usually the first step is to um understand the question and qualify ...
Vertical Order Traversal of a Binary Tree
reveal-cards-in-increasing-order
Given the `root` of a binary tree, calculate the **vertical order traversal** of the binary tree. For each node at position `(row, col)`, its left and right children will be at positions `(row + 1, col - 1)` and `(row + 1, col + 1)` respectively. The root of the tree is at `(0, 0)`. The **vertical order traversal** o...
null
Array,Queue,Sorting,Simulation
Medium
null
126
Hey guys welcome to take good bye Nivedita and you are going to solve video switch problem. We will understand through the example what is given to us in the statement and what we have to fix. After that we will see our solution how to solve this problem. Okay, so look here, I have taken the first example, what all hav...
Word Ladder II
word-ladder-ii
A **transformation sequence** from word `beginWord` to word `endWord` using a dictionary `wordList` is a sequence of words `beginWord -> s1 -> s2 -> ... -> sk` such that: * Every adjacent pair of words differs by a single letter. * Every `si` for `1 <= i <= k` is in `wordList`. Note that `beginWord` does not need ...
null
Hash Table,String,Backtracking,Breadth-First Search
Hard
127,2276
1,302
hello friends so today in this video we're gonna discuss another problem from lead code problem name deepest leaf sum so as you can see it's a medium level problem it actually states that you are given a root of a binary tree in the problem statement and you have to return out the sum of the values at its deepest leave...
Deepest Leaves Sum
delete-characters-to-make-fancy-string
Given the `root` of a binary tree, return _the sum of values of its deepest leaves_. **Example 1:** **Input:** root = \[1,2,3,4,5,null,6,7,null,null,null,null,8\] **Output:** 15 **Example 2:** **Input:** root = \[6,7,8,2,7,1,3,9,null,1,4,null,null,null,5\] **Output:** 19 **Constraints:** * The number of nodes i...
What's the optimal way to delete characters if three or more consecutive characters are equal? If three or more consecutive characters are equal, keep two of them and delete the rest.
String
Easy
null
1,235
Hey everyone welcome to my channel, so today we will see question number five of our dynamic framing place and this is liquid number 1235 so it will seem sure, okay enough, we will solve it in the classical way, there is no need to be too smart, okay classic. This is not a question about DP's maximum profit in job. So ...
Maximum Profit in Job Scheduling
maximum-profit-in-job-scheduling
We have `n` jobs, where every job is scheduled to be done from `startTime[i]` to `endTime[i]`, obtaining a profit of `profit[i]`. You're given the `startTime`, `endTime` and `profit` arrays, return the maximum profit you can take such that there are no two jobs in the subset with overlapping time range. If you choose...
null
null
Hard
null
1,044
hey everybody this is Larry this is day 19 of the Li code every challenge we're here to solve the longest two pickets substring it'll like button hit the subscribe button join the discord and let me know what you think so yeah so usually I will jump into solving this problem and resolve alive and I'm still going to do ...
Longest Duplicate Substring
find-common-characters
Given a string `s`, consider all _duplicated substrings_: (contiguous) substrings of s that occur 2 or more times. The occurrences may overlap. Return **any** duplicated substring that has the longest possible length. If `s` does not have a duplicated substring, the answer is `" "`. **Example 1:** **Input:** s = "ba...
null
Array,Hash Table,String
Easy
350
1,025
Hey guys welcome back to the channel this is Manish Arit today we are going to do a simple question we have by doing division game and on lead code this is the problem number 1025 it is a simple question so once we see the problem first what is and Then we will move on to our solution, so what is the problem we have? H...
Divisor Game
minimum-cost-for-tickets
Alice and Bob take turns playing a game, with Alice starting first. Initially, there is a number `n` on the chalkboard. On each player's turn, that player makes a move consisting of: * Choosing any `x` with `0 < x < n` and `n % x == 0`. * Replacing the number `n` on the chalkboard with `n - x`. Also, if a player...
null
Array,Dynamic Programming
Medium
322
410
hello everyone i hope you are all doing well welcome back to algorithm simplified and today we're going over the binary search solution for number 410 split array largest sum it gives you an array of integers and also m indicating the number of sub-arrays it indicating the number of sub-arrays it indicating the number ...
Split Array Largest Sum
split-array-largest-sum
Given an integer array `nums` and an integer `k`, split `nums` into `k` non-empty subarrays such that the largest sum of any subarray is **minimized**. Return _the minimized largest sum of the split_. A **subarray** is a contiguous part of the array. **Example 1:** **Input:** nums = \[7,2,5,10,8\], k = 2 **Output:*...
null
Array,Binary Search,Dynamic Programming,Greedy
Hard
1056,1192,2242,2330
1,690
welcome to june's leeco challenge today's problem is stone game seven alice and bob take turns playing a game with alice starting first there are end stones arranged in a row on each player's turn they can remove either the leftmost stone or the rightmost stone from the row and receive points equal to the sum of the re...
Stone Game VII
maximum-length-of-subarray-with-positive-product
Alice and Bob take turns playing a game, with **Alice starting first**. There are `n` stones arranged in a row. On each player's turn, they can **remove** either the leftmost stone or the rightmost stone from the row and receive points equal to the **sum** of the remaining stones' values in the row. The winner is the ...
Split the whole array into subarrays by zeroes since a subarray with positive product cannot contain any zero. If the subarray has even number of negative numbers, the whole subarray has positive product. Otherwise, we have two choices, either - remove the prefix till the first negative element in this subarray, or rem...
Array,Dynamic Programming,Greedy
Medium
null
1,650
Hai gas welcome to today's video and today we are going to do let's code problem 1650 whose name is lowest common and sister of a binary tree so here we have to do the same, we have to find the LCM of our tree or both the odds but in this question special The thing is that every note has the reference of its parent, so...
Lowest Common Ancestor of a Binary Tree III
find-root-of-n-ary-tree
Given two nodes of a binary tree `p` and `q`, return _their lowest common ancestor (LCA)_. Each node will have a reference to its parent node. The definition for `Node` is below: class Node { public int val; public Node left; public Node right; public Node parent; } According to the **[definition of ...
Node with indegree 0 is the root
Hash Table,Bit Manipulation,Tree,Depth-First Search
Medium
1655
54
By the size of today we will paint the train equation of Hey Palace video number. The question given is medium. Liquid number is 15. Four questions have to be done in a spiral. Take it for a minute. Even the name is clear that you must have given a broken trick and you can friend it in spiral form. This is a very frequ...
Spiral Matrix
spiral-matrix
Given an `m x n` `matrix`, return _all elements of the_ `matrix` _in spiral order_. **Example 1:** **Input:** matrix = \[\[1,2,3\],\[4,5,6\],\[7,8,9\]\] **Output:** \[1,2,3,6,9,8,7,4,5\] **Example 2:** **Input:** matrix = \[\[1,2,3,4\],\[5,6,7,8\],\[9,10,11,12\]\] **Output:** \[1,2,3,4,8,12,11,10,9,5,6,7\] **Const...
Well for some problems, the best way really is to come up with some algorithms for simulation. Basically, you need to simulate what the problem asks us to do. We go boundary by boundary and move inwards. That is the essential operation. First row, last column, last row, first column and then we move inwards by 1 and th...
Array,Matrix,Simulation
Medium
59,921
150
Hello Hi Everyone Welcome to my channel it's all the very famous problem rebuffed is not in this problem in interviews and Gautam Jain Amit Jain Google Microsoft and this problem statement of expression in reverse plus minus and expression drawn in middle age always no problem Thi 90 Subscribe No Tension To Egg Jeevan ...
Evaluate Reverse Polish Notation
evaluate-reverse-polish-notation
You are given an array of strings `tokens` that represents an arithmetic expression in a [Reverse Polish Notation](http://en.wikipedia.org/wiki/Reverse_Polish_notation). Evaluate the expression. Return _an integer that represents the value of the expression_. **Note** that: * The valid operators are `'+'`, `'-'`, ...
null
Array,Math,Stack
Medium
224,282
724
how's it going guys so today we're going to solve the one of the coolest question which is find pivot index this question is literally good so what this question is saying if you look at over here they are saying we have given an array of individual numbers we have to calculate the pivot index okay the pivot index in t...
Find Pivot Index
find-pivot-index
Given an array of integers `nums`, calculate the **pivot index** of this array. The **pivot index** is the index where the sum of all the numbers **strictly** to the left of the index is equal to the sum of all the numbers **strictly** to the index's right. If the index is on the left edge of the array, then the left...
We can precompute prefix sums P[i] = nums[0] + nums[1] + ... + nums[i-1]. Then for each index, the left sum is P[i], and the right sum is P[P.length - 1] - P[i] - nums[i].
Array,Prefix Sum
Easy
560,2102,2369
714
hi guys hope you're being great uh today's question is best time to buy and sell stock with transaction fee so the patient says you given an array of integers prices for which the eyuth element is the price of a given stock one day I and a non-negative integer fee one day I and a non-negative integer fee one day I and ...
Best Time to Buy and Sell Stock with Transaction Fee
best-time-to-buy-and-sell-stock-with-transaction-fee
You are given an array `prices` where `prices[i]` is the price of a given stock on the `ith` day, and an integer `fee` representing a transaction fee. Find the maximum profit you can achieve. You may complete as many transactions as you like, but you need to pay the transaction fee for each transaction. **Note:** You...
Consider the first K stock prices. At the end, the only legal states are that you don't own a share of stock, or that you do. Calculate the most profit you could have under each of these two cases.
Array,Dynamic Programming,Greedy
Medium
122
124
so this is another problems on the binary so in this problem what you have to find out if you traversal this tree and what is the maximum sum you can find out from a given TV so let me explain through this example so suppose if you Traverse from this 9 to 10 and this to 20. so YouTube have actually nine you have to add...
Binary Tree Maximum Path Sum
binary-tree-maximum-path-sum
A **path** in a binary tree is a sequence of nodes where each pair of adjacent nodes in the sequence has an edge connecting them. A node can only appear in the sequence **at most once**. Note that the path does not need to pass through the root. The **path sum** of a path is the sum of the node's values in the path. ...
null
Dynamic Programming,Tree,Depth-First Search,Binary Tree
Hard
112,129,666,687,1492