id
int64
1
2k
content
stringlengths
272
88.9k
title
stringlengths
3
77
title_slug
stringlengths
3
79
question_content
stringlengths
230
5k
question_hints
stringclasses
695 values
tag
stringclasses
618 values
level
stringclasses
3 values
similar_question_ids
stringclasses
822 values
485
See, in this video we are going to question the lead code for 885 Maximum Consecutive One. In this question, there will be a binary are given, it is ok that means zero and one will be there only and what do we have to do, maximum consecutive words are coming out as if here is Consecutive. There are two vans here and ho...
Max Consecutive Ones
max-consecutive-ones
Given a binary array `nums`, return _the maximum number of consecutive_ `1`_'s in the array_. **Example 1:** **Input:** nums = \[1,1,0,1,1,1\] **Output:** 3 **Explanation:** The first two digits or the last three digits are consecutive 1s. The maximum number of consecutive 1s is 3. **Example 2:** **Input:** nums = ...
You need to think about two things as far as any window is concerned. One is the starting point for the window. How do you detect that a new window of 1s has started? The next part is detecting the ending point for this window. How do you detect the ending point for an existing window? If you figure these two things...
Array
Easy
487,1046,1542,1999
1,658
hello everyone welcome to day 14th of january let go challenge and today's question is minimum operations to reduce x to zero in this question you are given an input array and an integer x uh you can perform multiple operations in the array and in each operation you can either pick an element from the right hand or the...
Minimum Operations to Reduce X to Zero
minimum-swaps-to-arrange-a-binary-grid
You are given an integer array `nums` and an integer `x`. In one operation, you can either remove the leftmost or the rightmost element from the array `nums` and subtract its value from `x`. Note that this **modifies** the array for future operations. Return _the **minimum number** of operations to reduce_ `x` _to **e...
For each row of the grid calculate the most right 1 in the grid in the array maxRight. To check if there exist answer, sort maxRight and check if maxRight[i] ≤ i for all possible i's. If there exist an answer, simulate the swaps.
Array,Greedy,Matrix
Medium
null
1,404
let's see code number okay i haven't done this number of steps to reduce a number in binary representation to one given a binary representation of an integer as a string s but turn the number of steps to reduce it to 1 under the following rows it's guaranteed that you can always reach one for test cases we just have to...
Number of Steps to Reduce a Number in Binary Representation to One
print-immutable-linked-list-in-reverse
Given the binary representation of an integer as a string `s`, return _the number of steps to reduce it to_ `1` _under the following rules_: * If the current number is even, you have to divide it by `2`. * If the current number is odd, you have to add `1` to it. It is guaranteed that you can always reac...
null
Linked List,Two Pointers,Stack,Recursion
Medium
null
99
That guys welcome back to my channel like this video we are going to two year recovery bent tree so this gives statement here you are giving any road office binary search tree bst valid values ​​of exactly two notes of values ​​of exactly two notes of values ​​of exactly two notes of fifteen years went by mistake recov...
Recover Binary Search Tree
recover-binary-search-tree
You are given the `root` of a binary search tree (BST), where the values of **exactly** two nodes of the tree were swapped by mistake. _Recover the tree without changing its structure_. **Example 1:** **Input:** root = \[1,3,null,null,2\] **Output:** \[3,1,null,null,2\] **Explanation:** 3 cannot be a left child of 1 ...
null
Tree,Depth-First Search,Binary Search Tree,Binary Tree
Medium
null
641
hello everyone today we are going to solve this problem called design circular deck ok so if you are familiar with so I'm going to use Python 3 to solve this problem and if you are quite familiar with Python 3 you might know there's a module called collections and in this module there is a class called building class c...
Design Circular Deque
design-circular-deque
Design your implementation of the circular double-ended queue (deque). Implement the `MyCircularDeque` class: * `MyCircularDeque(int k)` Initializes the deque with a maximum size of `k`. * `boolean insertFront()` Adds an item at the front of Deque. Returns `true` if the operation is successful, or `false` otherwi...
null
null
Medium
null
165
hey everyone it is site hope you are doing well so let's start with the question so the question is compare version number okay so you have given two version one and version two you have to compare them okay and version num consists of one or more version joining by a dot okay and you have to compare the version compar...
Compare Version Numbers
compare-version-numbers
Given two version numbers, `version1` and `version2`, compare them. Version numbers consist of **one or more revisions** joined by a dot `'.'`. Each revision consists of **digits** and may contain leading **zeros**. Every revision contains **at least one character**. Revisions are **0-indexed from left to right**, wit...
null
Two Pointers,String
Medium
null
1,489
hey everybody there's a slurry you're watching me solve this problem live during a contest I'm gonna stop the explanation and then it's going to go into some code review some times and then just me working on a palm let me know what you think about this format hit like button to subscribe one join me on a discord link ...
Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree
pizza-with-3n-slices
Given a weighted undirected connected graph with `n` vertices numbered from `0` to `n - 1`, and an array `edges` where `edges[i] = [ai, bi, weighti]` represents a bidirectional and weighted edge between nodes `ai` and `bi`. A minimum spanning tree (MST) is a subset of the graph's edges that connects all vertices withou...
By studying the pattern of the operations, we can find out that the problem is equivalent to: Given an integer array with size 3N, select N integers with maximum sum and any selected integers are not next to each other in the array. The first one in the array is considered next to the last one in the array. Use Dynamic...
Array,Dynamic Programming,Greedy,Heap (Priority Queue)
Hard
null
1,269
Hello friends welcome to Cod sura in this video we'll be solving lead code problem 1269 number of ways to stay in the same place after some steps though this problem is marked as a hard level problem I would say this is a medium level problem and if you have solved yesterday's problem or have some understanding of dyna...
Number of Ways to Stay in the Same Place After Some Steps
market-analysis-ii
You have a pointer at index `0` in an array of size `arrLen`. At each step, you can move 1 position to the left, 1 position to the right in the array, or stay in the same place (The pointer should not be placed outside the array at any time). Given two integers `steps` and `arrLen`, return the number of ways such that...
null
Database
Hard
null
146
yes today I'll be doing on 146 which is called Lau cache and this pop-up states called Lau cache and this pop-up states called Lau cache and this pop-up states that we want to design an event a structure for at least recently used cache it should support the following operations get input yet whoa get about you and it ...
LRU Cache
lru-cache
Design a data structure that follows the constraints of a **[Least Recently Used (LRU) cache](https://en.wikipedia.org/wiki/Cache_replacement_policies#LRU)**. Implement the `LRUCache` class: * `LRUCache(int capacity)` Initialize the LRU cache with **positive** size `capacity`. * `int get(int key)` Return the valu...
null
Hash Table,Linked List,Design,Doubly-Linked List
Medium
460,588,604,1903
938
friends today I'm going to solve it could problem 938 range sum of PST so here we are given a binary search tree and we are given the node root node of the binary search tree the two integer values low and high and we need to return the sum of all the values of the nodes whose values are in the range low and high so le...
Range Sum of BST
numbers-at-most-n-given-digit-set
Given the `root` node of a binary search tree and two integers `low` and `high`, return _the sum of values of all nodes with a value in the **inclusive** range_ `[low, high]`. **Example 1:** **Input:** root = \[10,5,15,3,7,null,18\], low = 7, high = 15 **Output:** 32 **Explanation:** Nodes 7, 10, and 15 are in the ra...
null
Array,Math,Binary Search,Dynamic Programming
Hard
null
562
hello friends now less of the longest an eye out can see reach if one Ahmet ryx as lemon is given a zero one metrics and finding the longest eye of conservative one in the metrics the line could be horizontal vertical diagonal and anti dark so see this example we can find that the longest so consider one is this guy so...
Longest Line of Consecutive One in Matrix
longest-line-of-consecutive-one-in-matrix
Given an `m x n` binary matrix `mat`, return _the length of the longest line of consecutive one in the matrix_. The line could be horizontal, vertical, diagonal, or anti-diagonal. **Example 1:** **Input:** mat = \[\[0,1,1,0\],\[0,1,1,0\],\[0,0,0,1\]\] **Output:** 3 **Example 2:** **Input:** mat = \[\[1,1,1,1\],\[0...
One solution is to count ones in each direction separately and find the longest line. Don't you think it will take too much lines of code? Is it possible to use some extra space to make the solution simple? Can we use dynamic programming to make use of intermediate results? Think of a 3D array which can be used to sto...
Array,Dynamic Programming,Matrix
Medium
null
128
Hello guys welcome let's go straight to the video language problem me this and the longest corridor sequence from this problem me to the front ginger green the length of maximum quantity consultancy okay what is the quantity sequence positive sequence pure sequence like late to 1234 and 789 and late Se 60 Ok And Monito...
Longest Consecutive Sequence
longest-consecutive-sequence
Given an unsorted array of integers `nums`, return _the length of the longest consecutive elements sequence._ You must write an algorithm that runs in `O(n)` time. **Example 1:** **Input:** nums = \[100,4,200,1,3,2\] **Output:** 4 **Explanation:** The longest consecutive elements sequence is `[1, 2, 3, 4]`. Therefor...
null
Array,Hash Table,Union Find
Medium
298,2278
137
1:37 single numbers to give me a non 1:37 single numbers to give me a non 1:37 single numbers to give me a non empty array of integers every element appears three times except for one which appears exactly once find that single one you algum should have a linear time complexity could you implement it without using extr...
Single Number II
single-number-ii
Given an integer array `nums` where every element appears **three times** except for one, which appears **exactly once**. _Find the single element and return it_. You must implement a solution with a linear runtime complexity and use only constant extra space. **Example 1:** **Input:** nums = \[2,2,3,2\] **Output:**...
null
Array,Bit Manipulation
Medium
136,260
796
foreign welcome back to my channel and today we are we guys are going to solve a new lead code question that is rotate string with the help of python so the question says given to string s and Gold return true if any if and only if s can become gold after some number of shifts on S a shift on S consists of moving the l...
Rotate String
reaching-points
Given two strings `s` and `goal`, return `true` _if and only if_ `s` _can become_ `goal` _after some number of **shifts** on_ `s`. A **shift** on `s` consists of moving the leftmost character of `s` to the rightmost position. * For example, if `s = "abcde "`, then it will be `"bcdea "` after one shift. **Example 1...
null
Math
Hard
null
1,736
hey everybody this is larry this is day uh no this is q1 of the latest weekly contest 225 latest time by replacing hidden digits um hit the like button hit the subscribe button join me on discord uh my energy is a little bit low today because of some situation with my life um but you know let's see you know this is my ...
Latest Time by Replacing Hidden Digits
build-binary-expression-tree-from-infix-expression
You are given a string `time` in the form of `hh:mm`, where some of the digits in the string are hidden (represented by `?`). The valid times are those inclusively between `00:00` and `23:59`. Return _the latest valid time you can get from_ `time` _by replacing the hidden_ _digits_. **Example 1:** **Input:** time =...
Convert infix expression to postfix expression. Build an expression tree from the postfix expression.
String,Stack,Tree,Binary Tree
Hard
785,1750
664
64 string printer so there is a string printer with the following two spal properties so the printer can only print a sequence of the same characters each time at each turn printer can print new characters starting from the studing form and adding at any place and will cover the original existing characters so let me j...
Strange Printer
strange-printer
There is a strange printer with the following two special properties: * The printer can only print a sequence of **the same character** each time. * At each turn, the printer can print new characters starting from and ending at any place and will cover the original existing characters. Given a string `s`, return ...
null
String,Dynamic Programming
Hard
546,1696
604
hello guys now a Chinese of the design compressed a straight iterator actually is probably similar to the previous progress all which will give up give us a stream we will compress it and now we are given a compress the stream we want you recovered so and also this program I think if the similar cuter read characters b...
Design Compressed String Iterator
design-compressed-string-iterator
Design and implement a data structure for a compressed string iterator. The given compressed string will be in the form of each letter followed by a positive integer representing the number of this letter existing in the original uncompressed string. Implement the StringIterator class: * `next()` Returns **the next...
null
Array,Hash Table,String,Design,Iterator
Easy
146,443
41
hello let's try to solve a lead code problem today we are going to solve number 41 First missing positive so it's a hard problem and even we did it many times it's really easy to make mistakes because we if we did it many times we basically know how to solve it but there are still some tricks we may forget it's time we...
First Missing Positive
first-missing-positive
Given an unsorted integer array `nums`, return the smallest missing positive integer. You must implement an algorithm that runs in `O(n)` time and uses constant extra space. **Example 1:** **Input:** nums = \[1,2,0\] **Output:** 3 **Explanation:** The numbers in the range \[1,2\] are all in the array. **Example 2:*...
Think about how you would solve the problem in non-constant space. Can you apply that logic to the existing space? We don't care about duplicates or non-positive integers Remember that O(2n) = O(n)
Array,Hash Table
Hard
268,287,448,770
5
hi guys welcome to the tech grant today we are going to solve the lead code problem of longest palindromic substring do like and share the video subscribe to the channel to get further update and also i've started a new playlist for those who want to start with data structure so do check that out as well the link will ...
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
1,869
hey guys welcome to today's video in today's video we're going to look at a lead code problem and the problem's name is longer contigous segments of ones than zeros so in this question we given a binary string s and our task is to return true if the longest contigous segments of ones is strictly longer than the longest...
Longer Contiguous Segments of Ones than Zeros
longer-contiguous-segments-of-ones-than-zeros
Given a binary string `s`, return `true` _if the **longest** contiguous segment of_ `1`'_s is **strictly longer** than the **longest** contiguous segment of_ `0`'_s in_ `s`, or return `false` _otherwise_. * For example, in `s = "110100010 "` the longest continuous segment of `1`s has length `2`, and the longest cont...
null
null
Easy
null
268
this is one of the simpler problems and yet I find that this problem is asked in a lot of coding interviews why is that so well you are given an array of integers that have numbers in the range of 0 to n correct and you have to find the missing number the main reason this problem is asked in a lot of places is that bec...
Missing Number
missing-number
Given an array `nums` containing `n` distinct numbers in the range `[0, n]`, return _the only number in the range that is missing from the array._ **Example 1:** **Input:** nums = \[3,0,1\] **Output:** 2 **Explanation:** n = 3 since there are 3 numbers, so all numbers are in the range \[0,3\]. 2 is the missing number...
null
Array,Hash Table,Math,Bit Manipulation,Sorting
Easy
41,136,287,770,2107
1,022
Hello hello everyone welcome to our channel co with honey and today will be discussing the easy problem evening of root to lip binary numbers 102 the like delhi challenge problem seethe [ seethe [ seethe 11sau loot explain time related subscribe explain number 90 number two the Park And What Is The Decimal Values Of De...
Sum of Root To Leaf Binary Numbers
unique-paths-iii
You are given the `root` of a binary tree where each node has a value `0` or `1`. Each root-to-leaf path represents a binary number starting with the most significant bit. * For example, if the path is `0 -> 1 -> 1 -> 0 -> 1`, then this could represent `01101` in binary, which is `13`. For all leaves in the tree, c...
null
Array,Backtracking,Bit Manipulation,Matrix
Hard
37,63,212
443
given an array of characters cares compress it using the following algorithm these are the rules that we should follow the first rule is if in the list of characters that they have the number of like a distinct character is equal to one we are going to just add that character like this example we have one a we are goin...
String Compression
string-compression
Given an array of characters `chars`, compress it using the following algorithm: Begin with an empty string `s`. For each group of **consecutive repeating characters** in `chars`: * If the group's length is `1`, append the character to `s`. * Otherwise, append the character followed by the group's length. The co...
How do you know if you are at the end of a consecutive group of characters?
Two Pointers,String
Medium
38,271,604,1241
1,976
foreign welcome back to the channel so today in this video lecture we're going to be solving this problem number of ways to arrive at destination so this is yet another problem in the diastra algorithm Series so basically you in a city that consists of n intersections and they are numbered from 0 to n minus 1. that mea...
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
284
Jhal Hello Friends Welcome To Your Flight Should Be Vaikuntha Lok Shaitan 2 Medium Lal Problem From Digit Court Till Problem No. 218 More Problems Design United South East Self Financed Operational List In Addition To His Next And Next Operation OK Increment Till Previous Zombies Inside Him We Constraints two years wil...
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
145
welcome to july's leeco challenge today's problem is construct binary tree from inorder and post-order traversal from inorder and post-order traversal from inorder and post-order traversal given an in-order and post-order given an in-order and post-order given an in-order and post-order traversal of a tree construct th...
Binary Tree Postorder Traversal
binary-tree-postorder-traversal
Given the `root` of a binary tree, return _the postorder traversal of its nodes' values_. **Example 1:** **Input:** root = \[1,null,2,3\] **Output:** \[3,2,1\] **Example 2:** **Input:** root = \[\] **Output:** \[\] **Example 3:** **Input:** root = \[1\] **Output:** \[1\] **Constraints:** * The number of the n...
null
Stack,Tree,Depth-First Search,Binary Tree
Easy
94,776
63
welcome to interview Pro let's solve another lead code problem today unique Parts two this question was asked in a number of companies so let's see what this question is about we will be given M byn integer array we'll be starting from the first cell we need to reach the last cell of this grid and the condition is we c...
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
188
hey guys everything going this is Jay sir who's not good at algorithms in this video I'm going to take a look at 188 best time to spare and sell stock for we've already accomplished the previous three related problems which one two three please search on my channel for details if you want in this problem we're the requ...
Best Time to Buy and Sell Stock IV
best-time-to-buy-and-sell-stock-iv
You are given an integer array `prices` where `prices[i]` is the price of a given stock on the `ith` day, and an integer `k`. Find the maximum profit you can achieve. You may complete at most `k` transactions: i.e. you may buy at most `k` times and sell at most `k` times. **Note:** You may not engage in multiple tran...
null
Array,Dynamic Programming
Hard
121,122,123
352
hello guys today I'm gonna tell you about these questions in the lead code for the 352 data stream as destroying intervals so as we can see the questions if someone doesn't understand what does it mean I will explain here so as we can see here he gave a data stream input of non-negative integers so it input of non-nega...
Data Stream as Disjoint Intervals
data-stream-as-disjoint-intervals
Given a data stream input of non-negative integers `a1, a2, ..., an`, summarize the numbers seen so far as a list of disjoint intervals. Implement the `SummaryRanges` class: * `SummaryRanges()` Initializes the object with an empty stream. * `void addNum(int value)` Adds the integer `value` to the stream. * `int...
null
Binary Search,Design,Ordered Set
Hard
228,436,715
797
um hello so today we are going to do this problem which is part of lead called do some birthday challenge so the problem is all paths from search to Target so we get a directed acyclic graph um so this piece is important with roads that are labeled from zero to n minus one and uh we want to find all the possible paths ...
All Paths From Source to Target
rabbits-in-forest
Given a directed acyclic graph (**DAG**) of `n` nodes labeled from `0` to `n - 1`, find all possible paths from node `0` to node `n - 1` and return them in **any order**. The graph is given as follows: `graph[i]` is a list of all nodes you can visit from node `i` (i.e., there is a directed edge from node `i` to node `...
null
Array,Hash Table,Math,Greedy
Medium
null
673
hello and welcome back to another video today we're going to be doing number of longest increasing subsequence and so this is pretty much a follow-up to the this is pretty much a follow-up to the this is pretty much a follow-up to the problem that's uh called longest increasing subsequence only code and it's a very pop...
Number of Longest Increasing Subsequence
number-of-longest-increasing-subsequence
Given an integer array `nums`, return _the number of longest increasing subsequences._ **Notice** that the sequence has to be **strictly** increasing. **Example 1:** **Input:** nums = \[1,3,5,4,7\] **Output:** 2 **Explanation:** The two longest increasing subsequences are \[1, 3, 4, 7\] and \[1, 3, 5, 7\]. **Exampl...
null
Array,Dynamic Programming,Binary Indexed Tree,Segment Tree
Medium
300,674
55
in this video we'll be going over jump games so given rate of non-negative games so given rate of non-negative games so given rate of non-negative integers nums you're initially positioned at the first index of the array each element in the array represents your maximum jump length at that position determine if you are...
Jump Game
jump-game
You are given an integer array `nums`. You are initially positioned at the array's **first index**, and each element in the array represents your maximum jump length at that position. Return `true` _if you can reach the last index, or_ `false` _otherwise_. **Example 1:** **Input:** nums = \[2,3,1,1,4\] **Output:** t...
null
Array,Dynamic Programming,Greedy
Medium
45,1428,2001
111
hello everyone uh welcome back to pseudocoders uh today we are gonna talk about the lead code uh 111 problem minimum depth of the binary tree uh this problem is uh basically a very basic problem that can be asked in an interview question interview so let's move on let's get on with it uh let's read what the problem is ...
Minimum Depth of Binary Tree
minimum-depth-of-binary-tree
Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. **Note:** A leaf is a node with no children. **Example 1:** **Input:** root = \[3,9,20,null,null,15,7\] **Output:** 2 **Example 2:** **Input:** root = \[2...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Easy
102,104
5
hello guys welcome to study algorithms and today's problem is finding the longest palindromic substring first I'm gonna describe the problem statement and show you some sample test cases next we will understand how to go about solving the problem and what issues you may find while working through it then I will compare...
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
284
hi guys welcome to algorithms made easy in this video we will see the question peaking iterator given an iterator interface with methods next and has next design and implement a peaking iterator that supports the peak operation it peaks at the element that will be returned by the next call to next that is this next met...
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
897
hello everyone welcome to day 17th of april eco challenge my name is sanchez i am working a software developer at adobe and today i present day 661 of leetco daily question the question that we have in today is increasing order surgery and to your surprise for all those who have been following along as i told yesterday...
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
1,680
Hello Guys Welcome Back To Take Divorce And This Video Will See The Continuation Of Consecutive Binary Numbers Problem That Soft Code Number 181 Middle Age Problem No Problem Thursday Ko Daba Representation In Law And Order No Veer Versus The Latest Example Subscription is here inch and value Sanjay question is one to ...
Concatenation of Consecutive Binary Numbers
count-all-possible-routes
Given an integer `n`, return _the **decimal value** of the binary string formed by concatenating the binary representations of_ `1` _to_ `n` _in order, **modulo**_ `109 + 7`. **Example 1:** **Input:** n = 1 **Output:** 1 **Explanation: ** "1 " in binary corresponds to the decimal value 1. **Example 2:** **Input:**...
Use dynamic programming to solve this problem with each state defined by the city index and fuel left. Since the array contains distinct integers fuel will always be spent in each move and so there can be no cycles.
Array,Dynamic Programming,Memoization
Hard
null
1,441
friend so today we can discuss this problem from weekly contest we put 188 problem number 104 gone we didn't array with type operation so the problem statement is very simple so you are given a target array and an integer n in each iteration you will read a number from 1 2 3 2 till N and you have to build the target ar...
Build an Array With Stack Operations
minimum-flips-to-make-a-or-b-equal-to-c
You are given an integer array `target` and an integer `n`. You have an empty stack with the two following operations: * **`"Push "`**: pushes an integer to the top of the stack. * **`"Pop "`**: removes the integer on the top of the stack. You also have a stream of the integers in the range `[1, n]`. Use the tw...
Check the bits one by one whether they need to be flipped.
Bit Manipulation
Medium
2323
1,689
hello everyone welcome to coding decoded my name is santiago deja i am working as technical architect sd4 at adobe and sincere apologies i couldn't post the solution of today's lead good problem in the morning as it was a working day for me i just came back from office and i thought of completing this exercise because ...
Partitioning Into Minimum Number Of Deci-Binary Numbers
detect-pattern-of-length-m-repeated-k-or-more-times
A decimal number is called **deci-binary** if each of its digits is either `0` or `1` without any leading zeros. For example, `101` and `1100` are **deci-binary**, while `112` and `3001` are not. Given a string `n` that represents a positive decimal integer, return _the **minimum** number of positive **deci-binary** n...
Use a three-layer loop to check all possible patterns by iterating through all possible starting positions, all indexes less than m, and if the character at the index is repeated k times.
Array,Enumeration
Easy
1764
456
hey everyone welcome back and let's write some more neat code today so today let's solve the problem one three two pattern we're given an array of n integers and we want to find a one three two pattern such that there are three integers and they appear in the order i j k so j appears after i in the array and k appears ...
132 Pattern
132-pattern
Given an array of `n` integers `nums`, a **132 pattern** is a subsequence of three integers `nums[i]`, `nums[j]` and `nums[k]` such that `i < j < k` and `nums[i] < nums[k] < nums[j]`. Return `true` _if there is a **132 pattern** in_ `nums`_, otherwise, return_ `false`_._ **Example 1:** **Input:** nums = \[1,2,3,4\] ...
null
Array,Binary Search,Stack,Monotonic Stack,Ordered Set
Medium
null
22
hey everyone welcome back and let's write some more neat code today so today let's solve generate parentheses so we are given a pair a certain number and pairs of parentheses and we want to write a function to generate combinations of all well-formed well-formed well-formed parentheses and so you can see that these are...
Generate Parentheses
generate-parentheses
Given `n` pairs of parentheses, write a function to _generate all combinations of well-formed parentheses_. **Example 1:** **Input:** n = 3 **Output:** \["((()))","(()())","(())()","()(())","()()()"\] **Example 2:** **Input:** n = 1 **Output:** \["()"\] **Constraints:** * `1 <= n <= 8`
null
String,Dynamic Programming,Backtracking
Medium
17,20,2221
1,057
hey guys how's everything going today let's take a look at number 105 seven campus bikes there is a campus represented as 2d grid there's n workers and bikes each work and bike is a 2d coordinates on this grid okay our goal used to sign a bike to each worker a month so the bikes are more than the worker so every worker...
Campus Bikes
numbers-with-repeated-digits
On a campus represented on the X-Y plane, there are `n` workers and `m` bikes, with `n <= m`. You are given an array `workers` of length `n` where `workers[i] = [xi, yi]` is the position of the `ith` worker. You are also given an array `bikes` of length `m` where `bikes[j] = [xj, yj]` is the position of the `jth` bike...
How many numbers with no duplicate digits? How many numbers with K digits and no duplicates? How many numbers with same length as N? How many numbers with same prefix as N?
Math,Dynamic Programming
Hard
null
160
hi everyone it's Orkin welcome to my channel uh today we are gonna solve lead code 160 intersection of two linked list problem so the problem statement is that we have to linked lists and uh with the head of the link at least being a and the B and we need to return the node at which the to list intersect so um if there...
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,391
thousand 391 crimes that are called chekib diverse for him and for you madrid this problem by the contest 181 of lyrical and good and gel and with many times and good is his problem in reality simple laborious state but it is quite simple what it is about is that They are going to give us the flu. It is the typical pro...
Check if There is a Valid Path in a Grid
counting-elements
You are given an `m x n` `grid`. Each cell of `grid` represents a street. The street of `grid[i][j]` can be: * `1` which means a street connecting the left cell and the right cell. * `2` which means a street connecting the upper cell and the lower cell. * `3` which means a street connecting the left cell and the...
Use hashset to store all elements. Loop again to count all valid elements.
Array,Hash Table
Easy
null
86
foreign hi this is Topher from the lonely Dash and today we're going over lead code question number 86 partition list which states given the head of a linked list and a value X partition it such that all nodes less than x come before nodes greater than or equal to X you should preserve the original relative order of th...
Partition List
partition-list
Given the `head` of a linked list and a value `x`, partition it such that all nodes **less than** `x` come before nodes **greater than or equal** to `x`. You should **preserve** the original relative order of the nodes in each of the two partitions. **Example 1:** **Input:** head = \[1,4,3,2,5,2\], x = 3 **Output:**...
null
Linked List,Two Pointers
Medium
2265
100
So the name of the question is Se Tree, you will get this question number 100, I will put this question in the description in the link, go and solve it there, then look carefully, in the problem statement you have two trees given, okay, the name of is Ke. What is this P? This is the root note of the first tree. What is...
Same Tree
same-tree
Given the roots of two binary trees `p` and `q`, write a function to check if they are the same or not. Two binary trees are considered the same if they are structurally identical, and the nodes have the same value. **Example 1:** **Input:** p = \[1,2,3\], q = \[1,2,3\] **Output:** true **Example 2:** **Input:** p...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Easy
null
46
in this video we'll be going over permutations given an array numbers of distinct integers return all the possible permutations you can return the answer in any order so our input array is one two three and these are all the possible permutations each of the elements is used once in each of the combinations let's go ov...
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
174
Hua Tha Hello Everybody Welcome To My Channel Today's Date 2F June Recording Challenge And Problem Play Eastern Jung Game Straight Problem Statement And Tried To Understand Half Minute Captures Pain And Imprisoned In Harinder Gautam Right Corner Of Danger Consists Of A Gross And Room's Light Off to Degree Tower Valiant...
Dungeon Game
dungeon-game
The demons had captured the princess and imprisoned her in **the bottom-right corner** of a `dungeon`. The `dungeon` consists of `m x n` rooms laid out in a 2D grid. Our valiant knight was initially positioned in **the top-left room** and must fight his way through `dungeon` to rescue the princess. The knight has an i...
null
Array,Dynamic Programming,Matrix
Hard
62,64,741,2354
1,926
away for a while some of you know the reason for it was my sister's wedding and I took the liberty to enjoy that event thoroughly by God's grace all the event went really well and I'll be sharing the glimpse of my D dance performances very soon so that you guys can enjoy those too however now it's time to get back to b...
Nearest Exit from Entrance in Maze
products-price-for-each-store
You are given an `m x n` matrix `maze` (**0-indexed**) with empty cells (represented as `'.'`) and walls (represented as `'+'`). You are also given the `entrance` of the maze, where `entrance = [entrancerow, entrancecol]` denotes the row and column of the cell you are initially standing at. In one step, you can move o...
null
Database
Easy
1948
807
hey everybody this is Larry this is me go uh doing an extra question because I'm trying to take advantage of my premium uh lead code it's February 5th uh of 2023 man these years they go fight by don't they all right let's get started let's do a random one um okay to do and let's go any difficulty give me one well okay ...
Max Increase to Keep City Skyline
custom-sort-string
There is a city composed of `n x n` blocks, where each block contains a single building shaped like a vertical square prism. You are given a **0-indexed** `n x n` integer matrix `grid` where `grid[r][c]` represents the **height** of the building located in the block at row `r` and column `c`. A city's **skyline** is t...
null
Hash Table,String,Sorting
Medium
null
349
in any order okay so this is the first example in this first example these two in this area is given to you your output is 2 okay because you have to return the unique okay unit element you have to return and the result can be any order so your output is too high so because a unique element because means if you interse...
Intersection of Two Arrays
intersection-of-two-arrays
Given two integer arrays `nums1` and `nums2`, return _an array of their intersection_. Each element in the result must be **unique** and you may return the result in **any order**. **Example 1:** **Input:** nums1 = \[1,2,2,1\], nums2 = \[2,2\] **Output:** \[2\] **Example 2:** **Input:** nums1 = \[4,9,5\], nums2 = \...
null
Array,Hash Table,Two Pointers,Binary Search,Sorting
Easy
350,1149,1392,2190,2282
791
Hello Everyone So today we will solve another problem of Lead Ko Daily Challenge Custom Short Sting Let us start if you have not subscribed our channel then please subscribe then first of all let us understand the problem statement what is given to us So let's start, you are given to string order and S, so we have been...
Custom Sort String
split-bst
You are given two strings order and s. All the characters of `order` are **unique** and were sorted in some custom order previously. Permute the characters of `s` so that they match the order that `order` was sorted. More specifically, if a character `x` occurs before a character `y` in `order`, then `x` should occur ...
Use recursion. If root.val <= V, you split root.right into two halves, then join it's left half back on root.right.
Tree,Binary Search Tree,Recursion,Binary Tree
Medium
450
807
Hello Hi Friends Welcome Back To Days Ago Into Solitude Problem 10 Maths Increase That City Skyline After Start Looking Into The Details Of The Problem And Some Example Clear Mention That My Channel Is Dedicated To And People Hu A And Preparing For Code In Interviews And Where Introduced And All My Channel The Royal To...
Max Increase to Keep City Skyline
custom-sort-string
There is a city composed of `n x n` blocks, where each block contains a single building shaped like a vertical square prism. You are given a **0-indexed** `n x n` integer matrix `grid` where `grid[r][c]` represents the **height** of the building located in the block at row `r` and column `c`. A city's **skyline** is t...
null
Hash Table,String,Sorting
Medium
null
583
That Hey Guys Welcome And Welcome Back To My Channel Today Bhaiya Ko International Problem Barf Aur 1.5 Lite Video Please Like Share Subscribe Barf Aur 1.5 Lite Video Please Like Share Subscribe Barf Aur 1.5 Lite Video Please Like Share Subscribe My Channel Record Bhi Solve All Problems Dairy And I Don't Want You To Mi...
Delete Operation for Two Strings
delete-operation-for-two-strings
Given two strings `word1` and `word2`, return _the minimum number of **steps** required to make_ `word1` _and_ `word2` _the same_. In one **step**, you can delete exactly one character in either string. **Example 1:** **Input:** word1 = "sea ", word2 = "eat " **Output:** 2 **Explanation:** You need one step to mak...
null
String,Dynamic Programming
Medium
72,712,1250
1,323
I am Hasan America. In this video, ricote always comes to me. 323. to their table. Wooden sword. Every participation from the baker Orhan. Sorry, living the condition of the table. Our Fridays, this is not genial before. Look, it's long, come, it's the last goddess, now it's the transition that emerged. Steel should fi...
Maximum 69 Number
maximum-69-number
You are given a positive integer `num` consisting only of digits `6` and `9`. Return _the maximum number you can get by changing **at most** one digit (_`6` _becomes_ `9`_, and_ `9` _becomes_ `6`_)_. **Example 1:** **Input:** num = 9669 **Output:** 9969 **Explanation:** Changing the first digit results in 6669. Cha...
null
null
Easy
null
936
Same guys welcome to take good bye Nivedita and in this video we are going to solve stamping also sequence in such problems statement what have we got here we have two strings even champion target and in this problem statement the giver is that an initial string We have a camera whose length is equal to the lens of the...
Stamping The Sequence
rle-iterator
You are given two strings `stamp` and `target`. Initially, there is a string `s` of length `target.length` with all `s[i] == '?'`. In one turn, you can place `stamp` over `s` and replace every letter in the `s` with the corresponding letter from `stamp`. * For example, if `stamp = "abc "` and `target = "abcba "`, t...
null
Array,Design,Counting,Iterator
Medium
null
543
to look at a legal problem called diameter of binary trees so i haven't do any easy legal problems for a while now so i'm gonna do it now but basically depends really depends on your experience this question in my opinion is pretty easy but it might not be easy for um for other people but i think that in this video i r...
Diameter of Binary Tree
diameter-of-binary-tree
Given the `root` of a binary tree, return _the length of the **diameter** of the tree_. The **diameter** of a binary tree is the **length** of the longest path between any two nodes in a tree. This path may or may not pass through the `root`. The **length** of a path between two nodes is represented by the number of ...
null
Tree,Depth-First Search,Binary Tree
Easy
1665
328
Loot Hello Friends Hindi Session Where Do We Need To Discuss About Another Simple List Co Problem And This Liquid You Will Be Given As In Link List Group Oil And Notes With Affordable Events Please Note The Group Must Be Done Not Index Not Be Not Valid For United State The First Noida Shoulder To Shoulder 1000 Give Wha...
Odd Even Linked List
odd-even-linked-list
Given the `head` of a singly linked list, group all the nodes with odd indices together followed by the nodes with even indices, and return _the reordered list_. The **first** node is considered **odd**, and the **second** node is **even**, and so on. Note that the relative order inside both the even and odd groups s...
null
Linked List
Medium
725
611
welcome to july's leeco challenge today's problem is valid triangle number given an integer array nums return the number of triplets chosen from the array that can make triangles if we take them as side lengths of a triangle here with two three four we're gonna output three because we have uh three combinations of two ...
Valid Triangle Number
valid-triangle-number
Given an integer array `nums`, return _the number of triplets chosen from the array that can make triangles if we take them as side lengths of a triangle_. **Example 1:** **Input:** nums = \[2,2,3,4\] **Output:** 3 **Explanation:** Valid combinations are: 2,3,4 (using the first 2) 2,3,4 (using the second 2) 2,2,3 *...
null
Array,Two Pointers,Binary Search,Greedy,Sorting
Medium
259
1,512
Work in this area Ajay Ko Ki A [ Ki A [ Ki A Hello Everyone and Welcome to New Video Hindi Video Bihar Going to Discuss Another Problem from Its Code Problem Is Problem 1512 Number of the Problem Statement Boys Subscribe and Good Player Our Pear Hum Apna 12351 This Vansh Now what we have to do is told in this what Sinh...
Number of Good Pairs
design-underground-system
Given an array of integers `nums`, return _the number of **good pairs**_. A pair `(i, j)` is called _good_ if `nums[i] == nums[j]` and `i` < `j`. **Example 1:** **Input:** nums = \[1,2,3,1,1,3\] **Output:** 4 **Explanation:** There are 4 good pairs (0,3), (0,4), (3,4), (2,5) 0-indexed. **Example 2:** **Input:** nu...
Use two hash tables. The first to save the check-in time for a customer and the second to update the total time between two stations.
Hash Table,String,Design
Medium
2285
671
hello all welcome to netset os today in this video we'll be discussing lead code number 671 second minimum note in a binary tree here let's understand this question in terms of players let's say i have steams who are playing the games 5 4 2 three six one eight and seven now obviously if i need to take out the winner ou...
Second Minimum Node In a Binary Tree
second-minimum-node-in-a-binary-tree
Given a non-empty special binary tree consisting of nodes with the non-negative value, where each node in this tree has exactly `two` or `zero` sub-node. If the node has two sub-nodes, then this node's value is the smaller value among its two sub-nodes. More formally, the property `root.val = min(root.left.val, root.ri...
null
Tree,Depth-First Search,Binary Tree
Easy
230
1,324
everyone so today we're going to go over a string based problem asked at Microsoft called print words vertically so the description says given a string s returned all the words vertically in the same order in which they appear in s words are returned as a list of strings complete with spaces when is necessary trailing ...
Print Words Vertically
where-will-the-ball-fall
Given a string `s`. Return all the words vertically in the same order in which they appear in `s`. Words are returned as a list of strings, complete with spaces when is necessary. (Trailing spaces are not allowed). Each word would be put on only one column and that in one column there will be only one word. **Exam...
Use DFS. Traverse the path of the ball downwards until you reach the bottom or get stuck.
Array,Dynamic Programming,Depth-First Search,Matrix,Simulation
Medium
null
1,970
hi everyone in today challenge we are going to solve this problem the problem name is last day where you can still close and the problem number is one nine seven zero all right guys so as usual first of all we are going to clearly understand this problem statement after that we're gonna move to the logic part we are go...
Last Day Where You Can Still Cross
sorting-the-sentence
There is a **1-based** binary matrix where `0` represents land and `1` represents water. You are given integers `row` and `col` representing the number of rows and columns in the matrix, respectively. Initially on day `0`, the **entire** matrix is **land**. However, each day a new cell becomes flooded with **water**. ...
Divide the string into the words as an array of strings Sort the words by removing the last character from each word and sorting according to it
String,Sorting
Easy
2168
1,197
hi everyone with Kelvin here so let's discuss about beauty contest 9 second question we need more mic move so we are given infinite chessboard good coordinate from minus infinity to plus infinity and we have fun like X square 0 and then I have a possible Phegley to move as a standard chess role of naik and then we've b...
Minimum Knight Moves
parsing-a-boolean-expression
In an **infinite** chess board with coordinates from `-infinity` to `+infinity`, you have a **knight** at square `[0, 0]`. A knight has 8 possible moves it can make, as illustrated below. Each move is two squares in a cardinal direction, then one square in an orthogonal direction. Return _the minimum number of steps ...
Write a function "parse" which calls helper functions "parse_or", "parse_and", "parse_not".
String,Stack,Recursion
Hard
null
531
hey everybody this is Larry this is January 17th of the New Year 2023. I'm going to try to do a problem that I haven't done before so let's uh let's get to it uh oh there you go uh what I want to do I feel like yesterday I got it easy or something but I don't remember all right let's just uh let's just focus on a mediu...
Lonely Pixel I
lonely-pixel-i
Given an `m x n` `picture` consisting of black `'B'` and white `'W'` pixels, return _the number of **black** lonely pixels_. A black lonely pixel is a character `'B'` that located at a specific position where the same row and same column don't have **any other** black pixels. **Example 1:** **Input:** picture = \[\[...
null
Array,Hash Table,Matrix
Medium
533
2
so hello everyone i am straight i am a software development engineer so we are starting with this lead code premium top interview problem series we will be discussing each and every problem which are mentioned on the lead code top interviews and also this will help you to crack your next coding interview in the top not...
Add Two Numbers
add-two-numbers
You are given two **non-empty** linked lists representing two non-negative integers. The digits are stored in **reverse order**, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list. You may assume the two numbers do not contain any leading zero, except the number 0 ...
null
Linked List,Math,Recursion
Medium
43,67,371,415,445,1031,1774
1,762
today we're going to be solving leak code problem 1762 buildings with an ocean view currently this problem is really popular with facebook amazon and microsoft so this is definitely one to know for your upcoming on-site interviews all right upcoming on-site interviews all right upcoming on-site interviews all right let...
Buildings With an Ocean View
furthest-building-you-can-reach
There are `n` buildings in a line. You are given an integer array `heights` of size `n` that represents the heights of the buildings in the line. The ocean is to the right of the buildings. A building has an ocean view if the building can see the ocean without obstructions. Formally, a building has an ocean view if al...
Assume the problem is to check whether you can reach the last building or not. You'll have to do a set of jumps, and choose for each one whether to do it using a ladder or bricks. It's always optimal to use ladders in the largest jumps. Iterate on the buildings, maintaining the largest r jumps and the sum of the remain...
Array,Greedy,Heap (Priority Queue)
Medium
null
103
tension I am smile breathe inside you and the black and today you might Justin this with Steve significant sings a hope to find you open up your eyes blinded by the lies so you can see to dice Sidra sauna took a swing at a wrecking ball and I prayed for Maddow and thought a way to reconcile cos in my heart it's not wor...
Binary Tree Zigzag Level Order Traversal
binary-tree-zigzag-level-order-traversal
Given the `root` of a binary tree, return _the zigzag level order traversal of its nodes' values_. (i.e., from left to right, then right to left for the next level and alternate between). **Example 1:** **Input:** root = \[3,9,20,null,null,15,7\] **Output:** \[\[3\],\[20,9\],\[15,7\]\] **Example 2:** **Input:** roo...
null
Tree,Breadth-First Search,Binary Tree
Medium
102
389
hello everyone so in this video let us talk about a easy problem from lead code the problem name is find the difference so you are given two string s and t string T is generated by random shuffling the string s and then adding one more letter at a random place now you just have to return the letter that was added uh to...
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
383
hi there in this video we'll be looking into a problem called Ransom note let's jump into the problem statement so given two strings Ransom note and magazine return true if Ransom note can be constructed by using the letters from magazine and false otherwise so each letter in magazine can only be used once in Ransom no...
Ransom Note
ransom-note
Given two strings `ransomNote` and `magazine`, return `true` _if_ `ransomNote` _can be constructed by using the letters from_ `magazine` _and_ `false` _otherwise_. Each letter in `magazine` can only be used once in `ransomNote`. **Example 1:** **Input:** ransomNote = "a", magazine = "b" **Output:** false **Example ...
null
Hash Table,String,Counting
Easy
691
1,351
Hello everyone welcome you are my channel from where you get to learn a lot of things ok the name of this question is count negative numbers in a sorted matrix question it is very simple ok Amazon asked this question let's read the statement of the question Let's see what six is ​​saying, it is saying what six is ​​say...
Count Negative Numbers in a Sorted Matrix
replace-the-substring-for-balanced-string
Given a `m x n` matrix `grid` which is sorted in non-increasing order both row-wise and column-wise, return _the number of **negative** numbers in_ `grid`. **Example 1:** **Input:** grid = \[\[4,3,2,-1\],\[3,2,1,-1\],\[1,1,-1,-2\],\[-1,-1,-2,-3\]\] **Output:** 8 **Explanation:** There are 8 negatives number in the ma...
Use 2-pointers algorithm to make sure all amount of characters outside the 2 pointers are smaller or equal to n/4. That means you need to count the amount of each letter and make sure the amount is enough.
String,Sliding Window
Medium
null
363
um hello so today we are going to do this problem which is uh part of august daily challenge max sum of rectangle no larger than k so basically the maximum of any sub rectangle in this in the rectangle that we get as input that is smaller or equal to k and we get the k value um and yeah it's guaranteed that there is a ...
Max Sum of Rectangle No Larger Than K
max-sum-of-rectangle-no-larger-than-k
Given an `m x n` matrix `matrix` and an integer `k`, return _the max sum of a rectangle in the matrix such that its sum is no larger than_ `k`. It is **guaranteed** that there will be a rectangle with a sum no larger than `k`. **Example 1:** **Input:** matrix = \[\[1,0,1\],\[0,-2,3\]\], k = 2 **Output:** 2 **Explana...
null
Array,Binary Search,Dynamic Programming,Matrix,Ordered Set
Hard
null
1,589
hello welcome to today's video we'll be looking at lea code problem number 1589 the maximum sum obtained of any permutation the problem says that we have an array of integers and an array of requests and the ith request gives us the starting position and the ending position of that request what that means is we go to t...
Maximum Sum Obtained of Any Permutation
maximum-sum-obtained-of-any-permutation
We have an array of integers, `nums`, and an array of `requests` where `requests[i] = [starti, endi]`. The `ith` request asks for the sum of `nums[starti] + nums[starti + 1] + ... + nums[endi - 1] + nums[endi]`. Both `starti` and `endi` are _0-indexed_. Return _the maximum total sum of all requests **among all permuta...
null
null
Medium
null
790
Hello friends, the liquid problem to be discussed in today's video is Zamino and Prominent Rigs Problem, Very Jab Very Sweet Problem Kya Hai Bhi Two Types of Tiles 2012 Millon Se Electron Shetty Excessive This Is Your Domination Tap Control Man Is Okay NDA government teacher and I have written a number of way to toilet...
Domino and Tromino Tiling
global-and-local-inversions
You have two types of tiles: a `2 x 1` domino shape and a tromino shape. You may rotate these shapes. Given an integer n, return _the number of ways to tile an_ `2 x n` _board_. Since the answer may be very large, return it **modulo** `109 + 7`. In a tiling, every square must be covered by a tile. Two tilings are dif...
Where can the 0 be placed in an ideal permutation? What about the 1?
Array,Math
Medium
null
153
So hello friends, today our dec31 is that is the point minimum in routine solidarity, so what to do in this question, we must have been given solidarity for BSE but in the rotated way, like Gyani here, if our name is late, now in this that Whenever you rotate, please set the app one time and then do comment along with ...
Find Minimum in Rotated Sorted Array
find-minimum-in-rotated-sorted-array
Suppose an array of length `n` sorted in ascending order is **rotated** between `1` and `n` times. For example, the array `nums = [0,1,2,4,5,6,7]` might become: * `[4,5,6,7,0,1,2]` if it was rotated `4` times. * `[0,1,2,4,5,6,7]` if it was rotated `7` times. Notice that **rotating** an array `[a[0], a[1], a[2], ....
Array was originally in ascending order. Now that the array is rotated, there would be a point in the array where there is a small deflection from the increasing sequence. eg. The array would be something like [4, 5, 6, 7, 0, 1, 2]. You can divide the search space into two and see which direction to go. Can you think ...
Array,Binary Search
Medium
33,154
338
Hi guys welcome back to my channel in this video we are going to solve counting mid day one problem of march list in challenge switch problem one and give wealth and exam whose link will be end plus one and its element will be All the numbers from jio to end numbers are there - in the representation, there - in the rep...
Counting Bits
counting-bits
Given an integer `n`, return _an array_ `ans` _of length_ `n + 1` _such that for each_ `i` (`0 <= i <= n`)_,_ `ans[i]` _is the **number of**_ `1`_**'s** in the binary representation of_ `i`. **Example 1:** **Input:** n = 2 **Output:** \[0,1,1\] **Explanation:** 0 --> 0 1 --> 1 2 --> 10 **Example 2:** **Input:** n =...
You should make use of what you have produced already. Divide the numbers in ranges like [2-3], [4-7], [8-15] and so on. And try to generate new range from previous. Or does the odd/even status of the number help you in calculating the number of 1s?
Dynamic Programming,Bit Manipulation
Easy
191
451
so here's the problem liquid 451 sort characters by frequency so problem setting is pretty simple you'll be given a string sort it in descending order based on the frequency of the character the frequency of character is the number of times appears in the Stream so if you see is t r e so descending all right so e comes...
Sort Characters By Frequency
sort-characters-by-frequency
Given a string `s`, sort it in **decreasing order** based on the **frequency** of the characters. The **frequency** of a character is the number of times it appears in the string. Return _the sorted string_. If there are multiple answers, return _any of them_. **Example 1:** **Input:** s = "tree " **Output:** "eer...
null
Hash Table,String,Sorting,Heap (Priority Queue),Bucket Sort,Counting
Medium
347,387,1741
215
hey what's up guys in this video i'm going to go through this elite code 215 okay it's a largest element in an array so let's look at the example in here um we are given an array of numbers so it looks like this and we need to find the largest the second largest number for this example so the largest one is six and the...
Kth Largest Element in an Array
kth-largest-element-in-an-array
Given an integer array `nums` and an integer `k`, return _the_ `kth` _largest element in the array_. Note that it is the `kth` largest element in the sorted order, not the `kth` distinct element. You must solve it in `O(n)` time complexity. **Example 1:** **Input:** nums = \[3,2,1,5,6,4\], k = 2 **Output:** 5 **Ex...
null
Array,Divide and Conquer,Sorting,Heap (Priority Queue),Quickselect
Medium
324,347,414,789,1014,2113,2204,2250
617
hey everyone welcome back and today we will be doing another lead chord problem 617 merge to Binary trees an easy one you are given to binary tree is root 1 and root 2. imagine that when you put one of them to cover the other some of the node of two are overlapped while the others are not you need to merge the two tree...
Merge Two Binary Trees
merge-two-binary-trees
You are given two binary trees `root1` and `root2`. Imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not. You need to merge the two trees into a new binary tree. The merge rule is that if two nodes overlap, then sum node values up as the new valu...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Easy
null
399
Came Trend Quality Tubelight England 27th September Refugee Dega To Problem After That They Division 10 Minutes Facebook Restaurant Problem Share Governor Equation For A Difficult Of Very Interesting And Real Number One Subscribe 0 Key Print Jeweler Tumor June 2012 Decree Will Result In No Division 101 With Dozens of I...
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,481
it is an amazing problem hi guys good morning welcome back to new video it has been asked by JP Morgan a lot Amazon xedia and do let's quickly xedia and do let's quickly xedia and do let's quickly see what the problem says again it's a very good problem it is MZ medium but still it is actually a very good problem the l...
Least Number of Unique Integers after K Removals
students-with-invalid-departments
Given an array of integers `arr` and an integer `k`. Find the _least number of unique integers_ after removing **exactly** `k` elements**.** **Example 1:** **Input:** arr = \[5,5,4\], k = 1 **Output:** 1 **Explanation**: Remove the single 4, only 5 is left. **Example 2:** **Input:** arr = \[4,3,1,1,3,3,2\], k = 3 *...
null
Database
Easy
null
417
today we are solving Pacific Atlantic water flow problem there is an mcross and rectangular Island that borders both the Pacific Ocean and Atlantic Ocean Pacific Ocean touches the islands left and top edges and Atlantic Ocean touches Islands right and bottom edges this island is partitioned into a grid of square cells ...
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
142
hello guys welcome to deep codes and in today's video we will discuss Lead Core question 142 that says linkless cycle 2. so here you are given the height of the link list and we need to return the node where the cycle begins and if there is no cycle simply written null okay so along with the head you are also given one...
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
1,974
Hello Friends Today In This Video Will Be Going Through The Cost Your Problems From The Latest Patience Contest Friends Let's Start The First Problems To Find Out The Minimum Time To Type God Tuition Special Typewriter Health Center Soon Given That You Have A Typewriter With This Object To Apply For Slow ABCD Will Also...
Minimum Time to Type Word Using Special Typewriter
find-customers-with-positive-revenue-this-year
There is a special typewriter with lowercase English letters `'a'` to `'z'` arranged in a **circle** with a **pointer**. A character can **only** be typed if the pointer is pointing to that character. The pointer is **initially** pointing to the character `'a'`. Each second, you may perform one of the following operat...
null
Database
Easy
null
201
hello this time we are going to take a look at question 201 bitwise and of numbers wrench in this question were given a range M in where n is in the range of 0 to 2 1 4 7 4 8 3 6 4 7 I think that's the maximum integer you can get and we have to return the bitwise end of all numbers in this range inclusive to do this we...
Bitwise AND of Numbers Range
bitwise-and-of-numbers-range
Given two integers `left` and `right` that represent the range `[left, right]`, return _the bitwise AND of all numbers in this range, inclusive_. **Example 1:** **Input:** left = 5, right = 7 **Output:** 4 **Example 2:** **Input:** left = 0, right = 0 **Output:** 0 **Example 3:** **Input:** left = 1, right = 2147...
null
Bit Manipulation
Medium
null
54
you remember those problems during your early programming days where you had to print something in form of a star in form of a ladder or something in form of a rectangle right there were so many different patterns and you just experimented with four Loops to get to that answer correct such is a problem available on lea...
Spiral Matrix
spiral-matrix
Given an `m x n` `matrix`, return _all elements of the_ `matrix` _in spiral order_. **Example 1:** **Input:** matrix = \[\[1,2,3\],\[4,5,6\],\[7,8,9\]\] **Output:** \[1,2,3,6,9,8,7,4,5\] **Example 2:** **Input:** matrix = \[\[1,2,3,4\],\[5,6,7,8\],\[9,10,11,12\]\] **Output:** \[1,2,3,4,8,12,11,10,9,5,6,7\] **Const...
Well for some problems, the best way really is to come up with some algorithms for simulation. Basically, you need to simulate what the problem asks us to do. We go boundary by boundary and move inwards. That is the essential operation. First row, last column, last row, first column and then we move inwards by 1 and th...
Array,Matrix,Simulation
Medium
59,921
714
hey everybody this is Larry this is day 22 of the legal Daily Times hit the like button to the Subscribe and join the Discord let me know what you think about today's forum and it seems like it's the classic tradition oh yeah I mean uh Lisbon right now in Portugal uh yeah this is the classic uh buy and sell start with ...
Best Time to Buy and Sell Stock with Transaction Fee
best-time-to-buy-and-sell-stock-with-transaction-fee
You are given an array `prices` where `prices[i]` is the price of a given stock on the `ith` day, and an integer `fee` representing a transaction fee. Find the maximum profit you can achieve. You may complete as many transactions as you like, but you need to pay the transaction fee for each transaction. **Note:** You...
Consider the first K stock prices. At the end, the only legal states are that you don't own a share of stock, or that you do. Calculate the most profit you could have under each of these two cases.
Array,Dynamic Programming,Greedy
Medium
122
417
show you how to solve legal question 417 pacific atlantic water flow it's a median legal question it's also a very classic and uh high frequency question and this is basically they give you an island grid if you look at example here and there's pacific ocean at the italian atlantic ocean and if you look at here pacific...
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
156
hey what's up guys this is sean here so today uh let's take a look at the lead called problem number 156 binary tree upside down so this is not a tree problem you know so you're given like a root of a binary tree and you need to turn the upside turn the tree upside down and return the new root so the way you're turning...
Binary Tree Upside Down
binary-tree-upside-down
Given the `root` of a binary tree, turn the tree upside down and return _the new root_. You can turn a binary tree upside down with the following steps: 1. The original left child becomes the new root. 2. The original root becomes the new right child. 3. The original right child becomes the new left child. The me...
null
Tree,Depth-First Search,Binary Tree
Medium
206
153
all right let's try to solve question number 153 fine minimum in rotated sorted array we're gonna read the question come up with a couple of solutions trying to analyze our solutions and see which one we should code up we probably think about the most optimal solution and that's the one about the P coding up suppose an...
Find Minimum in Rotated Sorted Array
find-minimum-in-rotated-sorted-array
Suppose an array of length `n` sorted in ascending order is **rotated** between `1` and `n` times. For example, the array `nums = [0,1,2,4,5,6,7]` might become: * `[4,5,6,7,0,1,2]` if it was rotated `4` times. * `[0,1,2,4,5,6,7]` if it was rotated `7` times. Notice that **rotating** an array `[a[0], a[1], a[2], ....
Array was originally in ascending order. Now that the array is rotated, there would be a point in the array where there is a small deflection from the increasing sequence. eg. The array would be something like [4, 5, 6, 7, 0, 1, 2]. You can divide the search space into two and see which direction to go. Can you think ...
Array,Binary Search
Medium
33,154
2
hello everyone welcome to day 12 of january lead code challenge and today's question is add two numbers uh it's a simple question we are given you in which you are given two numbers in the form of a linked list the digits are present in the form of a linked list and you need to add those two numbers and return the a ne...
Add Two Numbers
add-two-numbers
You are given two **non-empty** linked lists representing two non-negative integers. The digits are stored in **reverse order**, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list. You may assume the two numbers do not contain any leading zero, except the number 0 ...
null
Linked List,Math,Recursion
Medium
43,67,371,415,445,1031,1774
70
Hello friends welcome back to the PM softic Solutions basically in this session we will going to solve lead code problem number 7 is climbing stairs so without further delay let's go to the dashboard and try to understand the problem statement the statement says that you are climbing a staircase it takes an step to rea...
Climbing Stairs
climbing-stairs
You are climbing a staircase. It takes `n` steps to reach the top. Each time you can either climb `1` or `2` steps. In how many distinct ways can you climb to the top? **Example 1:** **Input:** n = 2 **Output:** 2 **Explanation:** There are two ways to climb to the top. 1. 1 step + 1 step 2. 2 steps **Example 2:** ...
To reach nth step, what could have been your previous steps? (Think about the step sizes)
Math,Dynamic Programming,Memoization
Easy
747,1013,1236
304
welcome back to this video in this video we're going to solve this coordinate equation range sum query to the immutable in this problem given a 2d matrix handle multiple queries of the following type calculate the sum of the element of matrix inside the rectangle defined by its upper left corner row 1 column 1 and lowe...
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
419
hey how you doing guys it's ilya bell here i recorded stuff on youtube share description for all my information i do all legal problems um make sure you subscribe to the channel give me a big thumbs up to support it and this is called bottle soups in the board um unit 2d port count how many bottle sweeps are needed 2d ...
Battleships in a Board
battleships-in-a-board
Given an `m x n` matrix `board` where each cell is a battleship `'X'` or empty `'.'`, return _the number of the **battleships** on_ `board`. **Battleships** can only be placed horizontally or vertically on `board`. In other words, they can only be made of the shape `1 x k` (`1` row, `k` columns) or `k x 1` (`k` rows, ...
null
Array,Depth-First Search,Matrix
Medium
null
157
hey guys how's everything going this is chaser who is not good at algorithms in this video I'm going to take a look at one five eight the read end characters given three four call multiple times or given a file and assume that we can only read the file using before we plan implement a method to reach to read any charac...
Read N Characters Given Read4
read-n-characters-given-read4
Given a `file` and assume that you can only read the file using a given method `read4`, implement a method to read `n` characters. **Method read4:** The API `read4` reads **four consecutive characters** from `file`, then writes those characters into the buffer array `buf4`. The return value is the number of actual c...
null
String,Simulation,Interactive
Easy
158
484
hey what's up guys chung here again so and so this time let's take a look at another list called problem number 484 uh find permutation uh okay so you're given like a secret signature consisting of only character d and i where d representing a decreasing relationship between two numbers and i representing an increasing...
Find Permutation
find-permutation
A permutation `perm` of `n` integers of all the integers in the range `[1, n]` can be represented as a string `s` of length `n - 1` where: * `s[i] == 'I'` if `perm[i] < perm[i + 1]`, and * `s[i] == 'D'` if `perm[i] > perm[i + 1]`. Given a string `s`, reconstruct the lexicographically smallest permutation `perm` a...
null
Array,Stack,Greedy
Medium
null
347
all right this is 347 top K Freon elements and so essentially in this question what's happening is you're given an array nums right and you're also given an integer K and this k um is supposed to determine where you cut off with the Kos elements right so we have three ones two twos and then 1 three and we're only retur...
Top K Frequent Elements
top-k-frequent-elements
Given an integer array `nums` and an integer `k`, return _the_ `k` _most frequent elements_. You may return the answer in **any order**. **Example 1:** **Input:** nums = \[1,1,1,2,2,3\], k = 2 **Output:** \[1,2\] **Example 2:** **Input:** nums = \[1\], k = 1 **Output:** \[1\] **Constraints:** * `1 <= nums.lengt...
null
Array,Hash Table,Divide and Conquer,Sorting,Heap (Priority Queue),Bucket Sort,Counting,Quickselect
Medium
192,215,451,659,692,1014,1919
1,312
Hello everyone welcome to my channel but it is very similar to the diary which we have read till now, it will be very easy, it is ok my I insert the steps, you make a string parallel to the question, who did the question? Amazon Microsoft Google Let's understand the question once. Okay, so in the question you have been...
Minimum Insertion Steps to Make a String Palindrome
count-artifacts-that-can-be-extracted
Given a string `s`. In one step you can insert any character at any index of the string. Return _the minimum number of steps_ to make `s` palindrome. A **Palindrome String** is one that reads the same backward as well as forward. **Example 1:** **Input:** s = "zzazz " **Output:** 0 **Explanation:** The string "zz...
Check if each coordinate of each artifact has been excavated. How can we do this quickly without iterating over the dig array every time? Consider marking all excavated cells in a 2D boolean array.
Array,Hash Table,Simulation
Medium
221
1,665
1665 minimum initial energy to finish tasks so let's first try to understand the problem so we are giving a tasks and inside tasks it going to be sear rate so this subar rate means tasks I means actual I and minimum I yeah so this means initially we have some energy and then for this energy if it is more than the uh mi...
Minimum Initial Energy to Finish Tasks
diameter-of-n-ary-tree
You are given an array `tasks` where `tasks[i] = [actuali, minimumi]`: * `actuali` is the actual amount of energy you **spend to finish** the `ith` task. * `minimumi` is the minimum amount of energy you **require to begin** the `ith` task. For example, if the task is `[10, 12]` and your current energy is `11`, yo...
For the node i, calculate the height of each of its children and keep the first and second maximum heights (max1_i , max2_i). Check all nodes and return max( 2 + max1_i + max2_i ).
Tree,Depth-First Search
Medium
543
459
in this problem we have to check whether the given string is formed by repeating some of the substrings so let's see an example so if you look at this string aba then there is no such substring which you repeat multiple times to form this aba because if you have a then you repeat it multiple times you cannot get a b a ...
Repeated Substring Pattern
repeated-substring-pattern
Given a string `s`, check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. **Example 1:** **Input:** s = "abab " **Output:** true **Explanation:** It is the substring "ab " twice. **Example 2:** **Input:** s = "aba " **Output:** false **Example 3:** ...
null
String,String Matching
Easy
28,686