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
1,877
Hello everyone, welcome to my channel here they solve problems Lead code today task number 1877 minimize the maximum sum of pairs in an array sum of pairs sum of pair A and b is respectively the sum of a n B so the maximum value of the sum of a pair is the maximum this is su among all pairs we are given an array us of ...
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
494
okay let's talk about target sum so you are given integer read nums and the integer target return a number of different expressions that you can build so in this example there are uh lists in the rate and a target three so you have five different ways so in this situation i mean in this question you can actually use re...
Target Sum
target-sum
You are given an integer array `nums` and an integer `target`. You want to build an **expression** out of nums by adding one of the symbols `'+'` and `'-'` before each integer in nums and then concatenate all the integers. * For example, if `nums = [2, 1]`, you can add a `'+'` before `2` and a `'-'` before `1` and ...
null
Array,Dynamic Programming,Backtracking
Medium
282
744
next problem is called find smallest letter greater than the target we are given an array of characters uh called letters that sorted in non-creasing letters that sorted in non-creasing letters that sorted in non-creasing orderorder and the character Target uh there are at least two different characters in the letters ...
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
1,791
hey what is going on it is thursday april 21st 2022 welcome to coding with chef and yeah uh i'm ready on this fine lovely thursday hitting up uh the close to the end of the week point um i'm ready today to do a graph problem and you know graph problems to me are fundamentals of computer science and they um i think they...
Find Center of Star Graph
richest-customer-wealth
There is an undirected **star** graph consisting of `n` nodes labeled from `1` to `n`. A star graph is a graph where there is one **center** node and **exactly** `n - 1` edges that connect the center node with every other node. You are given a 2D integer array `edges` where each `edges[i] = [ui, vi]` indicates that th...
Calculate the wealth of each customer Find the maximum element in array.
Array,Matrix
Easy
null
122
okay so hello guys let's try to solve question number one will do uh from lead code the best time for buying and selling the stock part two okay so about this question uh so they have given us a vector and we have to find the maximum profit that uh we can buy and buy buying then selling the uh stocks but the difference...
Best Time to Buy and Sell Stock II
best-time-to-buy-and-sell-stock-ii
You are given an integer array `prices` where `prices[i]` is the price of a given stock on the `ith` day. On each day, you may decide to buy and/or sell the stock. You can only hold **at most one** share of the stock at any time. However, you can buy it then immediately sell it on the **same day**. Find and return _t...
null
Array,Dynamic Programming,Greedy
Medium
121,123,188,309,714
1,631
hello and welcome to another video today we're going to be working on path with minimum effort so in this problem you're hiker preparing for a hike you're given an array of rows and columns and so the height of a particular square is just the row in the column and you want to get from the top left to the bottom right a...
Path With Minimum Effort
number-of-sub-arrays-with-odd-sum
You are a hiker preparing for an upcoming hike. You are given `heights`, a 2D array of size `rows x columns`, where `heights[row][col]` represents the height of cell `(row, col)`. You are situated in the top-left cell, `(0, 0)`, and you hope to travel to the bottom-right cell, `(rows-1, columns-1)` (i.e., **0-indexed**...
Can we use the accumulative sum to keep track of all the odd-sum sub-arrays ? if the current accu sum is odd, we care only about previous even accu sums and vice versa.
Array,Math,Dynamic Programming,Prefix Sum
Medium
2242
509
hello everyone welcome to another one of my lead code videos in this one I'm doing lead code 509 Fibonacci number and it's part of an effort that I want to make more dynamic programming videos so that any of you doing the lead code study plan on dynamic programming can benefit from these videos so let's get right into ...
Fibonacci Number
inorder-successor-in-bst-ii
The **Fibonacci numbers**, commonly denoted `F(n)` form a sequence, called the **Fibonacci sequence**, such that each number is the sum of the two preceding ones, starting from `0` and `1`. That is, F(0) = 0, F(1) = 1 F(n) = F(n - 1) + F(n - 2), for n > 1. Given `n`, calculate `F(n)`. **Example 1:** **Input:** n = ...
null
Tree,Binary Search Tree,Binary Tree
Medium
285
417
It was well mixed with your arrow, I wash you guys welcome back to my channel again suhag question a question number 417 the name of this is Pacific Atlantic Water Flop so let's make it clear we have our antique tone in a set a ok so this Till the announcement, we will understand it very well first and then solve it is...
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
1,888
Sandeep in a favorable month and not avoid discussing beat problem one interested in this problem basically which only acting spring usko se most profit hips operation in the spring to first operations that fictional character of birth and death and simply pink character liquid 1 0 robbers Options Interesting Gift Oper...
Minimum Number of Flips to Make the Binary String Alternating
find-nearest-point-that-has-the-same-x-or-y-coordinate
You are given a binary string `s`. You are allowed to perform two types of operations on the string in any sequence: * **Type-1: Remove** the character at the start of the string `s` and **append** it to the end of the string. * **Type-2: Pick** any character in `s` and **flip** its value, i.e., if its value is `'...
Iterate through each point, and keep track of the current point with the smallest Manhattan distance from your current location.
Array
Easy
1014
49
okay this is uh leak code 49 group anagrams they're asking to look through the string and then return an array of arrays that contain all the anagrams in separate arrays so how i approach this what you can do is you can create basically a little object map of this and while you're looping through the input array up her...
Group Anagrams
group-anagrams
Given an array of strings `strs`, group **the anagrams** together. You can return the answer in **any order**. An **Anagram** is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. **Example 1:** **Input:** strs = \["eat","tea","tan...
null
Hash Table,String,Sorting
Medium
242,249
233
hi it's Saturday June 20th 2020 my name is Noah Seeley and welcome to my channel today we're back with leak code I haven't really been spending too much time on lead code as I was before because I've been a lot more focused on the papers that we've been reviewing but I think a good way to start with it again is devotin...
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,694
welcome back friends today we are going to solve lead code problem 1694 reformat phone number uh so before we start looking the details of this problem uh i just want to mention that i often create lead code solution videos and if you are like someone who is preparing for a job or you are learning java or you are inter...
Reformat Phone Number
make-sum-divisible-by-p
You are given a phone number as a string `number`. `number` consists of digits, spaces `' '`, and/or dashes `'-'`. You would like to reformat the phone number in a certain manner. Firstly, **remove** all spaces and dashes. Then, **group** the digits from left to right into blocks of length 3 **until** there are 4 or f...
Use prefix sums to calculate the subarray sums. Suppose you know the remainder for the sum of the entire array. How does removing a subarray affect that remainder? What remainder does the subarray need to have in order to make the rest of the array sum up to be divisible by k? Use a map to keep track of the rightmost i...
Array,Hash Table,Prefix Sum
Medium
1016
79
Hello hello everyone welcome to my channel todays 121 any problems but such a very famous problem interview saudi duty world and avoid the world can be constructed from letters click subscribe button decimal should not be used for example for this is the giver problem and subscribe tomorrow morning To Search All The Ch...
Word Search
word-search
Given an `m x n` grid of characters `board` and a string `word`, return `true` _if_ `word` _exists in the grid_. The word can be constructed from letters of sequentially adjacent cells, where adjacent cells are horizontally or vertically neighboring. The same letter cell may not be used more than once. **Example 1:**...
null
Array,Backtracking,Matrix
Medium
212
1,773
hello everyone welcome to another video and in this video we are going to look at a very different question now this is important because we need to understand how to access uh um a value inside a 2d Vector okay now um let's jump straight into the explanation first okay uh so what is what we are given is um let me what...
Count Items Matching a Rule
percentage-of-users-attended-a-contest
You are given an array `items`, where each `items[i] = [typei, colori, namei]` describes the type, color, and name of the `ith` item. You are also given a rule represented by two strings, `ruleKey` and `ruleValue`. The `ith` item is said to match the rule if **one** of the following is true: * `ruleKey == "type "` ...
null
Database
Easy
1338
1,573
Hello hello everybody welcome to my channel it's all the record problem number of best to split string to give energy subscribe ltd Video then subscribe to the Channel Please subscribe number of characters of Islam in one to three servi please attend a lot and 251 087 total number If wave in this is 320 can only move o...
Number of Ways to Split a String
find-two-non-overlapping-sub-arrays-each-with-target-sum
Given a binary string `s`, you can split `s` into 3 **non-empty** strings `s1`, `s2`, and `s3` where `s1 + s2 + s3 = s`. Return the number of ways `s` can be split such that the number of ones is the same in `s1`, `s2`, and `s3`. Since the answer may be too large, return it **modulo** `109 + 7`. **Example 1:** **Inp...
Let's create two arrays prefix and suffix where prefix[i] is the minimum length of sub-array ends before i and has sum = k, suffix[i] is the minimum length of sub-array starting at or after i and has sum = k. The answer we are searching for is min(prefix[i] + suffix[i]) for all values of i from 0 to n-1 where n == arr....
Array,Hash Table,Binary Search,Dynamic Programming,Sliding Window
Medium
null
226
hey friends welcome back to another leetco tutorial if you are new here my name is anar and i'm a self-taught my name is anar and i'm a self-taught my name is anar and i'm a self-taught software developer that makes content to help you break into and grow in the tech industry today we will be solving lead code 226 inve...
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,773
hello guys my name is asala and welcome back to my channel and today we are going to solve a new lead code question that discount items matching a rule so we will be solving this question with the help of JavaScript the question says you are given an array item each where each items I is equal to type color name descri...
Count Items Matching a Rule
percentage-of-users-attended-a-contest
You are given an array `items`, where each `items[i] = [typei, colori, namei]` describes the type, color, and name of the `ith` item. You are also given a rule represented by two strings, `ruleKey` and `ruleValue`. The `ith` item is said to match the rule if **one** of the following is true: * `ruleKey == "type "` ...
null
Database
Easy
1338
1,877
Hello friends welcome to my channel here I solve L problems and prepare to the court interview today's problem number is 1877 minimize maximum PIR sum in Array the PIR sum of a pair and a and b is equal to a plus b the maximum pair sum is the largest pay sum in the list of payers given an nums of even length N Pay up t...
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
872
hey everybody this is Larry hit the like button hit the Subscribe button drop me on Discord let me know what you think about today's problem leave similar trees have I done this before no worries I haven't not recently so okay so today's prime is leave similar trees easy hit the like button and subscribe and join me on...
Leaf-Similar Trees
split-array-into-fibonacci-sequence
Consider all the leaves of a binary tree, from left to right order, the values of those leaves form a **leaf value sequence**_._ For example, in the given tree above, the leaf value sequence is `(6, 7, 4, 9, 8)`. Two binary trees are considered _leaf-similar_ if their leaf value sequence is the same. Return `true` i...
null
String,Backtracking
Medium
306,1013
1,300
Hello Everyone So Today Bill B Discussing Question No. 1300 Need Code Which Is Some Of Mutated Are Closest To De Target Playlist Part Of My Beneficial Series Started Earlier I Have Made Two Videos In Which I Have Discussed The Template Solution And Its Inscription. It has been kept in good detail and I am going to teac...
Sum of Mutated Array Closest to Target
critical-connections-in-a-network
Given an integer array `arr` and a target value `target`, return the integer `value` such that when we change all the integers larger than `value` in the given array to be equal to `value`, the sum of the array gets as close as possible (in absolute difference) to `target`. In case of a tie, return the minimum such in...
Use Tarjan's algorithm.
Depth-First Search,Graph,Biconnected Component
Hard
null
1,026
hey guys welcome back to Hustler's algorithm today we are gonna be solving this problem maximum difference between node and ancestor so you can go through this problem statement but it simply says that you have to find the absolute difference between two nodes such that the second node will be the ancestor of first nod...
Maximum Difference Between Node and Ancestor
string-without-aaa-or-bbb
Given the `root` of a binary tree, find the maximum value `v` for which there exist **different** nodes `a` and `b` where `v = |a.val - b.val|` and `a` is an ancestor of `b`. A node `a` is an ancestor of `b` if either: any child of `a` is equal to `b` or any child of `a` is an ancestor of `b`. **Example 1:** **Input...
null
String,Greedy
Medium
null
63
hey everyone welcome back and let's write some more neat code today so today let's solve the problem unique paths too we have solved the first variation of this problem this one is pretty similar we're given an M by n grid so this is our grid down here we are going to start at the top left position where this robot is ...
Unique Paths II
unique-paths-ii
You are given an `m x n` integer array `grid`. There is a robot initially located at the **top-left corner** (i.e., `grid[0][0]`). The robot tries to move to the **bottom-right corner** (i.e., `grid[m - 1][n - 1]`). The robot can only move either down or right at any point in time. An obstacle and space are marked as ...
The robot can only move either down or right. Hence any cell in the first row can only be reached from the cell left to it. However, if any cell has an obstacle, you don't let that cell contribute to any path. So, for the first row, the number of ways will simply be if obstacleGrid[i][j] is not an obstacle ...
Array,Dynamic Programming,Matrix
Medium
62,1022
1,732
hey everybody this is Larry this is day 19 of the legal daily challenge hit the like button hit the Subscribe button join me on Discord let me know what you think about today's problem today's contest everything in between uh today's contest we might say I don't know I went on a long hike today so I'm a little bit tire...
Find the Highest Altitude
minimum-one-bit-operations-to-make-integers-zero
There is a biker going on a road trip. The road trip consists of `n + 1` points at different altitudes. The biker starts his trip on point `0` with altitude equal `0`. You are given an integer array `gain` of length `n` where `gain[i]` is the **net gain in altitude** between points `i`​​​​​​ and `i + 1` for all (`0 <=...
The fastest way to convert n to zero is to remove all set bits starting from the leftmost one. Try some simple examples to learn the rule of how many steps are needed to remove one set bit. consider n=2^k case first, then solve for all n.
Dynamic Programming,Bit Manipulation,Memoization
Hard
2119
1,444
hello guys welcome to deep codes and in today's video we will discuss later question one triple four that says number of ways of cutting a pizza so here you are given a rectangular Pizza represented as a row into columns Matrix where a character a represented an apple and Dot represent an empty cell further you are giv...
Number of Ways of Cutting a Pizza
number-of-steps-to-reduce-a-number-to-zero
Given a rectangular pizza represented as a `rows x cols` matrix containing the following characters: `'A'` (an apple) and `'.'` (empty cell) and given the integer `k`. You have to cut the pizza into `k` pieces using `k-1` cuts. For each cut you choose the direction: vertical or horizontal, then you choose a cut positi...
Simulate the process to get the final answer.
Math,Bit Manipulation
Easy
1303,2288
1,716
don't want to miss today's questions i said it's easy money in liquid bank heresy wants to save money for his first car he puts money in the league code bank every day he starts by putting one dollar on monday every day from tuesday to sunday he puts he'll put one dollar more than the day before on every subsequent mon...
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
521
hey everyone welcome back and today we'll be doing another lead code five two one longest uncommon subsequence one an easy one but have a lot of dislikes 90 dislikes in this problem given to Strings A and B return the length of the longest and common subsequence where subsequence between A and B if the longest uncommon...
Longest Uncommon Subsequence I
longest-uncommon-subsequence-i
Given two strings `a` and `b`, return _the length of the **longest uncommon subsequence** between_ `a` _and_ `b`. If the longest uncommon subsequence does not exist, return `-1`. An **uncommon subsequence** between two strings is a string that is a **subsequence of one but not the other**. A **subsequence** of a stri...
null
String
Easy
522
139
for given a string s and a dictionary of strings word dictionary return through if s can be segmented into a space separated sequence of one or more dictionary words because code space separated whatever it is as long as doesn't really matter note that the same word in the dictionary may be reused multiple times spee f...
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
82
so the problem says that you are given the head of a sorted linked list you to delete all nodes that have duplicate numbers leaving only distinct numbers from the original list also you have to return the linked list sorted as well if you look at the first example the number three is repeated twice and the number 4 is ...
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
59
um hello so today we are going to take a look at this problem called spiral matrix 2. um it's part of what's called april ladies challenge um so we get an integer n and we're going to generate an n by n matrix filled with elements from 1 to n squared in spiral order so this is the main uh complication here is in spotte...
Spiral Matrix II
spiral-matrix-ii
Given a positive integer `n`, generate an `n x n` `matrix` filled with elements from `1` to `n2` in spiral order. **Example 1:** **Input:** n = 3 **Output:** \[\[1,2,3\],\[8,9,4\],\[7,6,5\]\] **Example 2:** **Input:** n = 1 **Output:** \[\[1\]\] **Constraints:** * `1 <= n <= 20`
null
Array,Matrix,Simulation
Medium
54,921
1,374
hello friends today we are discuss this question from lead code weekly contest 179 problem number 137 for generate a string with characters that have odd count it's a easy problem in the problem statement states that you are given an integer n you have to return a string n is return a string with n characters ok says t...
Generate a String With Characters That Have Odd Counts
leftmost-column-with-at-least-a-one
Given an integer `n`, _return a string with `n` characters such that each character in such string occurs **an odd number of times**_. The returned string must contain only lowercase English letters. If there are multiples valid strings, return **any** of them. **Example 1:** **Input:** n = 4 **Output:** "pppz " **...
1. (Binary Search) For each row do a binary search to find the leftmost one on that row and update the answer. 2. (Optimal Approach) Imagine there is a pointer p(x, y) starting from top right corner. p can only move left or down. If the value at p is 0, move down. If the value at p is 1, move left. Try to figure out th...
Array,Binary Search,Matrix,Interactive
Medium
null
376
Story gone English Video Way Bill Discuss Liquid Question Thoughts What is the meaning of alternative numbers Difference of alternative numbers if positive negative alternative comes what does it mean our alternative is other vice note ok as if this number is given to us what will we do ok see Longest Return D Length o...
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
336
hello everyone welcome to my channel so today we are going to do leadco daily challenge palindrome pairs so basically in this question we are given with a list of words and this list of words we are required to basically check that how many pairs of palindromes are being there so here you can see that ABCD is there and...
Palindrome Pairs
palindrome-pairs
You are given a **0-indexed** array of **unique** strings `words`. A **palindrome pair** is a pair of integers `(i, j)` such that: * `0 <= i, j < words.length`, * `i != j`, and * `words[i] + words[j]` (the concatenation of the two strings) is a palindrome. Return _an array of all the **palindrome pairs** of_ `...
null
Array,Hash Table,String,Trie
Hard
5,214,2237
1,399
hi my name is david today we're going to do number one three nine count largest group this is an easy level problem on lead code and want to solve it in javascript so we're given an integer n that we take in and each number from 1 to n is grouped according to the sum of its digits return how many groups have the larges...
Count Largest Group
page-recommendations
You are given an integer `n`. Each number from `1` to `n` is grouped according to the sum of its digits. Return _the number of groups that have the largest size_. **Example 1:** **Input:** n = 13 **Output:** 4 **Explanation:** There are 9 groups in total, they are grouped according sum of its digits of numbers from...
null
Database
Medium
2046,2097
206
all right so let's take a look at another linked list problem this one is just called reverse length list it's very common in problems that you might have to reverse a linked list iterate through linked lists so in this particular case let's talk about how you would reverse one so you're given the head of a singly link...
Reverse Linked List
reverse-linked-list
Given the `head` of a singly linked list, reverse the list, and return _the reversed list_. **Example 1:** **Input:** head = \[1,2,3,4,5\] **Output:** \[5,4,3,2,1\] **Example 2:** **Input:** head = \[1,2\] **Output:** \[2,1\] **Example 3:** **Input:** head = \[\] **Output:** \[\] **Constraints:** * The number...
null
Linked List,Recursion
Easy
92,156,234,2196,2236
1,388
hey what's up guys this is chung here so today let's take a look at number one thousand three hundred and eighty eight pizza with three n slices so there's a piece of this with three n slices of varying size and you and your friends will take slices of pizza as follows and basically you if you pick any pizza right and ...
Pizza With 3n Slices
greatest-sum-divisible-by-three
There is a pizza with `3n` slices of varying size, you and your friends will take slices of pizza as follows: * You will pick **any** pizza slice. * Your friend Alice will pick the next slice in the anti-clockwise direction of your pick. * Your friend Bob will pick the next slice in the clockwise direction of yo...
Represent the state as DP[pos][mod]: maximum possible sum starting in the position "pos" in the array where the current sum modulo 3 is equal to mod.
Array,Dynamic Programming,Greedy
Medium
null
1,252
hey how you doing guys it's ilya bella here i recording stuff on youtube chat description for all my information i do all lead code problems make sure you um subscribe to the channel give me a big thumbs up to support it and this is called self with all values in the matrix um given and m which are the dimensions of a ...
Cells with Odd Values in a Matrix
break-a-palindrome
There is an `m x n` matrix that is initialized to all `0`'s. There is also a 2D array `indices` where each `indices[i] = [ri, ci]` represents a **0-indexed location** to perform some increment operations on the matrix. For each location `indices[i]`, do **both** of the following: 1. Increment **all** the cells on ro...
How to detect if there is impossible to perform the replacement? Only when the length = 1. Change the first non 'a' character to 'a'. What if the string has only 'a'? Change the last character to 'b'.
String,Greedy
Medium
null
1,074
weekly contest and apologies I am a bit late today the reason being I went to office had lots of work I came back around 8:30 had dinner took some rest around 8:30 had dinner took some rest around 8:30 had dinner took some rest and here I am in front of the laptop however in the evening I released best technical resume...
Number of Submatrices That Sum to Target
high-five
Given a `matrix` and a `target`, return the number of non-empty submatrices that sum to target. A submatrix `x1, y1, x2, y2` is the set of all cells `matrix[x][y]` with `x1 <= x <= x2` and `y1 <= y <= y2`. Two submatrices `(x1, y1, x2, y2)` and `(x1', y1', x2', y2')` are different if they have some coordinate that is...
How can we solve the problem if we have just one student? Given an student sort their grades and get the top 5 average. Generalize the idea to do it for many students.
Array,Hash Table,Sorting
Easy
null
485
welcome to september's leeco challenge today's problem is max consecutive ones given a binary array nums we turn the maximum number of consecutive ones in the array if we're given an array like this we can see the maximum number of consecutive ones is going to be three like so let's not over complicate this our approac...
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
296
hello and welcome back to the cracking Fang YouTube channel today we are solving a notoriously hard problem 296 best meeting point given an M byn binary grid where one marks the home of a friend return the to uh the minimum total travel distance the total travel distance is the sum of the distances between the houses o...
Best Meeting Point
best-meeting-point
Given an `m x n` binary grid `grid` where each `1` marks the home of one friend, return _the minimal **total travel distance**_. The **total travel distance** is the sum of the distances between the houses of the friends and the meeting point. The distance is calculated using [Manhattan Distance](http://en.wikipedia....
Try to solve it in one dimension first. How can this solution apply to the two dimension case?
Array,Math,Sorting,Matrix
Hard
317,462
1,600
hey everybody this is larry this is me going over q3 of the recent weekly contest 208 where i got really lucky um hit the like button hit the subscribe button join me on discord and cue twist wrong inheritance so again this is an exercise that turns out in reading to constraints uh and what i mean by that is that uh ba...
Throne Inheritance
throne-inheritance
A kingdom consists of a king, his children, his grandchildren, and so on. Every once in a while, someone in the family dies or a child is born. The kingdom has a well-defined order of inheritance that consists of the king as the first member. Let's define the recursive function `Successor(x, curOrder)`, which given a ...
null
null
Medium
null
1,609
Hello hi friends welcome back to loot problem 1609 you know entry le suicide looking details of this problem is one to bring to your notice data this day cream tube videos related to record solution in java s well s java j2ee interview helpful for material videos they discuss You Know All Agreement Go To Interview Ques...
Even Odd Tree
find-all-the-lonely-nodes
A binary tree is named **Even-Odd** if it meets the following conditions: * The root of the binary tree is at level index `0`, its children are at level index `1`, their children are at level index `2`, etc. * For every **even-indexed** level, all nodes at the level have **odd** integer values in **strictly increa...
Do a simple tree traversal, try to check if the current node is lonely or not. Node is lonely if at least one of the left/right pointers is null.
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Easy
563,1005
253
hello everyone welcome back to my channel so today i am here with another meeting rooms question so this meeting rooms question is a follow-up question follow-up question follow-up question to the previous meeting room question if you haven't seen or done the previous meeting rooms question i highly recommend you to ta...
Meeting Rooms II
meeting-rooms-ii
Given an array of meeting time intervals `intervals` where `intervals[i] = [starti, endi]`, return _the minimum number of conference rooms required_. **Example 1:** **Input:** intervals = \[\[0,30\],\[5,10\],\[15,20\]\] **Output:** 2 **Example 2:** **Input:** intervals = \[\[7,10\],\[2,4\]\] **Output:** 1 **Constr...
Think about how we would approach this problem in a very simplistic way. We will allocate rooms to meetings that occur earlier in the day v/s the ones that occur later on, right? If you've figured out that we have to sort the meetings by their start time, the next thing to think about is how do we do the allocation? Th...
Array,Two Pointers,Greedy,Sorting,Heap (Priority Queue)
Medium
56,252,452,1184
450
Hello hello everybody welcome to my channel it's all the problem delete node in binary search tree member classical problem it's kind in interviews and problems looks like easy but it's not video not with family aged such problems sholay 3d problem statement anderson given root no difference of events AND IT DID NOT BE...
Delete Node in a BST
delete-node-in-a-bst
Given a root node reference of a BST and a key, delete the node with the given key in the BST. Return _the **root node reference** (possibly updated) of the BST_. Basically, the deletion can be divided into two stages: 1. Search for a node to remove. 2. If the node is found, delete the node. **Example 1:** **Inpu...
null
Tree,Binary Search Tree,Binary Tree
Medium
791
1,048
Hello Gas Welcome To Me New YouTube Video Today in this video we are going to solve the questions Longest Train What do we have to do in Longest Train Chain? We have a list of words Jivan and we have to rearrange the list and arrange it in the list. By doing this we have to tell the length of the longest string chain o...
Longest String Chain
clumsy-factorial
You are given an array of `words` where each word consists of lowercase English letters. `wordA` is a **predecessor** of `wordB` if and only if we can insert **exactly one** letter anywhere in `wordA` **without changing the order of the other characters** to make it equal to `wordB`. * For example, `"abc "` is a **...
null
Math,Stack,Simulation
Medium
null
778
778 swimming rising water on it n by n grid each square representation at this point and I do something similar to this maybe not it ok we double check real quick sigh I guess not because they told me I didn't do it but ok dose up to that which I will use anyway ok 70s women rising water on an N by n grid each square w...
Swim in Rising Water
reorganize-string
You are given an `n x n` integer matrix `grid` where each value `grid[i][j]` represents the elevation at that point `(i, j)`. The rain starts to fall. At time `t`, the depth of the water everywhere is `t`. You can swim from a square to another 4-directionally adjacent square if and only if the elevation of both square...
Alternate placing the most common letters.
Hash Table,String,Greedy,Sorting,Heap (Priority Queue),Counting
Medium
358,621,1304
876
so hey guys welcome back so let's solve our today's lead code challenge it's a very easy problem middle of the link list so basically we're given the head of a single linguished so it's a single English we have to return the middle node of a link list so if there are two middle nodes we have to return the second middle...
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
546
hello friends in this video we will solve it called problem number 546 remove boxes so first we will understand the problem statement after that we will see approach for this problem and at the end we will see code in java let's understand the question so in the question we have given boxes of different color represent...
Remove Boxes
remove-boxes
You are given several `boxes` with different colors represented by different positive numbers. You may experience several rounds to remove boxes until there is no box left. Each time you can choose some continuous boxes with the same color (i.e., composed of `k` boxes, `k >= 1`), remove them and get `k * k` points. R...
null
Array,Dynamic Programming,Memoization
Hard
664,2247
1,043
hey everybody this is Larry this is day three of the February Leo day challenge hit the like button hit the Subscribe Buton join me on Discord let me know what you think about today's PR 10:43 petition away for maximum sum uh 10:43 petition away for maximum sum uh 10:43 petition away for maximum sum uh yeah I'm here ag...
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
92
let's go question number 92 reverse link to list two this is medium question uh let's get into it given the head of a singly linked list and two integers left and right where left is the smallic under white and liberate the node of the list from position left to position right and return the reversed list let's check t...
Reverse Linked List II
reverse-linked-list-ii
Given the `head` of a singly linked list and two integers `left` and `right` where `left <= right`, reverse the nodes of the list from position `left` to position `right`, and return _the reversed list_. **Example 1:** **Input:** head = \[1,2,3,4,5\], left = 2, right = 4 **Output:** \[1,4,3,2,5\] **Example 2:** **I...
null
Linked List
Medium
206
1,761
and countries abroad today we're going to approach problem 1761 a minimum degree of a connected Trio in a graph 17 is the age that I started programming so no if you didn't start before you were like 11 like some of these nerds um there's still hope for you and 61 is the age by which I hope to retire because um trying ...
Minimum Degree of a Connected Trio in a Graph
count-sorted-vowel-strings
You are given an undirected graph. You are given an integer `n` which is the number of nodes in the graph and an array `edges`, where each `edges[i] = [ui, vi]` indicates that there is an undirected edge between `ui` and `vi`. A **connected trio** is a set of **three** nodes where there is an edge between **every** pa...
For each character, its possible values will depend on the value of its previous character, because it needs to be not smaller than it. Think backtracking. Build a recursive function count(n, last_character) that counts the number of valid strings of length n and whose first characters are not less than last_character....
Dynamic Programming
Medium
null
1,509
everyone welcome to my channel so in this video i'm going to try to solve this problem and at the same time i'm going to follow the general interview steps while trying to solve it so first of all let's restart this question to get a good understanding so minimum difference between largest and smallest volumes removes ...
Minimum Difference Between Largest and Smallest Value in Three Moves
replace-employee-id-with-the-unique-identifier
You are given an integer array `nums`. In one move, you can choose one element of `nums` and change it to **any value**. Return _the minimum difference between the largest and smallest value of `nums` **after performing at most three moves**_. **Example 1:** **Input:** nums = \[5,3,2,4\] **Output:** 0 **Explanation...
null
Database
Easy
null
1,685
hey there welcome back to lead coding in this video we will be solving the second question of lead code biweekly contest 41 name of the problem is sum of absolute differences in the sorted array you are given an integer area numbers sorted in non-decreasing order sorted in non-decreasing order sorted in non-decreasing ...
Sum of Absolute Differences in a Sorted Array
stone-game-v
You are given an integer array `nums` sorted in **non-decreasing** order. Build and return _an integer array_ `result` _with the same length as_ `nums` _such that_ `result[i]` _is equal to the **summation of absolute differences** between_ `nums[i]` _and all the other elements in the array._ In other words, `result[i...
We need to try all possible divisions for the current row to get the max score. As calculating all possible divisions will lead us to calculate some sub-problems more than once, we need to think of dynamic programming.
Array,Math,Dynamic Programming,Game Theory
Hard
909,1240,1522,1617,1788,1808,2002,2156
30
hello and welcome in this video we are going to solve problem number 30 of lead code that is substrings with concatenation of all words so in let's go to the description and try to understand this okay so we have given a string s and the array of fasting words and we have all the strings of words are of same length so ...
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
14
hello everyone let's look at longest common prefix the problem statement is write a function to find the longest common prefix string among an array of strings if there's no common prefix return an empty string for the first example the input of flower flow flight so the output is fl for the second example input are do...
Longest Common Prefix
longest-common-prefix
Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string `" "`. **Example 1:** **Input:** strs = \[ "flower ", "flow ", "flight "\] **Output:** "fl " **Example 2:** **Input:** strs = \[ "dog ", "racecar ", "car "\] **Output:** " "...
null
String
Easy
null
468
today's problem is to validate a given ip address that is you will be given an ip address and you have to say whether it belongs to the ipv4 version of ip address ipv6 version of the ip address or it does not belong to any of these categories that means it is invalid so you have to return one of these three values now ...
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
1,436
hello guys and welcome back to lead Logics this is the destination city problem this is a lead Cod easy and the number for this is 436 so in this problem we are given with an array Parts where parts of I gives City a and City B so this is a pair of cities means there exist a direct path from City a to City B so there i...
Destination City
get-watched-videos-by-your-friends
You are given the array `paths`, where `paths[i] = [cityAi, cityBi]` means there exists a direct path going from `cityAi` to `cityBi`. _Return the destination city, that is, the city without any path outgoing to another city._ It is guaranteed that the graph of paths forms a line without any loop, therefore, there wil...
Do BFS to find the kth level friends. Then collect movies saw by kth level friends and sort them accordingly.
Array,Hash Table,Breadth-First Search,Sorting
Medium
null
931
what's up everyone today we're gonna be going over Lea code 931 minimum path falling and the input is a 2d grid and the output is going to be one integer and what they want is to find the minimum path from the top any of the columns to get to the bottom and what we can do is go either straight down or left or right at ...
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
947
all right so let's talk about the most stones removed with the same rule or column so you're given to the array and then you have to either remove the stone if they have the same rule or the same column so this is a 2d plane i'm going to just draw the diagram and then these are all positive right so i'll just give you ...
Most Stones Removed with Same Row or Column
online-election
On a 2D plane, we place `n` stones at some integer coordinate points. Each coordinate point may have at most one stone. A stone can be removed if it shares either **the same row or the same column** as another stone that has not been removed. Given an array `stones` of length `n` where `stones[i] = [xi, yi]` represen...
null
Array,Hash Table,Binary Search,Design
Medium
1483
1,602
hey everybody this is Larry this is me just doing a bonus premium uh question I haven't done one in a couple of whatever so uh let's do a medium one that I haven't done before and yeah let's go ing give me some good OMG and yeah uh find nearest write note in binary tree is today's uh um 1602. come in the wood of a bina...
Find Nearest Right Node in Binary Tree
find-nearest-right-node-in-binary-tree
Given the `root` of a binary tree and a node `u` in the tree, return _the **nearest** node on the **same level** that is to the **right** of_ `u`_, or return_ `null` _if_ `u` _is the rightmost node in its level_. **Example 1:** **Input:** root = \[1,2,3,null,4,5,6\], u = 4 **Output:** 5 **Explanation:** The nearest n...
null
null
Medium
null
160
hi everyone welcome to the loophead today in this video we will be solving june deep code challenge and the question for today is intersection of two linked list the question is easy tagged and it states that given the heads of two singly linked list had a and had b return the node at which the two lists intersect if t...
Intersection of Two Linked Lists
intersection-of-two-linked-lists
Given the heads of two singly linked-lists `headA` and `headB`, return _the node at which the two lists intersect_. If the two linked lists have no intersection at all, return `null`. For example, the following two linked lists begin to intersect at node `c1`: The test cases are generated such that there are no cycle...
null
Hash Table,Linked List,Two Pointers
Easy
599
1,748
Hello, we are together again in another toast, today's last isamu. Friends, we are given an intelligere series with Yürek elements, and in it, Yürük elements with Unique elements. He mentioned that there are numbers that are seen only once in the series, and in this series, friends, are there all the numbers that are s...
Sum of Unique Elements
best-team-with-no-conflicts
You are given an integer array `nums`. The unique elements of an array are the elements that appear **exactly once** in the array. Return _the **sum** of all the unique elements of_ `nums`. **Example 1:** **Input:** nums = \[1,2,3,2\] **Output:** 4 **Explanation:** The unique elements are \[1,3\], and the sum is 4. ...
First, sort players by age and break ties by their score. You can now consider the players from left to right. If you choose to include a player, you must only choose players with at least that score later on.
Array,Dynamic Programming,Sorting
Medium
null
950
hey everybody this is larry this is me doing an extra problem uh on the code daily challenges august 10 or uh on 2020. so yeah let's kind of do it to do one that we haven't done before and let's see sometimes i get a premium one okay that's good uh hit the like button hit a subscriber and join me on discord especially ...
Reveal Cards In Increasing Order
x-of-a-kind-in-a-deck-of-cards
You are given an integer array `deck`. There is a deck of cards where every card has a unique integer. The integer on the `ith` card is `deck[i]`. You can order the deck in any order you want. Initially, all the cards start face down (unrevealed) in one deck. You will do the following steps repeatedly until all cards...
null
Array,Hash Table,Math,Counting,Number Theory
Easy
null
83
hey people so today we are going to discuss lead code problem remove duplicates from sorted list so in this program we are given a head of sorted linked list and we have to delete all the duplicate nodes that are present in the given linked list and we have to return the linked list in the sorted form so if I have to g...
Remove Duplicates from Sorted List
remove-duplicates-from-sorted-list
Given the `head` of a sorted linked list, _delete all duplicates such that each element appears only once_. Return _the linked list **sorted** as well_. **Example 1:** **Input:** head = \[1,1,2\] **Output:** \[1,2\] **Example 2:** **Input:** head = \[1,1,2,3,3\] **Output:** \[1,2,3\] **Constraints:** * The numb...
null
Linked List
Easy
82,1982
956
Hai Gas Welcome To Me YouTube Video Today We Are Going To Solve That Daily Leaders Challenge And Today's Problem Name It Tallest Billboard So The Problem Statement Date You Are Installing A Billboard And You Want It You Have The Largest Miss Of Equal Height Okay You Example on collection of roads date content d date ca...
Tallest Billboard
number-of-music-playlists
You are installing a billboard and want it to have the largest height. The billboard will have two steel supports, one on each side. Each steel support must be an equal height. You are given a collection of `rods` that can be welded together. For example, if you have rods of lengths `1`, `2`, and `3`, you can weld the...
null
Math,Dynamic Programming,Combinatorics
Hard
null
6
in this video I will explain Lead Core problem number six zigzag conversion in this problem you are given a string and the number of rows and the string has to be expressed in a zigzag fashion what do they mean by zigzag fashion for example let's take the English alphabet for example A to Z and the number of rows is eq...
Zigzag Conversion
zigzag-conversion
The string `"PAYPALISHIRING "` is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N A P L S I I G Y I R And then read line by line: `"PAHNAPLSIIGYIR "` Write the code that will take a string and make this co...
null
String
Medium
null
23
welcome to january's leak code challenge today's problem is merge case sorted lists you are given an array of k linked lists each linked list is sorted in ascending order merge all the linked lists into one sorted linked list and return it if you recall with merging two sorted linked lists we could use the two pointer ...
Merge k Sorted Lists
merge-k-sorted-lists
You are given an array of `k` linked-lists `lists`, each linked-list is sorted in ascending order. _Merge all the linked-lists into one sorted linked-list and return it._ **Example 1:** **Input:** lists = \[\[1,4,5\],\[1,3,4\],\[2,6\]\] **Output:** \[1,1,2,3,4,4,5,6\] **Explanation:** The linked-lists are: \[ 1->4...
null
Linked List,Divide and Conquer,Heap (Priority Queue),Merge Sort
Hard
21,264
46
hello everyone let's look at permutations the problem statement is we are given array numbers of distinct integers we want to return all possible permutations and we can return an order let's look at first example the input numbers is one two three the output is array of arrays so it has one two three one three two thr...
Permutations
permutations
Given an array `nums` of distinct integers, return _all the possible permutations_. You can return the answer in **any order**. **Example 1:** **Input:** nums = \[1,2,3\] **Output:** \[\[1,2,3\],\[1,3,2\],\[2,1,3\],\[2,3,1\],\[3,1,2\],\[3,2,1\]\] **Example 2:** **Input:** nums = \[0,1\] **Output:** \[\[0,1\],\[1,0\...
null
Array,Backtracking
Medium
31,47,60,77
1,011
today we are going to talk about another very nice interview question or neat code problem 101 1 so this question talks about a conveyor belt that has packages that must be shipped from one point to another within D days so we are given an array of packages that there's weights specified so it's like package one has we...
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
382
foreign with the lonely Dash and today we're going over leap code question 382 linked list random node which states given a singly linked list return a random node's value from the linked list each node must have the same probability of being chosen implement the solution class so that's going to give you a class calle...
Linked List Random Node
linked-list-random-node
Given a singly linked list, return a random node's value from the linked list. Each node must have the **same probability** of being chosen. Implement the `Solution` class: * `Solution(ListNode head)` Initializes the object with the head of the singly-linked list `head`. * `int getRandom()` Chooses a node randoml...
null
Linked List,Math,Reservoir Sampling,Randomized
Medium
398
95
hello and welcome to another video in this video we're going to be working on unique binary search crease 2. so in this problem you're giving an integer Annie when you want to return all the structural unique vsts which have n nodes of unique values one to n or turn the answer in any order so for n equals three is our ...
Unique Binary Search Trees II
unique-binary-search-trees-ii
Given an integer `n`, return _all the structurally unique **BST'**s (binary search trees), which has exactly_ `n` _nodes of unique values from_ `1` _to_ `n`. Return the answer in **any order**. **Example 1:** **Input:** n = 3 **Output:** \[\[1,null,2,null,3\],\[1,null,3,2\],\[2,1,3\],\[3,1,null,null,2\],\[3,2,null,1\...
null
Dynamic Programming,Backtracking,Tree,Binary Search Tree,Binary Tree
Medium
96,241
343
hello everyone so in this video let us talk about a problem from lead course and media level problem the problem name is integer break so let's start the problem statement goes like this that you're given an integer n and you have to break that into the sum of key positive integers as that K is greater than equal to an...
Integer Break
integer-break
Given an integer `n`, break it into the sum of `k` **positive integers**, where `k >= 2`, and maximize the product of those integers. Return _the maximum product you can get_. **Example 1:** **Input:** n = 2 **Output:** 1 **Explanation:** 2 = 1 + 1, 1 \* 1 = 1. **Example 2:** **Input:** n = 10 **Output:** 36 **Exp...
There is a simple O(n) solution to this problem. You may check the breaking results of n ranging from 7 to 10 to discover the regularities.
Math,Dynamic Programming
Medium
1936
344
let's reverse strings now sure i can always use the same inbuilt reverse functions for this in a cheeky way but where's the fun in that so we will be dealing with manipulating the positions such as position zero or position four in this five letter word since strings are immutable meaning that i cannot change them inte...
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,684
Hello friends welcome to a new video in this video I am going to discuss a Lead Core problem okay and this problem is based on strings so the problem is counter number of the consistent strings so you are Kevin are staying allowed string okay allow Steam and then add it okay um a string type added okay and a string is ...
Count the Number of Consistent Strings
find-latest-group-of-size-m
You are given a string `allowed` consisting of **distinct** characters and an array of strings `words`. A string is **consistent** if all characters in the string appear in the string `allowed`. Return _the number of **consistent** strings in the array_ `words`. **Example 1:** **Input:** allowed = "ab ", words = \[...
Since the problem asks for the latest step, can you start the searching from the end of arr? Use a map to store the current “1” groups. At each step (going backwards) you need to split one group and update the map.
Array,Binary Search,Simulation
Medium
null
136
what's up youtube today we're going to take a look at lee problem number 136 single number marked as easy let's get into it so the problem statement says given a non-empty array of integer nums given a non-empty array of integer nums given a non-empty array of integer nums every element appears twice except for one fin...
Single Number
single-number
Given a **non-empty** array of integers `nums`, every element appears _twice_ except for one. Find that single one. You must implement a solution with a linear runtime complexity and use only constant extra space. **Example 1:** **Input:** nums = \[2,2,1\] **Output:** 1 **Example 2:** **Input:** nums = \[4,1,2,1,2...
null
Array,Bit Manipulation
Easy
137,260,268,287,389
1,685
hi friends uh welcome to followup in this video we're going to look at problem 1685 some of absolute differences in the SED array uh overall in this video we're going to use partial sum or prefix sum so this is our strategy so our plan will be the following first we're going to digest the problem requirements and then ...
Sum of Absolute Differences in a Sorted Array
stone-game-v
You are given an integer array `nums` sorted in **non-decreasing** order. Build and return _an integer array_ `result` _with the same length as_ `nums` _such that_ `result[i]` _is equal to the **summation of absolute differences** between_ `nums[i]` _and all the other elements in the array._ In other words, `result[i...
We need to try all possible divisions for the current row to get the max score. As calculating all possible divisions will lead us to calculate some sub-problems more than once, we need to think of dynamic programming.
Array,Math,Dynamic Programming,Game Theory
Hard
909,1240,1522,1617,1788,1808,2002,2156
250
hi guys um today i'll be doing this liquid question count unit value in the subtree so basically we want to count um the note if there's no child so there's no left and right trial we increment it by one so another thing is if the child and the parent has the same value we want to increment it by one yep so we will sta...
Count Univalue Subtrees
count-univalue-subtrees
Given the `root` of a binary tree, return _the number of **uni-value**_ _subtrees_. A **uni-value subtree** means all nodes of the subtree have the same value. **Example 1:** **Input:** root = \[5,1,5,5,5,null,5\] **Output:** 4 **Example 2:** **Input:** root = \[\] **Output:** 0 **Example 3:** **Input:** root = ...
null
Tree,Depth-First Search,Binary Tree
Medium
572,687
83
what's up guys i'm xavier naidoo a hacker Winkley code encoding tutorials so please subscribe to my channel and check me out if you haven't already also a like on this video would help me immensely today I'm going over remove duplicates from sorted list so this is a pretty simple problem we just have to remove all dupl...
Remove Duplicates from Sorted List
remove-duplicates-from-sorted-list
Given the `head` of a sorted linked list, _delete all duplicates such that each element appears only once_. Return _the linked list **sorted** as well_. **Example 1:** **Input:** head = \[1,1,2\] **Output:** \[1,2\] **Example 2:** **Input:** head = \[1,1,2,3,3\] **Output:** \[1,2,3\] **Constraints:** * The numb...
null
Linked List
Easy
82,1982
190
hey everyone today we'll be doing another lead code 190 reverse bits this is an easy one reverse bits of a given 32 bit unsigned in teacher and this is a very easy problem in which we are given unsigned integers integer 32 bits it's 32 bits and we have to reverse it and then return it and that's it so our easy way the ...
Reverse Bits
reverse-bits
Reverse bits of a given 32 bits unsigned integer. **Note:** * Note that in some languages, such as Java, there is no unsigned integer type. In this case, both input and output will be given as a signed integer type. They should not affect your implementation, as the integer's internal binary representation is the s...
null
Divide and Conquer,Bit Manipulation
Easy
7,191,2238
343
hello people today we'll be solving lead code daily equation 343 which is integer break and then we'll be moving to the step by step Java solution for it so the problem we are tackling today is about breaking an integer into the sum of positive integers to maximize their produ and we'll be given an integer n and we nee...
Integer Break
integer-break
Given an integer `n`, break it into the sum of `k` **positive integers**, where `k >= 2`, and maximize the product of those integers. Return _the maximum product you can get_. **Example 1:** **Input:** n = 2 **Output:** 1 **Explanation:** 2 = 1 + 1, 1 \* 1 = 1. **Example 2:** **Input:** n = 10 **Output:** 36 **Exp...
There is a simple O(n) solution to this problem. You may check the breaking results of n ranging from 7 to 10 to discover the regularities.
Math,Dynamic Programming
Medium
1936
399
hey what's up guys this is john here again so uh so this time i want to talk about uh today's daily challenge problem uh which is number 399 evaluate division and okay you're given like equations in the format of a divided by b equals to k where a and b are variables represented as strings which is this one the first o...
Evaluate Division
evaluate-division
You are given an array of variable pairs `equations` and an array of real numbers `values`, where `equations[i] = [Ai, Bi]` and `values[i]` represent the equation `Ai / Bi = values[i]`. Each `Ai` or `Bi` is a string that represents a single variable. You are also given some `queries`, where `queries[j] = [Cj, Dj]` rep...
Do you recognize this as a graph problem?
Array,Depth-First Search,Breadth-First Search,Union Find,Graph,Shortest Path
Medium
null
1,737
hello friends today i'm going to talk about the difficult 1737 change minimum characters to satisfy one of three conditions you are given two strings a and b that consists of lowercase networks in one operation you can change any network in a or b to any lower case networks so your goal is to satisfy one of the three c...
Change Minimum Characters to Satisfy One of Three Conditions
maximum-nesting-depth-of-the-parentheses
You are given two strings `a` and `b` that consist of lowercase letters. In one operation, you can change any character in `a` or `b` to **any lowercase letter**. Your goal is to satisfy **one** of the following three conditions: * **Every** letter in `a` is **strictly less** than **every** letter in `b` in the alp...
The depth of any character in the VPS is the ( number of left brackets before it ) - ( number of right brackets before it )
String,Stack
Easy
1208
1,734
hi guys in this video we are going to discuss the problem decode X Art permutation which is from lead code so the problem statement states that we are given an encoded array of size n and the N is always even so uh this encoded array is generated using this formula which is encoded of I is equal to form of i x r Prime ...
Decode XORed Permutation
bank-account-summary-ii
There is an integer array `perm` that is a permutation of the first `n` positive integers, where `n` is always **odd**. It was encoded into another integer array `encoded` of length `n - 1`, such that `encoded[i] = perm[i] XOR perm[i + 1]`. For example, if `perm = [1,3,2]`, then `encoded = [2,1]`. Given the `encoded`...
null
Database
Easy
null
173
welcome back to the channel today we are going to discuss solute code problem 173 binary search tree iterator so the problem statement says that implement the bst iterator class that represents an iterator over in order traversal of binary search tree so bst iterator tree node root so this is the constructor so initial...
Binary Search Tree Iterator
binary-search-tree-iterator
Implement the `BSTIterator` class that represents an iterator over the **[in-order traversal](https://en.wikipedia.org/wiki/Tree_traversal#In-order_(LNR))** of a binary search tree (BST): * `BSTIterator(TreeNode root)` Initializes an object of the `BSTIterator` class. The `root` of the BST is given as part of the co...
null
Stack,Tree,Design,Binary Search Tree,Binary Tree,Iterator
Medium
94,251,281,284,285,1729
101
Jhal Hello Everyone Swam This Video Were Going To Discuss Problem Symmetry So Let's Move Ahead And See What Is Problems And How To Solve This Problem Will Give With The Root Of Every Like Will Complete Three Do Subscribe My Channel Subscribe Must Subscribe And Like This Channel This Is The Mirror Image Consider When Th...
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
98
Jhaal Hello Bhai Welcome Tel Garm Kund Aisi Udayveer Victory In This Question Thursday Video subscribe and subscribe the Channel and subscribe the Hain To Is Seervi Subscribe Must Subscribe Now To 7 Questions Page Subscribe That Redmi Ignore Just Compare Value To The Root Not give the best wishes in the subscribe and s...
Validate Binary Search Tree
validate-binary-search-tree
Given the `root` of a binary tree, _determine if it is a valid binary search tree (BST)_. A **valid BST** is defined as follows: * The left subtree of a node contains only nodes with keys **less than** the node's key. * The right subtree of a node contains only nodes with keys **greater than** the node's key. * ...
null
Tree,Depth-First Search,Binary Search Tree,Binary Tree
Medium
94,501
269
hey everyone in this video let's take a look at question 269 alien dictionary only code this is part of our blind 75 list of questions so let's begin this question is actually a premium question that's why we're doing it on this website lint code and why the number here is different but otherwise the question the test ...
Alien Dictionary
alien-dictionary
There is a new alien language that uses the English alphabet. However, the order among the letters is unknown to you. You are given a list of strings `words` from the alien language's dictionary, where the strings in `words` are **sorted lexicographically** by the rules of this new language. Return _a string of the u...
null
Array,String,Depth-First Search,Breadth-First Search,Graph,Topological Sort
Hard
210
38
hey guys how's everything going let's take a look at number 38 countin say we're giving we are given a special rule of generating a string the first one is one so we need to count the every digits of the string and generate a new one so there's only one so one for these string there will be two one so next one is two o...
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
834
hello everyone welcome to day 4 of september eco challenge and today's question is sum of distances in tree in this question we are given an undirected connected tree with n nodes in it labeled from 0 to n minus 1 and their n minus 1 edges in it we need to tell the count of distances of each ith index with all other el...
Sum of Distances in Tree
ambiguous-coordinates
There is an undirected connected tree with `n` nodes labeled from `0` to `n - 1` and `n - 1` edges. You are given the integer `n` and the array `edges` where `edges[i] = [ai, bi]` indicates that there is an edge between nodes `ai` and `bi` in the tree. Return an array `answer` of length `n` where `answer[i]` is the s...
null
String,Backtracking
Medium
null
149
So gas welcome and welcome back to my channel so today our problem is max points on a line so in this problem statement what have you given us here we have been given an arrow points where your points I is representing A and Ye Ko, what is this of yours, the coordinator of any point, okay, so what we have to do here, w...
Max Points on a Line
max-points-on-a-line
Given an array of `points` where `points[i] = [xi, yi]` represents a point on the **X-Y** plane, return _the maximum number of points that lie on the same straight line_. **Example 1:** **Input:** points = \[\[1,1\],\[2,2\],\[3,3\]\] **Output:** 3 **Example 2:** **Input:** points = \[\[1,1\],\[3,2\],\[5,3\],\[4,1\]...
null
Array,Hash Table,Math,Geometry
Hard
356,2287
212
Hello hello welcome present world today going to solve today liquid problem it means valsad to end whatsapp to check it a video subscribe The Video then subscribe to the Page if you liked The Video then subscribe to define and this research in the world and returned his verses word written 200 words exact phrase 800 60...
Word Search II
word-search-ii
Given an `m x n` `board` of characters and a list of strings `words`, return _all words on the board_. Each word must be constructed from letters of sequentially adjacent cells, where **adjacent cells** are horizontally or vertically neighboring. The same letter cell may not be used more than once in a word. **Exampl...
You would need to optimize your backtracking to pass the larger test. Could you stop backtracking earlier? If the current candidate does not exist in all words' prefix, you could stop backtracking immediately. What kind of data structure could answer such query efficiently? Does a hash table work? Why or why not? How a...
Array,String,Backtracking,Trie,Matrix
Hard
79,1022,1433
1,685
hey everybody this is larry this is me going with q2 of the bi-weekly me going with q2 of the bi-weekly me going with q2 of the bi-weekly contest 41 some of the absolute differences in assorted array so basically this one it's um a tricky problem to think about uh but you know you could do that well you hit the like bu...
Sum of Absolute Differences in a Sorted Array
stone-game-v
You are given an integer array `nums` sorted in **non-decreasing** order. Build and return _an integer array_ `result` _with the same length as_ `nums` _such that_ `result[i]` _is equal to the **summation of absolute differences** between_ `nums[i]` _and all the other elements in the array._ In other words, `result[i...
We need to try all possible divisions for the current row to get the max score. As calculating all possible divisions will lead us to calculate some sub-problems more than once, we need to think of dynamic programming.
Array,Math,Dynamic Programming,Game Theory
Hard
909,1240,1522,1617,1788,1808,2002,2156
1,792
Hello Everyone I Hope You Are Doing Well And Today Will Be Solving Another Contest Question Vijay Font Interesting Request Name Is Maximum Avesh Show Medium Question Ultrasonication Together In This Question Giver School Subscribe Giver 2825 What is the number of the total number of students in the Class Image Bill-201...
Maximum Average Pass Ratio
find-the-most-competitive-subsequence
There is a school that has classes of students and each class will be having a final exam. You are given a 2D integer array `classes`, where `classes[i] = [passi, totali]`. You know beforehand that in the `ith` class, there are `totali` total students, but only `passi` number of students will pass the exam. You are al...
In lexicographical order, the elements to the left have higher priority than those that come after. Can you think of a strategy that incrementally builds the answer from left to right?
Array,Stack,Greedy,Monotonic Stack
Medium
402,1159
442
MP3 In today 's video, we are going to ask a question, 's video, we are going to ask a question, 's video, we are going to ask a question, Late is speaking, Find all duplicate sin and Hey, Given and Interior is speaking, a question from AIIMS where all the features in this range are definitely subscribed to. Once again...
Find All Duplicates in an Array
find-all-duplicates-in-an-array
Given an integer array `nums` of length `n` where all the integers of `nums` are in the range `[1, n]` and each integer appears **once** or **twice**, return _an array of all the integers that appears **twice**_. You must write an algorithm that runs in `O(n)` time and uses only constant extra space. **Example 1:** ...
null
Array,Hash Table
Medium
448
594
harmonious sequence subsequence so we Define a harmonious array as an array where difference between its maximum value and its minimum value will be exactly one so given an integer array written the length of its longest harmonious subsequence among all possible subsequences a subsequence of an array is a sequence that...
Longest Harmonious Subsequence
longest-harmonious-subsequence
We define a harmonious array as an array where the difference between its maximum value and its minimum value is **exactly** `1`. Given an integer array `nums`, return _the length of its longest harmonious subsequence among all its possible subsequences_. A **subsequence** of array is a sequence that can be derived f...
null
Array,Hash Table,Sorting
Easy
null
334
hello guys today we will solve lead chord problem 334 so here we have given one array in that we have to find a triplet such that I is greater than J is greater than K is a valid you know so uh here we have you know first of all if we want to do this thing using Brute Force then we can start from the last element and t...
Increasing Triplet Subsequence
increasing-triplet-subsequence
Given an integer array `nums`, return `true` _if there exists a triple of indices_ `(i, j, k)` _such that_ `i < j < k` _and_ `nums[i] < nums[j] < nums[k]`. If no such indices exists, return `false`. **Example 1:** **Input:** nums = \[1,2,3,4,5\] **Output:** true **Explanation:** Any triplet where i < j < k is valid. ...
null
Array,Greedy
Medium
300,2122,2280
1,443
all right let's look at this problem called minimum time to collect all apples in a tree so essentially what is given to us is we are given an edges array which gives us all the edges of the tree in an undirected fashion and we also given a has Apple array which tells whether or not a specific node is an apple or node ...
Minimum Time to Collect All Apples in a Tree
minimum-distance-to-type-a-word-using-two-fingers
Given an undirected tree consisting of `n` vertices numbered from `0` to `n-1`, which has some apples in their vertices. You spend 1 second to walk over one edge of the tree. _Return the minimum time in seconds you have to spend to collect all apples in the tree, starting at **vertex 0** and coming back to this vertex....
Use dynamic programming. dp[i][j][k]: smallest movements when you have one finger on i-th char and the other one on j-th char already having written k first characters from word.
String,Dynamic Programming
Hard
2088
48
hey what's up guys Nick white here I do technically stuff on twitching YouTube check the description for all my information you can I post a bunch of stuff on my picture on patreon if you want to I'm having a tough time talking support me or whatever and reach out to me on discord patreon whatever I try and get back to...
Rotate Image
rotate-image
You are given an `n x n` 2D `matrix` representing an image, rotate the image by **90** degrees (clockwise). You have to rotate the image [**in-place**](https://en.wikipedia.org/wiki/In-place_algorithm), which means you have to modify the input 2D matrix directly. **DO NOT** allocate another 2D matrix and do the rotati...
null
Array,Math,Matrix
Medium
2015
926
hey everybody this is larry this is me going over day 10 of the august league daily challenge hit the uh for i guess hit the like button the subscriber and join me on discord let me know what you think about today's problem i just want to someone uh on my discord actually recently gave me a uh thing uh so i started doi...
Flip String to Monotone Increasing
find-and-replace-pattern
A binary string is monotone increasing if it consists of some number of `0`'s (possibly none), followed by some number of `1`'s (also possibly none). You are given a binary string `s`. You can flip `s[i]` changing it from `0` to `1` or from `1` to `0`. Return _the minimum number of flips to make_ `s` _monotone increa...
null
Array,Hash Table,String
Medium
null
1,712
hi everyone it's albert happy new year and this is the first decoding video of 2021 and today let's solve the median question from the contest ways to split array into three sub arrays the question statement so we are given an integer array and we will say a split of an integer array is good if the array can be split i...
Ways to Split Array Into Three Subarrays
unique-orders-and-customers-per-month
A split of an integer array is **good** if: * The array is split into three **non-empty** contiguous subarrays - named `left`, `mid`, `right` respectively from left to right. * The sum of the elements in `left` is less than or equal to the sum of the elements in `mid`, and the sum of the elements in `mid` is less ...
null
Database
Easy
null
191
alrighty what's up guys we're back with that last video on our foundations of data structures before we go into more complex algorithms this time we're doing legal number 191 number of one bit so before we go into a question let's look at some binary to understand what it's are exactly so here we have a 4-bit are exact...
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