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
395
hello gas field under consideration for subscribing character subscribe and subscribe this Video subscribe button video tenders 59 click the absolute subscribe button city pin code will also subscribe modification in president appointed election subscribe and subscribe Video subscribe and width shrubs And - Video subsc...
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
1,758
hello guys and welcome back to lead Logics this is the minimum changes to make an alternating binary string problem from lead code this is a lead code easy and the number for this is 1758 so we are given with a string in the problem there's a string s consisting of only characters zero and one that is it is a binary st...
Minimum Changes To Make Alternating Binary String
distribute-repeating-integers
You are given a string `s` consisting only of the characters `'0'` and `'1'`. In one operation, you can change any `'0'` to `'1'` or vice versa. The string is called alternating if no two adjacent characters are equal. For example, the string `"010 "` is alternating, while the string `"0100 "` is not. Return _the **m...
Count the frequencies of each number. For example, if nums = [4,4,5,5,5], frequencies = [2,3]. Each customer wants all of their numbers to be the same. This means that each customer will be assigned to one number. Use dynamic programming. Iterate through the numbers' frequencies, and choose some subset of customers to ...
Array,Dynamic Programming,Backtracking,Bit Manipulation,Bitmask
Hard
null
566
welcome to july's leeco challenge this problem is called reshape the matrix you can see i've missed a bunch of problems last week so i apologize for that i'll be trying to catch up throughout the month all right so in matlab there is a handy function called reshape which i'm well aware of which can reshape an m times n...
Reshape the Matrix
reshape-the-matrix
In MATLAB, there is a handy function called `reshape` which can reshape an `m x n` matrix into a new one with a different size `r x c` keeping its original data. You are given an `m x n` matrix `mat` and two integers `r` and `c` representing the number of rows and the number of columns of the wanted reshaped matrix. ...
Do you know how 2d matrix is stored in 1d memory? Try to map 2-dimensions into one. M[i][j]=M[n*i+j] , where n is the number of cols. This is the one way of converting 2-d indices into one 1-d index. Now, how will you convert 1-d index into 2-d indices? Try to use division and modulus to convert 1-d index into 2-d...
Array,Matrix,Simulation
Easy
2132
887
hey what's up guys this is chung here so today uh let's take a look at this called problem number 887 super act drop so this one is a very classic you know problem you know in terms of dp so basically you're given like a kx and then you're given like building floors with n floor from one to n right so i mean each act i...
Super Egg Drop
minimum-cost-to-hire-k-workers
You are given `k` identical eggs and you have access to a building with `n` floors labeled from `1` to `n`. You know that there exists a floor `f` where `0 <= f <= n` such that any egg dropped at a floor **higher** than `f` will **break**, and any egg dropped **at or below** floor `f` will **not break**. Each move, y...
null
Array,Greedy,Sorting,Heap (Priority Queue)
Hard
null
5
Hello friends, welcome to this video, question number five is the list code, the question of the longest platform is the question of all these media, it is the question of rings category, let's start with the longest and subscribe, then let's do the problem statement with the problem statement, I will give you one more...
Longest Palindromic Substring
longest-palindromic-substring
Given a string `s`, return _the longest_ _palindromic_ _substring_ in `s`. **Example 1:** **Input:** s = "babad " **Output:** "bab " **Explanation:** "aba " is also a valid answer. **Example 2:** **Input:** s = "cbbd " **Output:** "bb " **Constraints:** * `1 <= s.length <= 1000` * `s` consist of only dig...
How can we reuse a previously computed palindrome to compute a larger palindrome? If “aba” is a palindrome, is “xabax” a palindrome? Similarly is “xabay” a palindrome? Complexity based hint: If we use brute-force and check whether for every start and end position a substring is a palindrome we have O(n^2) start - end ...
String,Dynamic Programming
Medium
214,266,336,516,647
344
okay so how's it going ladies and gentlemen so today we are going to solve one of the coolest problem which is reverse string 344 lead code okay so uh i have already made a like i have already posted a video on this problem like few uh like maybe a year ago okay now you asking like why you are putting it back again ah ...
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
221
hello guys welcome to another video of the series of coding trivia to solve the problem it's called maximal square given an mn2n binary matrix filled with zeros and ones you have to find the largest square containing only once and return its area okay let's try to take an example to understand this question better so w...
Maximal Square
maximal-square
Given an `m x n` binary `matrix` filled with `0`'s and `1`'s, _find the largest square containing only_ `1`'s _and return its area_. **Example 1:** **Input:** matrix = \[\[ "1 ", "0 ", "1 ", "0 ", "0 "\],\[ "1 ", "0 ", "1 ", "1 ", "1 "\],\[ "1 ", "1 ", "1 ", "1 ", "1 "\],\[ "1 ", "0 ", "0 ", "1 ", "0 "\]\] **Output:*...
null
Array,Dynamic Programming,Matrix
Medium
85,769,1312,2200
11
hello everyone so in today's question we are going to see container with most water that is a lead code question number 11. so here the program is there like bit between a largest height what is the maximum water we can store so here's the easiest way to do the same and you have the full fledged question like solution ...
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,839
hello welcome back today let's try to solve another lyrical problem 1839 longest substrate of all vowels in order so what did I mean by both remix Nae IOU and it should be Saturday in order like this way if it is not in order so we will not quote it we just need to return the longest so for example this one with a e i ...
Longest Substring Of All Vowels in Order
decode-xored-array
A string is considered **beautiful** if it satisfies the following conditions: * Each of the 5 English vowels (`'a'`, `'e'`, `'i'`, `'o'`, `'u'`) must appear **at least once** in it. * The letters must be sorted in **alphabetical order** (i.e. all `'a'`s before `'e'`s, all `'e'`s before `'i'`s, etc.). For example...
Since that encoded[i] = arr[i] XOR arr[i+1], then arr[i+1] = encoded[i] XOR arr[i]. Iterate on i from beginning to end, and set arr[i+1] = encoded[i] XOR arr[i].
Array,Bit Manipulation
Easy
null
376
hello guys welcome back today we have this question called wiggle subsequence now first of all let's take a look at what the question means by the word wiggle now let's say we are given a sequence of numbers like 9 8 10 2 4 0 5 and 1. now the question calls such a sequence of numbers a wiggle sequence now this is becau...
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
35
That one ice welcome to record as per today's problem china shirt position this youtube channel please do subscribe vishal to complete your problems and problems is given solidarity and target value return indicated targets point is not returned and spirit be id in order to fill ajeem notification Vowel Problems Meanwh...
Search Insert Position
search-insert-position
Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You must write an algorithm with `O(log n)` runtime complexity. **Example 1:** **Input:** nums = \[1,3,5,6\], target = 5 **Output:** 2 **Exa...
null
Array,Binary Search
Easy
278
701
hello friends so today in this video we're gonna discuss an interesting problem from lead code which is a medium level problem name insert into a binary search tree so there can be a number of ways to insert in a binary search tree but first we have to understand what is a binary search tree and if in the simplest term...
Insert into a Binary Search Tree
insert-into-a-binary-search-tree
You are given the `root` node of a binary search tree (BST) and a `value` to insert into the tree. Return _the root node of the BST after the insertion_. It is **guaranteed** that the new value does not exist in the original BST. **Notice** that there may exist multiple valid ways for the insertion, as long as the tre...
null
null
Medium
null
289
hey everyone welcome to let boy coding today we're going to a soft 89 game of life and business a very common question in the interview this is the question that do not test our algorithm skills but it's test us on how to follow the instructions and how to handle age cases very carefully so unless without question the ...
Game of Life
game-of-life
According to [Wikipedia's article](https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life): "The **Game of Life**, also known simply as **Life**, is a cellular automaton devised by the British mathematician John Horton Conway in 1970. " The board is made up of an `m x n` grid of cells, where each cell has an initial st...
null
Array,Matrix,Simulation
Medium
73
391
Yes, hello, this is Live Coding Labopal. Today, I will solve the problem called perfect rectangle, number 391 in Litcode. Today's problem is a hard problem. To explain the problem briefly, sub-squares are input, and sub-squares are input, and sub-squares are input, and when the squares are well combined, it is a large ...
Perfect Rectangle
perfect-rectangle
Given an array `rectangles` where `rectangles[i] = [xi, yi, ai, bi]` represents an axis-aligned rectangle. The bottom-left point of the rectangle is `(xi, yi)` and the top-right point of it is `(ai, bi)`. Return `true` _if all the rectangles together form an exact cover of a rectangular region_. **Example 1:** **Inp...
null
Array,Line Sweep
Hard
null
476
hi so let's talk about the number component so the complement of the integer is the integer you get when you flip all of 0 to 1 or all of one two zero right so this question is pretty straightforward so I'm going to just uh quickly summarize this so if you get a number of five right integer five right the component for...
Number Complement
number-complement
The **complement** of an integer is the integer you get when you flip all the `0`'s to `1`'s and all the `1`'s to `0`'s in its binary representation. * For example, The integer `5` is `"101 "` in binary and its **complement** is `"010 "` which is the integer `2`. Given an integer `num`, return _its complement_. **...
null
Bit Manipulation
Easy
null
236
Hello guys welcome back to tech division in this video you will see the longest co ancestor of every problem which is remedy co number 230 6 and will see the solution for this entry problem so let's tree problem statement in this problem give a brief notes industry The Definition of the Best All the Difference Between ...
Lowest Common Ancestor of a Binary Tree
lowest-common-ancestor-of-a-binary-tree
Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to the [definition of LCA on Wikipedia](https://en.wikipedia.org/wiki/Lowest_common_ancestor): "The lowest common ancestor is defined between two nodes `p` and `q` as the lowest node in `T` that has both `p` and `q` as...
null
Tree,Depth-First Search,Binary Tree
Medium
235,1190,1354,1780,1790,1816,2217
526
welcome to january's leeco challenge today's problem is beautiful arrangement and buckle up this is going to be a long one but we'll get through it together suppose you have n integers labeled 1 through n a permutation of those n integers perm is considered a beautiful arrangement if for every i inside of our permutati...
Beautiful Arrangement
beautiful-arrangement
Suppose you have `n` integers labeled `1` through `n`. A permutation of those `n` integers `perm` (**1-indexed**) is considered a **beautiful arrangement** if for every `i` (`1 <= i <= n`), **either** of the following is true: * `perm[i]` is divisible by `i`. * `i` is divisible by `perm[i]`. Given an integer `n`,...
null
Array,Dynamic Programming,Backtracking,Bit Manipulation,Bitmask
Medium
667
1,822
hello so let's talk about the sign of the part of array so you are giving the function so uh you want to just return the value if the part of the sum um actually negative or positive or is actually equal to zero so this question is pretty straightforward so oh what you actually need to do is by like when this is negati...
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
1,863
hello welcome back to the last of lead code problem 1862 sum up on subsets saw totals okay um the store total of an array is defined as the bitwise saw of all its elements or zero if the array is empty okay and is to return the sum up on so totals for every success of the given array okay and a subset with the same ele...
Sum of All Subset XOR Totals
sum-of-all-subset-xor-totals
The **XOR total** of an array is defined as the bitwise `XOR` of **all its elements**, or `0` if the array is **empty**. * For example, the **XOR total** of the array `[2,5,6]` is `2 XOR 5 XOR 6 = 1`. Given an array `nums`, return _the **sum** of all **XOR totals** for every **subset** of_ `nums`. **Note:** Subset...
null
null
Easy
null
203
hey everyone welcome back and let's solve another elite code problem today let's look at lead code 203 remove linked list elements and don't forget to hit the like button it supports the channel a lot so let's say we have a linked list 1 2 six three four five six and we want to remove all occurrences of the value six f...
Remove Linked List Elements
remove-linked-list-elements
Given the `head` of a linked list and an integer `val`, remove all the nodes of the linked list that has `Node.val == val`, and return _the new head_. **Example 1:** **Input:** head = \[1,2,6,3,4,5,6\], val = 6 **Output:** \[1,2,3,4,5\] **Example 2:** **Input:** head = \[\], val = 1 **Output:** \[\] **Example 3:**...
null
Linked List,Recursion
Easy
27,237,2216
96
hello welcome recently partly we are going to solve this little problem named GUI by nice asking so given on given numbers so number three so that how can I mean how my number three who can make closed chamber one this way so check this example so you know that 25 Knightley writes one is the other chef whose child loan...
Unique Binary Search Trees
unique-binary-search-trees
Given an integer `n`, return _the number of structurally unique **BST'**s (binary search trees) which has exactly_ `n` _nodes of unique values from_ `1` _to_ `n`. **Example 1:** **Input:** n = 3 **Output:** 5 **Example 2:** **Input:** n = 1 **Output:** 1 **Constraints:** * `1 <= n <= 19`
null
Math,Dynamic Programming,Tree,Binary Search Tree,Binary Tree
Medium
95
257
hey welcome guys so let's solve this 257 binary tree pass this problem is uh really uh this code is really important to make to solve other problems like a 900 a in the other problem so basically uh this problem basically will uh give you the code now you can start from roots and go to all the paths also all or at leas...
Binary Tree Paths
binary-tree-paths
Given the `root` of a binary tree, return _all root-to-leaf paths in **any order**_. A **leaf** is a node with no children. **Example 1:** **Input:** root = \[1,2,3,null,5\] **Output:** \[ "1->2->5 ", "1->3 "\] **Example 2:** **Input:** root = \[1\] **Output:** \[ "1 "\] **Constraints:** * The number of nodes ...
null
String,Backtracking,Tree,Depth-First Search,Binary Tree
Easy
113,1030,2217
93
so good evening so I'm back with another video uh this time I'm going to be making a video called restore IP addresses in wheat code so on the offset this question looks somewhat difficult but I can show you how to do it in somewhat of an easy manner all right so this is mainly a backtracking question if you think abou...
Restore IP Addresses
restore-ip-addresses
A **valid IP address** consists of exactly four integers separated by single dots. Each integer is between `0` and `255` (**inclusive**) and cannot have leading zeros. * For example, `"0.1.2.201 "` and `"192.168.1.1 "` are **valid** IP addresses, but `"0.011.255.245 "`, `"192.168.1.312 "` and `"192.168@1.1 "` are **...
null
String,Backtracking
Medium
752
271
hey everyone welcome back and let's write some more neat code today so today let's solve the problem in code and decode strings so you can tell the interface is a little bit different this time and that's because we are going to be solving this problem on lint code because this is a premium leak code problem and we can...
Encode and Decode Strings
encode-and-decode-strings
Design an algorithm to encode **a list of strings** to **a string**. The encoded string is then sent over the network and is decoded back to the original list of strings. Machine 1 (sender) has the function: string encode(vector strs) { // ... your code return encoded\_string; } Machine 2 (receiver) has the func...
null
Array,String,Design
Medium
38,297,443,696
1,696
Hey everyone today I want to explain the solution&nbsp; to problem 1696 on LeetCode called Jump Game 6.&nbsp; In this problem, we're given a number line&nbsp; with n steps. We are also given a number,&nbsp;&nbsp; say k, which represents the most steps&nbsp; we can take forwards in each turn.&nbsp; On the number line ar...
Jump Game VI
strange-printer-ii
You are given a **0-indexed** integer array `nums` and an integer `k`. You are initially standing at index `0`. In one move, you can jump at most `k` steps forward without going outside the boundaries of the array. That is, you can jump from index `i` to any index in the range `[i + 1, min(n - 1, i + k)]` **inclusive*...
Try thinking in reverse. Given the grid, how can you tell if a colour was painted last?
Array,Graph,Topological Sort,Matrix
Hard
664
1,046
Hi guys welcome back to my channel cpp code and today we will do question 1046 of lead code, it is a good question, I have solved it before, see what is given in this question, the name of this question is last stone wait or r. Given an array of integer number of stones, what is the weight of each stone? We are given a...
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
684
hey everybody this is larry this is the 25th of june uh for the june daily leco challenge hit the like button hit the subscribe button join me on discord and smash whatever uh today's problem is redundant connection so i usually start these live so if it's a little bit slow fast forward whatever you need to do okay wha...
Redundant Connection
redundant-connection
In this problem, a tree is an **undirected graph** that is connected and has no cycles. You are given a graph that started as a tree with `n` nodes labeled from `1` to `n`, with one additional edge added. The added edge has two **different** vertices chosen from `1` to `n`, and was not an edge that already existed. Th...
null
Depth-First Search,Breadth-First Search,Union Find,Graph
Medium
685,721,2246
139
Hello everyone welcome, we are going to do video number 53 of my channel and you will know that you can watch DP Concepts playlist if you want to study DP from scratch but I have mentioned one thing that it is not necessary that you will watch that playlist. Only then you can understand today's question, there is nothi...
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
461
hello everyone welcome to quartus camp we are at 18th day of november lit code challenge and the problem we are going to cover in this video is hamming distance so the input given here is a two integer value x and y and we have to represent those two integers in form of binary and we have to return the number of positi...
Hamming Distance
hamming-distance
The [Hamming distance](https://en.wikipedia.org/wiki/Hamming_distance) between two integers is the number of positions at which the corresponding bits are different. Given two integers `x` and `y`, return _the **Hamming distance** between them_. **Example 1:** **Input:** x = 1, y = 4 **Output:** 2 **Explanation:** 1...
null
Bit Manipulation
Easy
191,477
1,460
hey what's up guys uh this is chung here so today uh it's called 1764 form array by concatenating sub arrays of another array so you're given like a 2d integer array groups of length n and you're also given like an integer array of nums here so you need to choose like un disjoint sub arrays from the array nums such tha...
Make Two Arrays Equal by Reversing Subarrays
number-of-substrings-containing-all-three-characters
You are given two integer arrays of equal length `target` and `arr`. In one step, you can select any **non-empty subarray** of `arr` and reverse it. You are allowed to make any number of steps. Return `true` _if you can make_ `arr` _equal to_ `target` _or_ `false` _otherwise_. **Example 1:** **Input:** target = \[1,...
For each position we simply need to find the first occurrence of a/b/c on or after this position. So we can pre-compute three link-list of indices of each a, b, and c.
Hash Table,String,Sliding Window
Medium
2187
1,648
hey there everyone welcome back to lead coding in this video we will be solving the question number three of lead code weekly contest 124 name of the problem is selling diminishing valued colored balls the problem statement is you have an inventory of different colored balls and there's a customer that wants orders bal...
Sell Diminishing-Valued Colored Balls
minimum-insertions-to-balance-a-parentheses-string
You have an `inventory` of different colored balls, and there is a customer that wants `orders` balls of **any** color. The customer weirdly values the colored balls. Each colored ball's value is the number of balls **of that color** you currently have in your `inventory`. For example, if you own `6` yellow balls, the...
Use a stack to keep opening brackets. If you face single closing ')' add 1 to the answer and consider it as '))'. If you have '))' with empty stack, add 1 to the answer, If after finishing you have x opening remaining in the stack, add 2x to the answer.
String,Stack,Greedy
Medium
2095
729
alright guys welcome to our channel code with sunny and in this video i will be talking about the lead code problem again and again for the daily habit and index is seven to nine and the problem is of medium type problem of the late code okay so i thought something interesting that before moving to discuss this problem...
My Calendar I
my-calendar-i
You are implementing a program to use as your calendar. We can add a new event if adding the event will not cause a **double booking**. A **double booking** happens when two events have some non-empty intersection (i.e., some moment is common to both events.). The event can be represented as a pair of integers `start...
Store the events as a sorted list of intervals. If none of the events conflict, then the new event can be added.
Design,Segment Tree,Ordered Set
Medium
731,732
92
hey everybody this is Larry I hit the like button hit the subscribe button let me know how you're doing this farm I'm gonna stop alive right about now Oh 92 we must link this to we were said link this from position m2n do it in one pass one is less than or you could M which is less than you go to N or which is less the...
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,498
hello everyone welcome back to Lee coding on this channel we try to solve the problems which are frequently asked in programming interviews we try to build the solutions in a stepwise manner and then talk about the space and the time complexity which is asked in the interviews now the problem which we are going to look...
Number of Subsequences That Satisfy the Given Sum Condition
find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree
You are given an array of integers `nums` and an integer `target`. Return _the number of **non-empty** subsequences of_ `nums` _such that the sum of the minimum and maximum element on it is less or equal to_ `target`. Since the answer may be too large, return it **modulo** `109 + 7`. **Example 1:** **Input:** nums =...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Medium
null
1,833
Hello friends, today's question is of medium level question of maximum ice cream bar delete code. In this question we will be given an arrangement named cost, its length will be end and cost and the arrow will represent me, price it for the day. Which will represent the price and we will initially have some coins given...
Maximum Ice Cream Bars
find-the-highest-altitude
It is a sweltering summer day, and a boy wants to buy some ice cream bars. At the store, there are `n` ice cream bars. You are given an array `costs` of length `n`, where `costs[i]` is the price of the `ith` ice cream bar in coins. The boy initially has `coins` coins to spend, and he wants to buy as many ice cream bar...
Let's note that the altitude of an element is the sum of gains of all the elements behind it Getting the altitudes can be done by getting the prefix sum array of the given array
Array,Prefix Sum
Easy
null
1,029
English Video I Will Discuss Another Liquid Question Key You Which Was Two Cities In This Question A Company Planning You Interview You And People Life D Aage Of They Are Cost Of Or Cost Of IB Cost Of I D Cost Of Flying And D Cost of flying is D and percentage B is cost of five. See what it means, we have a company whi...
Two City Scheduling
vertical-order-traversal-of-a-binary-tree
A company is planning to interview `2n` people. Given the array `costs` where `costs[i] = [aCosti, bCosti]`, the cost of flying the `ith` person to city `a` is `aCosti`, and the cost of flying the `ith` person to city `b` is `bCosti`. Return _the minimum cost to fly every person to a city_ such that exactly `n` people...
null
Hash Table,Tree,Depth-First Search,Breadth-First Search,Binary Tree
Hard
null
735
hey what's up guys think white here I detect encoding stuff on twitch and YouTube check the description for all my information you can support me on my patreon that I really appreciate that I do like a bunch of stuff on there and then you know message me on discord if you're trying to reach out it's a good spot but we'...
Asteroid Collision
asteroid-collision
We are given an array `asteroids` of integers representing asteroids in a row. For each asteroid, the absolute value represents its size, and the sign represents its direction (positive meaning right, negative meaning left). Each asteroid moves at the same speed. Find out the state of the asteroids after all collisio...
Say a row of asteroids is stable. What happens when a new asteroid is added on the right?
Array,Stack
Medium
605,2245,2317
1,962
hello everyone welcome to my channel so today we are going to delete good daily challenge remove stones to minimize the total so let us postage this question then about the constraint and then finally about the coding part about the same and then at the end time complexity in the space complexity possible now here uh l...
Remove Stones to Minimize the Total
single-threaded-cpu
You are given a **0-indexed** integer array `piles`, where `piles[i]` represents the number of stones in the `ith` pile, and an integer `k`. You should apply the following operation **exactly** `k` times: * Choose any `piles[i]` and **remove** `floor(piles[i] / 2)` stones from it. **Notice** that you can apply the ...
To simulate the problem we first need to note that if at any point in time there are no enqueued tasks we need to wait to the smallest enqueue time of a non-processed element We need a data structure like a min-heap to support choosing the task with the smallest processing time from all the enqueued tasks
Array,Sorting,Heap (Priority Queue)
Medium
2176
64
so first let's take a look at minimum path sum so we're given a m times n grid filled with non negative values so positive all positive values including zero find a path from top left to bottom right which minimize the sum of all numbers along its path so you can only move either down or right at any point in time so w...
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,001
1001 grid illumination on an n-by-n 1001 grid illumination on an n-by-n 1001 grid illumination on an n-by-n quit of cells each cell XY z-- with x quit of cells each cell XY z-- with x quit of cells each cell XY z-- with x between 0 and n + y between 0 and n as a between 0 and n + y between 0 and n as a between 0 and n ...
Grid Illumination
n-repeated-element-in-size-2n-array
There is a 2D `grid` of size `n x n` where each cell of this grid has a lamp that is initially **turned off**. You are given a 2D array of lamp positions `lamps`, where `lamps[i] = [rowi, coli]` indicates that the lamp at `grid[rowi][coli]` is **turned on**. Even if the same lamp is listed more than once, it is turned...
null
Array,Hash Table
Easy
null
242
hello everyone and today let's go through one classic liquid problem and also a kind of introductory problem to help people get into computer science and data structure and algorithms um so it's legal problem 242 valid anagram let's take a read at the problem first given two strings s and t written true if T is an anag...
Valid Anagram
valid-anagram
Given two strings `s` and `t`, return `true` _if_ `t` _is an anagram of_ `s`_, and_ `false` _otherwise_. 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:** s = "anagram", t = "nagaram" **...
null
Hash Table,String,Sorting
Easy
49,266,438
1,466
hi guys good morning in this video we're gonna see a problem reorder routes to make all paths leading to the city zero problem is exactly what it says that we are given n cities numbered from 0 to n minus one pretty cool and minus 1 Rhodes such that there is only one way to travel between two different cities and this ...
Reorder Routes to Make All Paths Lead to the City Zero
jump-game-v
There are `n` cities numbered from `0` to `n - 1` and `n - 1` roads such that there is only one way to travel between two different cities (this network form a tree). Last year, The ministry of transport decided to orient the roads in one direction because they are too narrow. Roads are represented by `connections` wh...
Use dynamic programming. dp[i] is max jumps you can do starting from index i. Answer is max(dp[i]). dp[i] = 1 + max (dp[j]) where j is all indices you can reach from i.
Array,Dynamic Programming,Sorting
Hard
2001
849
welcome to october's leeco challenge today's problem is maximize distance to closest person in the asia kovid it's a pretty pertinent question you're given an array representing row seats where seats i equaling one represents a person sitting in the ice seat seats i equaling zero represents that seat is empty now there...
Maximize Distance to Closest Person
maximize-distance-to-closest-person
You are given an array representing a row of `seats` where `seats[i] = 1` represents a person sitting in the `ith` seat, and `seats[i] = 0` represents that the `ith` seat is empty **(0-indexed)**. There is at least one empty seat, and at least one person sitting. Alex wants to sit in the seat such that the distance b...
null
null
Medium
null
1,418
Hello hello friend this question from decor previous contest don't like problem number 1418 district table pappu doctor's national interest directly click on subscribe button order that customer number and kashmir and restaurant in order to were sardar this fit and food water telephone numbers Gautam And List On The Ta...
Display Table of Food Orders in a Restaurant
display-table-of-food-orders-in-a-restaurant
Given the array `orders`, which represents the orders that customers have done in a restaurant. More specifically `orders[i]=[customerNamei,tableNumberi,foodItemi]` where `customerNamei` is the name of the customer, `tableNumberi` is the table customer sit at, and `foodItemi` is the item customer orders. _Return the r...
null
null
Medium
null
139
hello welcome to ricobed today let's explore this circle program 139 so we are giving a lovely streamers and the dictionary vertically containing restaurant and reverse the multi-determining path can be the multi-determining path can be the multi-determining path can be divided into space separator sequences one or mor...
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
1,591
hey what is up guys today we're going to be doing problem number 1591 strange printer number two so there's a strange printer with the following two special requirements on each turn the printer will print a solid rectangular pattern of a single color on the grill this will color up this will cover up the existing colo...
Strange Printer II
strange-printer-ii
There is a strange printer with the following two special requirements: * On each turn, the printer will print a solid rectangular pattern of a single color on the grid. This will cover up the existing colors in the rectangle. * Once the printer has used a color for the above operation, **the same color cannot be ...
null
null
Hard
null
24
hello guys I hope you are all doing well in this video I will show you how to solve the problem lead chord 24 swap node and purse so let's get started so the problem is that they give us a linked list and as we know a linked list is a data structure that have nodes and each node have a value and reference to the next n...
Swap Nodes in Pairs
swap-nodes-in-pairs
Given a linked list, swap every two adjacent nodes and return its head. You must solve the problem without modifying the values in the list's nodes (i.e., only nodes themselves may be changed.) **Example 1:** **Input:** head = \[1,2,3,4\] **Output:** \[2,1,4,3\] **Example 2:** **Input:** head = \[\] **Output:** \[\...
null
Linked List,Recursion
Medium
25,528
212
hey everyone welcome back and let's write some more neat code today so today let's solve word search two and once again like usual this is a problem from the blind 75 link code list a list that we've been tracking on this spreadsheet and the link will be in the description to this and we are very close actually to bein...
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,200
hello guys my name is Ursula and welcome back to my channel and today we will be learning about how do we solve a new lead code question that is minimum absolute difference with the help of JavaScript so let's start this tutorial and just before starting with this question guys do subscribe to the channel hit the like ...
Minimum Absolute Difference
remove-interval
Given an array of **distinct** integers `arr`, find all pairs of elements with the minimum absolute difference of any two elements. Return a list of pairs in ascending order(with respect to pairs), each pair `[a, b]` follows * `a, b` are from `arr` * `a < b` * `b - a` equals to the minimum absolute difference o...
Solve the problem for every interval alone. Divide the problem into cases according to the position of the two intervals.
Array
Medium
null
287
in this problem we have to find a duplicate number from a list of given numbers so we are given a list of numbers and there are a few conditions that all the numbers will lie from 1 to n both inclusive and there are exactly n plus one numbers so this you can find from the size of the vector that is given to you or size...
Find the Duplicate Number
find-the-duplicate-number
Given an array of integers `nums` containing `n + 1` integers where each integer is in the range `[1, n]` inclusive. There is only **one repeated number** in `nums`, return _this repeated number_. You must solve the problem **without** modifying the array `nums` and uses only constant extra space. **Example 1:** **...
null
Array,Two Pointers,Binary Search,Bit Manipulation
Medium
41,136,142,268,645
1,168
hey what's up guys this is sean here so this time uh lead called number 1168 optimize water distribution in the village okay so this one this time we have earned houses in the village and we want to supply water for all the houses by building wells and laying pipes okay so basically we have own houses and we want to su...
Optimize Water Distribution in a Village
duplicate-zeros
There are `n` houses in a village. We want to supply water for all the houses by building wells and laying pipes. For each house `i`, we can either build a well inside it directly with cost `wells[i - 1]` (note the `-1` due to **0-indexing**), or pipe in water from another well to it. The costs to lay pipes between ho...
This is a great introductory problem for understanding and working with the concept of in-place operations. The problem statement clearly states that we are to modify the array in-place. That does not mean we cannot use another array. We just don't have to return anything. A better way to solve this would be without us...
Array,Two Pointers
Easy
null
1,090
the intended function of a program or part of a program can be specified by making general assertions about the values which the relevant variables will take after execution of the program welcome everybody it's amel and today we're going to solve largest values from labels we have a set of items the item has value val...
Largest Values From Labels
armstrong-number
There is a set of `n` items. You are given two integer arrays `values` and `labels` where the value and the label of the `ith` element are `values[i]` and `labels[i]` respectively. You are also given two integers `numWanted` and `useLimit`. Choose a subset `s` of the `n` elements such that: * The size of the subset...
Check if the given k-digit number equals the sum of the k-th power of it's digits. How to compute the sum of the k-th power of the digits of a number ? Can you divide the number into digits using division and modulus operations ? You can find the least significant digit of a number by taking it modulus 10. And you can ...
Math
Easy
null
83
And here we are attending question number 83 which is remove duplicates from sorted list. Here we have given a list. Here we have a linked list proper and from the listless we have to remove duplicate elements from it. You have here. Sorted and you have to remove duplicate elements like we have linked list here one you...
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
1,704
hello everyone welcome to this new video we are going to go through determine if string Hales are alike what does that mean that means you receive as input a string like this and you're supposed to split it into half and find out if you have the same number of VAR in the left and in the right if it is the case they ali...
Determine if String Halves Are Alike
special-positions-in-a-binary-matrix
You are given a string `s` of even length. Split this string into two halves of equal lengths, and let `a` be the first half and `b` be the second half. Two strings are **alike** if they have the same number of vowels (`'a'`, `'e'`, `'i'`, `'o'`, `'u'`, `'A'`, `'E'`, `'I'`, `'O'`, `'U'`). Notice that `s` contains uppe...
Keep track of 1s in each row and in each column. Then while iterating over matrix, if the current position is 1 and current row as well as current column contains exactly one occurrence of 1.
Array,Matrix
Easy
null
1,287
Hello everyone welcome to my channel code sari with mike so today we are going to do video number 74 of our playlist, ok it is marked easy but we will make it with three approaches and we will get to learn a lot, very good approachable appearing more than that 25 But in a sorted, okay, so let's see what the question is...
Element Appearing More Than 25% In Sorted Array
distance-between-bus-stops
Given an integer array **sorted** in non-decreasing order, there is exactly one integer in the array that occurs more than 25% of the time, return that integer. **Example 1:** **Input:** arr = \[1,2,2,6,6,6,6,7,10\] **Output:** 6 **Example 2:** **Input:** arr = \[1,1\] **Output:** 1 **Constraints:** * `1 <= arr...
Find the distance between the two stops if the bus moved in clockwise or counterclockwise directions.
Array
Easy
null
48
welcome back to our channel in this video let us see the solution for rotate image given an n by n 2d matrix representing an image rotate the image by 90 degrees in clockwise direction directly that is without using another 2d matrix for example consider the input of 3x3 2d matrix here the first row becomes the last co...
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
142
all right guys so welcome to another problem in this series for Linked list um this is problem 142 link list cycle two okay um so I'm assuming and I hope that you guys have done linked with cycle one and you guys have some basic intuition basic knowledge on link problems that contain linked lists okay and how to solve ...
Linked List Cycle II
linked-list-cycle-ii
Given the `head` of a linked list, return _the node where the cycle begins. If there is no cycle, return_ `null`. 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 ta...
null
Hash Table,Linked List,Two Pointers
Medium
141,287
138
hey everyone today we are going to show the little question copy list with random pointer so this is a quite wrong description so in summary so you are given like a link to this of links n and like this and each node has two pointers so one is a next pointer so pointing to next node so that's simple right and uh each n...
Copy List with Random Pointer
copy-list-with-random-pointer
A linked list of length `n` is given such that each node contains an additional random pointer, which could point to any node in the list, or `null`. Construct a [**deep copy**](https://en.wikipedia.org/wiki/Object_copying#Deep_copy) of the list. The deep copy should consist of exactly `n` **brand new** nodes, where e...
Just iterate the linked list and create copies of the nodes on the go. Since a node can be referenced from multiple nodes due to the random pointers, make sure you are not making multiple copies of the same node. You may want to use extra space to keep old node ---> new node mapping to prevent creating multiples copies...
Hash Table,Linked List
Medium
133,1624,1634
53
let's all leak code 53 maximum sub-array let's all leak code 53 maximum sub-array let's all leak code 53 maximum sub-array so we're given an integer array of gnomes and we want to find the contiguous sub array containing at least one number which has the largest sum and then we want to return only the sum so this array...
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
309
so welcome back to this another daily code problem so today it's called best time to buy and sell stock with cooldown and so it's a dynamic programming problem where essentially you're given this array called prices and these represent a certain stock price at a particular day and so on day Zero it would have a price o...
Best Time to Buy and Sell Stock with Cooldown
best-time-to-buy-and-sell-stock-with-cooldown
You are given an array `prices` where `prices[i]` is the price of a given stock on the `ith` day. Find the maximum profit you can achieve. You may complete as many transactions as you like (i.e., buy one and sell one share of the stock multiple times) with the following restrictions: * After you sell your stock, yo...
null
Array,Dynamic Programming
Medium
121,122
42
hello boys and girls and welcome to another episode of your favorite algorithm channel my name is Ryan powers and today I'm gonna be taking you through leet code 42 trapping rainwater so let's introduce the problem given n non-negative integers representing an non-negative integers representing an non-negative integers...
Trapping Rain Water
trapping-rain-water
Given `n` non-negative integers representing an elevation map where the width of each bar is `1`, compute how much water it can trap after raining. **Example 1:** **Input:** height = \[0,1,0,2,1,0,1,3,2,1,2,1\] **Output:** 6 **Explanation:** The above elevation map (black section) is represented by array \[0,1,0,2,1,...
null
Array,Two Pointers,Dynamic Programming,Stack,Monotonic Stack
Hard
11,238,407,756
1,325
hey everyone uh today i'll be going over a problem uh 1325 on leak code delete leaves with a given value so we're given a binary tree and we need to delete all the leaf nodes that have a value the trick is when you delete a leaf node uh if another node becomes a new leaf and also has the target that needs to be deleted...
Delete Leaves With a Given Value
path-with-maximum-probability
Given a binary tree `root` and an integer `target`, delete all the **leaf nodes** with value `target`. Note that once you delete a leaf node with value `target`**,** if its parent node becomes a leaf node and has the value `target`, it should also be deleted (you need to continue doing that until you cannot). **Examp...
Multiplying probabilities will result in precision errors. Take log probabilities to sum up numbers instead of multiplying them. Use Dijkstra's algorithm to find the minimum path between the two nodes after negating all costs.
Graph,Heap (Priority Queue),Shortest Path
Medium
2090
485
question number 485 max consecutive ones we're still on the easy problems here given the binary numbers return the maximum number of consecutive ones in the array okay so let's look at the an example here so what does it mean so if you look at one zero one you'll figure out the maximum ones is actually three here becau...
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
622
hi today i'll be talking about my circular queue from lead code and i'm going to approach this solution a bit differently now how do i know how many variables i have to declare well i'll start by looking through these methods in the class and start to see which are the ones are the easiest to solve so if we want to che...
Design Circular Queue
design-circular-queue
Design your implementation of the circular queue. The circular queue is a linear data structure in which the operations are performed based on FIFO (First In First Out) principle, and the last position is connected back to the first position to make a circle. It is also called "Ring Buffer ". One of the benefits of th...
null
null
Medium
null
968
That a hello everyone welcome to cases questions ministry cameras in this question in the treaty between stock subscribe camera on it subscribe mirva subscribe to that first limit tay apna hai shark slide show a binary k amrit liquid 96 subscription avenir with oo bluetooth settings of first World Immigration Question ...
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
1,349
hello everyone today I went to solve a lead code problem it's called maximum students ticking X hunt and stuck is hard it's a hard problem that's going to be the first bullet I went to solve the code I have already submitted my solutions and hours ago now I'm going to record a thought process out cold well this problem...
Maximum Students Taking Exam
check-if-it-is-a-straight-line
Given a `m * n` matrix `seats` that represent seats distributions in a classroom. If a seat is broken, it is denoted by `'#'` character otherwise it is denoted by a `'.'` character. Students can see the answers of those sitting next to the left, right, upper left and upper right, but he cannot see the answers of the s...
If there're only 2 points, return true. Check if all other points lie on the line defined by the first 2 points. Use cross product to check collinearity.
Array,Math,Geometry
Easy
null
222
in this video we are going to see the layer code problem number 222 count complete three nodes let's get into the problem so the problem statement is you are given a root of a complete binary return the number of nodes in the tree according to Wikipedia every level except possibly the last is completely filled in a com...
Count Complete Tree Nodes
count-complete-tree-nodes
Given the `root` of a **complete** binary tree, return the number of the nodes in the tree. According to **[Wikipedia](http://en.wikipedia.org/wiki/Binary_tree#Types_of_binary_trees)**, every level, except possibly the last, is completely filled in a complete binary tree, and all nodes in the last level are as far lef...
null
Binary Search,Tree,Depth-First Search,Binary Tree
Medium
270
20
hello guys welcome to algorithms made easy today we will be discussing the question valid paranthesis in this question we are given a string containing just the characters that is open in close brackets of three types and we need to determine if the string input is valid or not a string input is valid only if the open ...
Valid Parentheses
valid-parentheses
Given a string `s` containing just the characters `'('`, `')'`, `'{'`, `'}'`, `'['` and `']'`, determine if the input string is valid. An input string is valid if: 1. Open brackets must be closed by the same type of brackets. 2. Open brackets must be closed in the correct order. 3. Every close bracket has a corres...
An interesting property about a valid parenthesis expression is that a sub-expression of a valid expression should also be a valid expression. (Not every sub-expression) e.g. { { } [ ] [ [ [ ] ] ] } is VALID expression [ [ [ ] ] ] is VALID sub-expression { } [ ] is VALID sub-express...
String,Stack
Easy
22,32,301,1045,2221
189
all right so this problem is called rotate array and so basically what they're doing here is they're going to give you a k value and then uh your job is to essentially rotate a portion of this ray that many indices to the right so uh when they say three you shift everything to the right so seven falls off the end six f...
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
1,183
hey everybody this is Larry this is me going over the weekly premium problem uh I already saw that earlier you know I gotta do this and reverse order because I do get a lot of comments and I tried to be you know uh accommodating but in that the video is very long uh it took me about an hour this outfit is a very hard p...
Maximum Number of Ones
statistics-from-a-large-sample
Consider a matrix `M` with dimensions `width * height`, such that every cell has value `0` or `1`, and any **square** sub-matrix of `M` of size `sideLength * sideLength` has at most `maxOnes` ones. Return the maximum possible number of ones that the matrix `M` can have. **Example 1:** **Input:** width = 3, height = ...
The hard part is the median. Write a helper function which finds the k-th element from the sample.
Math,Two Pointers,Probability and Statistics
Medium
null
509
That a special welcome back to new video english video soaking explorer problem english course wishes in number and if you are not aware of ignore sequence it's something 40 number in bed with a sum of two pieces take vansh vacancy this line gear solid explain sequence understanding 40 Number one official numbers which...
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
1,764
hey everybody this is larry this is me going with q2 of the bi-weekly contest 46 formed away of the bi-weekly contest 46 formed away of the bi-weekly contest 46 formed away by concatenating sub-array of another by concatenating sub-array of another by concatenating sub-array of another array so this one conceptually mi...
Form Array by Concatenating Subarrays of Another Array
maximum-repeating-substring
You are given a 2D integer array `groups` of length `n`. You are also given an integer array `nums`. You are asked if you can choose `n` **disjoint** subarrays from the array `nums` such that the `ith` subarray is equal to `groups[i]` (**0-indexed**), and if `i > 0`, the `(i-1)th` subarray appears **before** the `ith`...
The constraints are low enough for a brute force approach. Try every k value from 0 upwards until word is no longer k-repeating.
String,String Matching
Easy
1689
1,679
hey everyone this is Alex welcome back to my video series on solving lead code problems it's 1 in the morning I've been surfing all day and doing lead code problems and I'm tired but this is the last one so this is problem 1,679 max number of K some pairs you're 1,679 max number of K some pairs you're 1,679 max number ...
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
331
hey everyone so welcome to another mock interview video I guess this one is on pre-order string something validation pre-order string something validation pre-order string something validation something it's a pretty good problem I encourage you to first do it and then watch this video I guess the thing is I'm warning ...
Verify Preorder Serialization of a Binary Tree
verify-preorder-serialization-of-a-binary-tree
One way to serialize a binary tree is to use **preorder traversal**. When we encounter a non-null node, we record the node's value. If it is a null node, we record using a sentinel value such as `'#'`. For example, the above binary tree can be serialized to the string `"9,3,4,#,#,1,#,#,2,#,6,#,# "`, where `'#'` repres...
null
String,Stack,Tree,Binary Tree
Medium
null
113
hello everyone so today's lead core challenge is path some too so we have given with a binary tree and our goal is to find the every path which sum will be our Tower kit sum so here as you can see in this example number one our Target sum is 22 so path that become a 22 is 5 4 11 and 2 as same as 5 8 4 and 5. so let's j...
Path Sum II
path-sum-ii
Given the `root` of a binary tree and an integer `targetSum`, return _all **root-to-leaf** paths where the sum of the node values in the path equals_ `targetSum`_. Each path should be returned as a list of the node **values**, not node references_. A **root-to-leaf** path is a path starting from the root and ending at...
null
Backtracking,Tree,Depth-First Search,Binary Tree
Medium
112,257,437,666,2217
389
hi everyone welcome to my channel let's solve the problem find the difference in this problem given us a two string s and t where t is formed from the s plus adding one extra character and we have to find that character so how we will solve this so one of the easiest implementation is just we will use the character fre...
Find the Difference
find-the-difference
You are given two strings `s` and `t`. String `t` is generated by random shuffling string `s` and then add one more letter at a random position. Return the letter that was added to `t`. **Example 1:** **Input:** s = "abcd ", t = "abcde " **Output:** "e " **Explanation:** 'e' is the letter that was added. **Exam...
null
Hash Table,String,Bit Manipulation,Sorting
Easy
136
51
okay so question 51 leak code n queens the end queen's puzzle is the problem of placing n queens on an n by n chessboard such that no two queens attack each other so we're given an integer n return all distinct solutions to the n queens puzzle you may return the answer in any order each solution contains a distinct boa...
N-Queens
n-queens
The **n-queens** puzzle is the problem of placing `n` queens on an `n x n` chessboard such that no two queens attack each other. Given an integer `n`, return _all distinct solutions to the **n-queens puzzle**_. You may return the answer in **any order**. Each solution contains a distinct board configuration of the n-...
null
Array,Backtracking
Hard
52,1043
284
okay so how's it going ladies and gentlemen so today we are going to solve another coolest problem uh lead code 284 picking iterator okay so the problem statement is saying like we have to implement a picking iterator class and that class has three main functions to do okay when the next one you can see over here and t...
Peeking Iterator
peeking-iterator
Design an iterator that supports the `peek` operation on an existing iterator in addition to the `hasNext` and the `next` operations. Implement the `PeekingIterator` class: * `PeekingIterator(Iterator nums)` Initializes the object with the given integer iterator `iterator`. * `int next()` Returns the next element...
Think of "looking ahead". You want to cache the next element. Is one variable sufficient? Why or why not? Test your design with call order of peek() before next() vs next() before peek(). For a clean implementation, check out Google's guava library source code.
Array,Design,Iterator
Medium
173,251,281
334
foreign name is increasing triplet subsequence so the question is given an integer array nums written true if there exist a triple of index i j k such that I is less than J and J is less than K and nums of I is less than nums of J and nums of J is less than nums of K if no such indexes exist return false so in simple w...
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,980
hey how's it going find unique binary string 1980 uh leak code given an array of nums containing n unique binary strings each of length n return a binary string of length n that does not appear in nums if there are multiple answers you may return any of them okay uh first off we're going to make a tree class and then i...
Find Unique Binary String
faulty-sensor
Given an array of strings `nums` containing `n` **unique** binary strings each of length `n`, return _a binary string of length_ `n` _that **does not appear** in_ `nums`_. If there are multiple answers, you may return **any** of them_. **Example 1:** **Input:** nums = \[ "01 ", "10 "\] **Output:** "11 " **Explanatio...
Check for a common prefix of the two arrays. After this common prefix, there should be one array similar to the other but shifted by one. If both arrays can be shifted, return -1.
Array,Two Pointers
Easy
null
1,675
hello everyone let's solve the problem minimize deviation in Array you are given an array Norms 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 divided by 2 if the element is odd multiply it by 2. the deviation of the error is the max...
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
779
Hello everyone Welcome to my channel here we solve problems Lead code today task number 779 kata symbol in a line we build a table of N lines numbered from one we start by writing zero the first line now we form the sequence of each line as follows we replace each zero of the previous line with sequence in a new line a...
K-th Symbol in Grammar
max-chunks-to-make-sorted-ii
We build a table of `n` rows (**1-indexed**). We start by writing `0` in the `1st` row. Now in every subsequent row, we look at the previous row and replace each occurrence of `0` with `01`, and each occurrence of `1` with `10`. * For example, for `n = 3`, the `1st` row is `0`, the `2nd` row is `01`, and the `3rd` r...
Each k for which some permutation of arr[:k] is equal to sorted(arr)[:k] is where we should cut each chunk.
Array,Stack,Greedy,Sorting,Monotonic Stack
Hard
780
304
so lead code practice in this video there are two goals the first goal is to see how to solve this problem and then we are going to do some coding work and the second goal is to see how should we have in a real interview so let's get started so in the real interview the first goal is always try to first understand the ...
Range Sum Query 2D - Immutable
range-sum-query-2d-immutable
Given a 2D matrix `matrix`, handle multiple queries of the following type: * Calculate the **sum** of the elements of `matrix` inside the rectangle defined by its **upper left corner** `(row1, col1)` and **lower right corner** `(row2, col2)`. Implement the `NumMatrix` class: * `NumMatrix(int[][] matrix)` Initial...
null
Array,Design,Matrix,Prefix Sum
Medium
303,308
368
hello waves welcome to algorithms maidenly today we will go through the day 13 problem largest divisible subset please like the video and if you are new don't forget to subscribe to our channel so you never miss any update given a set of distinct positive integer find the largest subset such that every pair si comma SJ...
Largest Divisible Subset
largest-divisible-subset
Given a set of **distinct** positive integers `nums`, return the largest subset `answer` such that every pair `(answer[i], answer[j])` of elements in this subset satisfies: * `answer[i] % answer[j] == 0`, or * `answer[j] % answer[i] == 0` If there are multiple solutions, return any of them. **Example 1:** **Inp...
null
Array,Math,Dynamic Programming,Sorting
Medium
null
60
hey hello there today's liquid in chinese questions called permutation sequence we have a set of n different numbers uh for number of conveniences i actually want to add uh we want to consider all the unique permutations we can do with this set of n numbers so it's a n factorial in total because for the first position ...
Permutation Sequence
permutation-sequence
The set `[1, 2, 3, ..., n]` contains a total of `n!` unique permutations. By listing and labeling all of the permutations in order, we get the following sequence for `n = 3`: 1. `"123 "` 2. `"132 "` 3. `"213 "` 4. `"231 "` 5. `"312 "` 6. `"321 "` Given `n` and `k`, return the `kth` permutation sequence. **Exa...
null
Math,Recursion
Hard
31,46
24
what is up guys the Tiffany line here today I am going over swap nodes in pairs I've been learning about linked lists today so it just reads giving a linked list swap every two adjacent nodes and return its head and we made not modify the value and list nodes only nodes itself may be changed so they want us to return t...
Swap Nodes in Pairs
swap-nodes-in-pairs
Given a linked list, swap every two adjacent nodes and return its head. You must solve the problem without modifying the values in the list's nodes (i.e., only nodes themselves may be changed.) **Example 1:** **Input:** head = \[1,2,3,4\] **Output:** \[2,1,4,3\] **Example 2:** **Input:** head = \[\] **Output:** \[\...
null
Linked List,Recursion
Medium
25,528
497
hey guys welcome back to another video and today we're going to be solving the lead code question random point and non-overlapping random point and non-overlapping random point and non-overlapping rectangle all right so in this question we're given a list of non-overlapping given a list of non-overlapping given a list ...
Random Point in Non-overlapping Rectangles
random-point-in-non-overlapping-rectangles
You are given an array of non-overlapping axis-aligned rectangles `rects` where `rects[i] = [ai, bi, xi, yi]` indicates that `(ai, bi)` is the bottom-left corner point of the `ith` rectangle and `(xi, yi)` is the top-right corner point of the `ith` rectangle. Design an algorithm to pick a random integer point inside th...
null
null
Medium
null
897
hey how you doing guys it's ilya bali here i'd recording stuff on youtube share description for all my information i do all legal problems uh make sure you subscribe to this channel give me big thumbs up to support it and this is called increasing order search three uh given binary search three rearrange the three in o...
Increasing Order Search Tree
prime-palindrome
Given the `root` of a binary search tree, rearrange the tree in **in-order** so that the leftmost node in the tree is now the root of the tree, and every node has no left child and only one right child. **Example 1:** **Input:** root = \[5,3,6,2,4,null,8,1,null,null,null,7,9\] **Output:** \[1,null,2,null,3,null,4,nul...
null
Math
Medium
2202
102
hey everyone today we're going to be looking at binary tree level order traversal now this is a breadth first search problem it says given the root of a binary tree return the level order traversal of its node's values i.e from left to right node's values i.e from left to right node's values i.e from left to right leve...
Binary Tree Level Order Traversal
binary-tree-level-order-traversal
Given the `root` of a binary tree, return _the level order traversal of its nodes' values_. (i.e., from left to right, level by level). **Example 1:** **Input:** root = \[3,9,20,null,null,15,7\] **Output:** \[\[3\],\[9,20\],\[15,7\]\] **Example 2:** **Input:** root = \[1\] **Output:** \[\[1\]\] **Example 3:** **I...
null
Tree,Breadth-First Search,Binary Tree
Medium
103,107,111,314,637,764,1035
345
welcome to little JavaScript channel will be solve every single liter question using JavaScript today we have a 345 reverse vowels of a string this is an easy question let's begin given a string s reverse only all the variables in the string and return it the vowels are a i e o u they can appear both in lower and upper...
Reverse Vowels of a String
reverse-vowels-of-a-string
Given a string `s`, reverse only all the vowels in the string and return it. The vowels are `'a'`, `'e'`, `'i'`, `'o'`, and `'u'`, and they can appear in both lower and upper cases, more than once. **Example 1:** **Input:** s = "hello" **Output:** "holle" **Example 2:** **Input:** s = "leetcode" **Output:** "leotc...
null
Two Pointers,String
Easy
344,1089
20
According to the business, inside we are going to spend a little money in auspicious works. This is a very famous question. Office meeting problem on everything. Okay, this is basically you also counter mix. Then we have asked that okay, so a very important question. This is what you guys have done by expanding the bas...
Valid Parentheses
valid-parentheses
Given a string `s` containing just the characters `'('`, `')'`, `'{'`, `'}'`, `'['` and `']'`, determine if the input string is valid. An input string is valid if: 1. Open brackets must be closed by the same type of brackets. 2. Open brackets must be closed in the correct order. 3. Every close bracket has a corres...
An interesting property about a valid parenthesis expression is that a sub-expression of a valid expression should also be a valid expression. (Not every sub-expression) e.g. { { } [ ] [ [ [ ] ] ] } is VALID expression [ [ [ ] ] ] is VALID sub-expression { } [ ] is VALID sub-express...
String,Stack
Easy
22,32,301,1045,2221
805
123 456 Topic Middle Sudhi-Budhi Shabd * 1st End Set It Is Obvious To * 1st End Set It Is Obvious To * 1st End Set It Is Obvious To Make Two Of Three And Condition Your To-Do Make Two Of Three And Condition Your To-Do Make Two Of Three And Condition Your To-Do List Menton Friends Subscribe Channel Radhe-Radhe At Channe...
Split Array With Same Average
escape-the-ghosts
You are given an integer array `nums`. You should move each element of `nums` into one of the two arrays `A` and `B` such that `A` and `B` are non-empty, and `average(A) == average(B)`. Return `true` if it is possible to achieve that and `false` otherwise. **Note** that for an array `arr`, `average(arr)` is the sum ...
null
Array,Math
Medium
1727
152
hello i'll be covering question 152 maximum product subarray let's get started so i have a given input and i want to keep track of maximum positive value and minimum negative value i see default value is one for beginning so how do i find uh maximum positive over here is negative times two or positive times two which o...
Maximum Product Subarray
maximum-product-subarray
Given an integer array `nums`, find a subarray that has the largest product, and return _the product_. The test cases are generated so that the answer will fit in a **32-bit** integer. **Example 1:** **Input:** nums = \[2,3,-2,4\] **Output:** 6 **Explanation:** \[2,3\] has the largest product 6. **Example 2:** **I...
null
Array,Dynamic Programming
Medium
53,198,238,628,713
404
hey it's cooper codes today we're gonna be taking a look at the lead code problem some of left leaves this was recently a feature daily problem on leak code so i thought i'd go over it and kind of explain my solution first things first we can take a look at their example to get an idea as to how we can solve this probl...
Sum of Left Leaves
sum-of-left-leaves
Given the `root` of a binary tree, return _the sum of all left leaves._ A **leaf** is a node with no children. A **left leaf** is a leaf that is the left child of another node. **Example 1:** **Input:** root = \[3,9,20,null,null,15,7\] **Output:** 24 **Explanation:** There are two left leaves in the binary tree, wit...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Easy
null
1,976
welcome guys so let's solving this 1976 number of ways to arrive at destinations okay so this problem is very easy uh you got some uh graph and uh and initialized at zero and there are total minus one vertices and the problem is that given all the uh if the number of all the shortest paths from zero to uh to zero to a ...
Number of Ways to Arrive at Destination
splitting-a-string-into-descending-consecutive-values
You are in a city that consists of `n` intersections numbered from `0` to `n - 1` with **bi-directional** roads between some intersections. The inputs are generated such that you can reach any intersection from any other intersection and that there is at most one road between any two intersections. You are given an in...
One solution is to try all possible splits using backtrack Look out for trailing zeros in string
String,Backtracking
Medium
null
1,171
hey guys welcome back to my channel let's solve today's problem 117 remove zero some consecutive notes from the link list okay so let me just read this uh not okay yeah let's solve this suppose uh what this question is saying I have um a few notes and just think of this numbers as a note okay now we have to remove all ...
Remove Zero Sum Consecutive Nodes from Linked List
shortest-path-in-binary-matrix
Given the `head` of a linked list, we repeatedly delete consecutive sequences of nodes that sum to `0` until there are no such sequences. After doing so, return the head of the final linked list. You may return any such answer. (Note that in the examples below, all sequences are serializations of `ListNode` objects.)...
Do a breadth first search to find the shortest path.
Array,Breadth-First Search,Matrix
Medium
null
222
they are there today's liquor in challenge question is called count complete three nodes so we have a complete binary tree we won't count the number of nodes inside this complete binary tree the definition for a complete binary tree is that every level except possibly for the very last a level inside this binary tree h...
Count Complete Tree Nodes
count-complete-tree-nodes
Given the `root` of a **complete** binary tree, return the number of the nodes in the tree. According to **[Wikipedia](http://en.wikipedia.org/wiki/Binary_tree#Types_of_binary_trees)**, every level, except possibly the last, is completely filled in a complete binary tree, and all nodes in the last level are as far lef...
null
Binary Search,Tree,Depth-First Search,Binary Tree
Medium
270
1,206
but cool let's take a look the sign escape lists without using any built-in escape lists without using any built-in escape lists without using any built-in libraries are limb sudden links hi cool 12:06 design skip list the sign is 12:06 design skip list the sign is 12:06 design skip list the sign is skipped list withou...
Design Skiplist
corporate-flight-bookings
Design a **Skiplist** without using any built-in libraries. A **skiplist** is a data structure that takes `O(log(n))` time to add, erase and search. Comparing with treap and red-black tree which has the same function and performance, the code length of Skiplist can be comparatively short and the idea behind Skiplists ...
null
Array,Prefix Sum
Medium
null
138
welcome to february's lego challenge today's problem is copy list with random pointer a linked list of length n is given such that each node contains an additional random pointer which could point to any node in the list or null construct a deep copy of the list the deep copy should consist of exact blah so basically w...
Copy List with Random Pointer
copy-list-with-random-pointer
A linked list of length `n` is given such that each node contains an additional random pointer, which could point to any node in the list, or `null`. Construct a [**deep copy**](https://en.wikipedia.org/wiki/Object_copying#Deep_copy) of the list. The deep copy should consist of exactly `n` **brand new** nodes, where e...
Just iterate the linked list and create copies of the nodes on the go. Since a node can be referenced from multiple nodes due to the random pointers, make sure you are not making multiple copies of the same node. You may want to use extra space to keep old node ---> new node mapping to prevent creating multiples copies...
Hash Table,Linked List
Medium
133,1624,1634
525
hello guys welcome to another video in the series of coding we are going to solve the problem it's called continuous array so given a binary r in nums you have to return the maximum length of a continuous sub array with equal number of zero and one let's try to take an example to understand now there are lot of sub arr...
Contiguous Array
contiguous-array
Given a binary array `nums`, return _the maximum length of a contiguous subarray with an equal number of_ `0` _and_ `1`. **Example 1:** **Input:** nums = \[0,1\] **Output:** 2 **Explanation:** \[0, 1\] is the longest contiguous subarray with an equal number of 0 and 1. **Example 2:** **Input:** nums = \[0,1,0\] **O...
null
Array,Hash Table,Prefix Sum
Medium
325