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
112
Hi gas welcome and welcome back to my channel so today our problem is Parth Sam so what have you given us in this problem statement here we have given the root note of a binary tree and the target is OK what do we have to do with the root In all the paths from the leaked note to the leaked note, if even one path's targ...
Path Sum
path-sum
Given the `root` of a binary tree and an integer `targetSum`, return `true` if the tree has a **root-to-leaf** path such that adding up all the values along the path equals `targetSum`. A **leaf** is a node with no children. **Example 1:** **Input:** root = \[5,4,8,11,null,13,4,7,2,null,null,null,1\], targetSum = 22...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Easy
113,124,129,437,666
40
hi everyone welcome to my channel let's solve the problem combination sum 2 so this is a second problem of the combination sum series i have already video on combination sum and combination sum 3 so if you haven't solve the combination sum problem before attempting this problem i will recommend to solve that problem fi...
Combination Sum II
combination-sum-ii
Given a collection of candidate numbers (`candidates`) and a target number (`target`), find all unique combinations in `candidates` where the candidate numbers sum to `target`. Each number in `candidates` may only be used **once** in the combination. **Note:** The solution set must not contain duplicate combinations....
null
Array,Backtracking
Medium
39
657
hello everyone so in this video let us talk about a very easy and very small code for a problem that is robo return to origin so what the problem statement is that there is a robot starting at the position zero comma zero in a 2d plane okay and the zero comma zero is let's say an origin and there's a 2d plane now what ...
Robot Return to Origin
robot-return-to-origin
There is a robot starting at the position `(0, 0)`, the origin, on a 2D plane. Given a sequence of its moves, judge if this robot **ends up at** `(0, 0)` after it completes its moves. You are given a string `moves` that represents the move sequence of the robot where `moves[i]` represents its `ith` move. Valid moves a...
null
String,Simulation
Easy
547,2239
309
what is up everybody welcome back to my channel this is tony aka one lead code one day if you're new here the channel does one lead code per day following the pattern of topics or series that is i'm going to be solving with you together on a lead code problem i have never attempted before you heard that right there's n...
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
1,696
hi guys welcome to tech geek so today we are back with the daily neet code challenge problem that's jump game six uh that's basically lead code medium one six nine six question before beginning this i'd like to request you all please like share and subscribe to my channel in case of any queries any questions any issues...
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,323
Hi gas welcome and welcome back to my channel so today our problem is maximum number 69 so what has been given to us in this problem statement, here we have been given a positivity in the name of wait in which what is there is only the digits and not those six and Nine is okay, what do we have to do, out of these we ca...
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
1,302
People came to them welcome to the video only coding tips or again problem pain cold play list no more than 120 values ​​for this deep sleep for example values ​​for this deep sleep for example values ​​for this deep sleep for example Video like and Share and subscribe the Channel Please subscribe and subscribe the Thu...
Deepest Leaves Sum
delete-characters-to-make-fancy-string
Given the `root` of a binary tree, return _the sum of values of its deepest leaves_. **Example 1:** **Input:** root = \[1,2,3,4,5,null,6,7,null,null,null,null,8\] **Output:** 15 **Example 2:** **Input:** root = \[6,7,8,2,7,1,3,9,null,1,4,null,null,null,5\] **Output:** 19 **Constraints:** * The number of nodes i...
What's the optimal way to delete characters if three or more consecutive characters are equal? If three or more consecutive characters are equal, keep two of them and delete the rest.
String
Easy
null
452
welcome to Sheba code in this video we will solve a leak code problem in under three minutes the problem is as follows we have a list of number pairs representing Balloons with each pair representing the range on the x-axis representing the range on the x-axis representing the range on the x-axis where the balloon is l...
Minimum Number of Arrows to Burst Balloons
minimum-number-of-arrows-to-burst-balloons
There are some spherical balloons taped onto a flat wall that represents the XY-plane. The balloons are represented as a 2D integer array `points` where `points[i] = [xstart, xend]` denotes a balloon whose **horizontal diameter** stretches between `xstart` and `xend`. You do not know the exact y-coordinates of the ball...
null
Array,Greedy,Sorting
Medium
253,435
211
hi guys so in this video we'll take a look at problem which is related to tri data structure now tri data structure is a quite unique data structure in a way that it's not commonly used like especially in colleges and courses uh we come across data structures like stack linked list queue array and we don't come across ...
Design Add and Search Words Data Structure
design-add-and-search-words-data-structure
Design a data structure that supports adding new words and finding if a string matches any previously added string. Implement the `WordDictionary` class: * `WordDictionary()` Initializes the object. * `void addWord(word)` Adds `word` to the data structure, it can be matched later. * `bool search(word)` Returns ...
You should be familiar with how a Trie works. If not, please work on this problem: Implement Trie (Prefix Tree) first.
String,Depth-First Search,Design,Trie
Medium
208,746
938
hello and welcome back to the cracking fang youtube channel today we're going to be solving leap code problem 938 range sum of a bst let's read the question prompt 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...
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
933
welcome to october's leak code challenge today's problem is number of recent calls you have a recent counter class which counts the number of recent requests within a certain time frame implement the recent counter class now recent counter initialized initializes the counter with zero recent requests and ping adds a ne...
Number of Recent Calls
increasing-order-search-tree
You have a `RecentCounter` class which counts the number of recent requests within a certain time frame. Implement the `RecentCounter` class: * `RecentCounter()` Initializes the counter with zero recent requests. * `int ping(int t)` Adds a new request at time `t`, where `t` represents some time in milliseconds, a...
null
Stack,Tree,Depth-First Search,Binary Search Tree,Binary Tree
Easy
null
1,020
hello and welcome to lead programmer today we are going to solve the question number of enclaves so we have a binary Matrix grid binary Matrix means the Matrix consists of only 0 and 1. here 0 represents a C cell one represents a Lancel now they have defined a move so what's a move so let's say we are at this Lancer so...
Number of Enclaves
longest-turbulent-subarray
You are given an `m x n` binary matrix `grid`, where `0` represents a sea cell and `1` represents a land cell. A **move** consists of walking from one land cell to another adjacent (**4-directionally**) land cell or walking off the boundary of the `grid`. Return _the number of land cells in_ `grid` _for which we cann...
null
Array,Dynamic Programming,Sliding Window
Medium
53
126
hi guys my name is jasmine and today we're going to be taking a look at one of the more challenging lead code problems and it's called word ladder 2. now this problem is an extension of the word ladder problem and they're quite similar but they're a little bit different and we're going to be taking a look at it today s...
Word Ladder II
word-ladder-ii
A **transformation sequence** from word `beginWord` to word `endWord` using a dictionary `wordList` is a sequence of words `beginWord -> s1 -> s2 -> ... -> sk` such that: * Every adjacent pair of words differs by a single letter. * Every `si` for `1 <= i <= k` is in `wordList`. Note that `beginWord` does not need ...
null
Hash Table,String,Backtracking,Breadth-First Search
Hard
127,2276
352
hello everyone let's solve today's lead code problem data stream is disjoint intervals this is a design problem we will have an empty stream when add no method is called we add the input value to the Stream and get intervals method is called we return a list of disjoint intervals start of Y and end of I and it is sorte...
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
417
welcome to march's leeco challenge today's problem is pacific atlantic water flow given an m times n matrix of non-negative integers representing the non-negative integers representing the non-negative integers representing the height of each unit cell in a continent the pacific ocean touches the left and top edges of ...
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
20
hey so welcome back in this another daily code problem so today it was called valid parentheses so this is actually a very popular question it has over 20 000 different upvotes here and so it's an easy level problem that I was actually asked in an interview once um and so you're given a string and you want to return a ...
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
81
hi everyone today we are going to solve the legal problem number 81 that's just a search and be rotated are you part two so in this we are given an array single array which is in which the array elements are rotated by an unknown pivot and if an input array a becomes like this so what we have to do you just have to fin...
Search in Rotated Sorted Array II
search-in-rotated-sorted-array-ii
There is an integer array `nums` sorted in non-decreasing order (not necessarily with **distinct** values). Before being passed to your function, `nums` is **rotated** at an unknown pivot index `k` (`0 <= k < nums.length`) such that the resulting array is `[nums[k], nums[k+1], ..., nums[n-1], nums[0], nums[1], ..., nu...
null
Array,Binary Search
Medium
33
289
Hello Guys Welcome to Vikram Midning Question Thursday subscribe and subscribe the Video then subscribe to The Amazing subscribe The Amazing Hai Turn Off Side Ambrose 10 Meter Defined Variable Mein Nine Administrator Affair Logic In Every Cell Minute And Ho Laharan The Phone To Ajay Send me on number to check fuel pres...
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
201
What the hell, hello, USB CD disk o88 infection does not end. Using a process from the top, especially the cuttings. It is necessary to talk about the most pathetic for the damage I have done in the garden. For example, is it a decision for the 5 people we wet in a restaurant for our martyrs? Angelica Immediately longi...
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
239
everyone welcome back and let's write some more neat code today let's look at a sliding window problem a hard sliding window problem sliding window maximum the statement is pretty straightforward actually so we're given an array of numbers and we also are given a number k which is going to represent the size of our sli...
Sliding Window Maximum
sliding-window-maximum
You are given an array of integers `nums`, there is a sliding window of size `k` which is moving from the very left of the array to the very right. You can only see the `k` numbers in the window. Each time the sliding window moves right by one position. Return _the max sliding window_. **Example 1:** **Input:** nums...
How about using a data structure such as deque (double-ended queue)? The queue size need not be the same as the window’s size. Remove redundant elements and the queue should store only elements that need to be considered.
Array,Queue,Sliding Window,Heap (Priority Queue),Monotonic Queue
Hard
76,155,159,265,1814
154
A Loved One Most Going Student Ko Delhi Silent Point Minimum In Routed Through The Nominated Element Must Subscribe Apps Net Speed ​​Simply Wind Pipe Se ZF Unmute Buddhi Festival Solution Wedding Gift A Title Always Want To Find Out The Most Optimistic Marriage Sutra Click the subscribe button on the right side and sub...
Find Minimum in Rotated Sorted Array II
find-minimum-in-rotated-sorted-array-ii
Suppose an array of length `n` sorted in ascending order is **rotated** between `1` and `n` times. For example, the array `nums = [0,1,4,4,5,6,7]` might become: * `[4,5,6,7,0,1,4]` if it was rotated `4` times. * `[0,1,4,4,5,6,7]` if it was rotated `7` times. Notice that **rotating** an array `[a[0], a[1], a[2], ....
null
Array,Binary Search
Hard
153
1,799
After finishing a small amount of rice, the Ricoh Atlas sound for your interest lists and muscle and operations on the main advantage of Michael cuesta calcium vitamin integration and I want operations in its position with some paper in the one Who uses Advanced nourish Endless Love is integrated time favorite Common d...
Maximize Score After N Operations
minimum-incompatibility
You are given `nums`, an array of positive integers of size `2 * n`. You must perform `n` operations on this array. In the `ith` operation **(1-indexed)**, you will: * Choose two elements, `x` and `y`. * Receive a score of `i * gcd(x, y)`. * Remove `x` and `y` from `nums`. Return _the maximum score you can rec...
The constraints are small enough for a backtrack solution but not any backtrack solution If we use a naive n^k don't you think it can be optimized
Array,Dynamic Programming,Bit Manipulation,Bitmask
Hard
null
814
hey what's up guys it's Nick white here and I do tech encoding stuff on twitch and YouTube and I do all the way code problems so check the description you can find everything that you need about me personally and I do all of these problems so you could check the videos I probably got it up by now I got a ton of them up...
Binary Tree Pruning
smallest-rotation-with-highest-score
Given the `root` of a binary tree, return _the same tree where every subtree (of the given tree) not containing a_ `1` _has been removed_. A subtree of a node `node` is `node` plus every node that is a descendant of `node`. **Example 1:** **Input:** root = \[1,null,0,0,1\] **Output:** \[1,null,0,null,1\] **Explanati...
null
Array,Prefix Sum
Hard
null
219
hello everyone this is kharid and today we are going to solve a legal question called contains duplicate number two so the let's read the problem statement given an integer array norms and an integer K return true if there are two distinct indices I and J in the array such that the value of I is equal to the value of J...
Contains Duplicate II
contains-duplicate-ii
Given an integer array `nums` and an integer `k`, return `true` _if there are two **distinct indices**_ `i` _and_ `j` _in the array such that_ `nums[i] == nums[j]` _and_ `abs(i - j) <= k`. **Example 1:** **Input:** nums = \[1,2,3,1\], k = 3 **Output:** true **Example 2:** **Input:** nums = \[1,0,1,1\], k = 1 **Outp...
null
Array,Hash Table,Sliding Window
Easy
217,220
216
okay this is really the problem 216 is combination three find or validate the combination of k numbers that sum up to so through any staggered number and k is the target length of the subsequence and we need to follow those conditions only number 1 through 9 are used digitally and each number is used at most was writte...
Combination Sum III
combination-sum-iii
Find all valid combinations of `k` numbers that sum up to `n` such that the following conditions are true: * Only numbers `1` through `9` are used. * Each number is used **at most once**. Return _a list of all possible valid combinations_. The list must not contain the same combination twice, and the combinations...
null
Array,Backtracking
Medium
39
886
Hello everyone welcome to my channel so today you may have Flipkart Samsung may have Flipkart Samsung may have Flipkart Samsung Okay let's move ahead so here I have leveled all the people okay and here I have given about their relation okay dislikes van kama 2 1 3 2 4 What does this mean? Dislike van Kama 2 What does i...
Possible Bipartition
score-of-parentheses
We want to split a group of `n` people (labeled from `1` to `n`) into two groups of **any size**. Each person may dislike some other people, and they should not go into the same group. Given the integer `n` and the array `dislikes` where `dislikes[i] = [ai, bi]` indicates that the person labeled `ai` does not like the...
null
String,Stack
Medium
null
455
hey everyone today we are going to solve theal question assign cookies okay so let me explain with this example so G = let me explain with this example so G = let me explain with this example so G = 153 and S = 153 and S = 153 and S = 412 and your goal is to maximize the number of your content children and output the m...
Assign Cookies
assign-cookies
Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child `i` has a greed factor `g[i]`, which is the minimum size of a cookie that the child will be content with; and each cookie `j` has a size `s[j]`. If `s[j] >= g[i]`, we can assign ...
null
Array,Greedy,Sorting
Easy
null
68
hello everyone uh welcome to i'll go pundit today we are going to solve the question number 68 uh text justification so this is a famous question has been asked in the last six months across multiple companies like intu twilo uber amazon so this is a very famous questions and it's been categorized as a hard question so...
Text Justification
text-justification
Given an array of strings `words` and a width `maxWidth`, format the text such that each line has exactly `maxWidth` characters and is fully (left and right) justified. You should pack your words in a greedy approach; that is, pack as many words as you can in each line. Pad extra spaces `' '` when necessary so that ea...
null
Array,String,Simulation
Hard
1714,2260
343
hello i don't have a name but you can call me now and today i would like to talk about the third dynamic programming practice question integer break in this question we'll have an integer of the inputs and we need to break this integer into certain parts for example 10 can we break into 3 and 4 because the sum is 10 an...
Integer Break
integer-break
Given an integer `n`, break it into the sum of `k` **positive integers**, where `k >= 2`, and maximize the product of those integers. Return _the maximum product you can get_. **Example 1:** **Input:** n = 2 **Output:** 1 **Explanation:** 2 = 1 + 1, 1 \* 1 = 1. **Example 2:** **Input:** n = 10 **Output:** 36 **Exp...
There is a simple O(n) solution to this problem. You may check the breaking results of n ranging from 7 to 10 to discover the regularities.
Math,Dynamic Programming
Medium
1936
647
has been asked by Facebook Goodman Sachs Amazon arobi Apple C Google Bloom Cisco xedia auna Capital Microsoft wmart Labs work day LinkedIn and so many companies hi guys good morning welcome back to a new video in this wey PR palic substring now the folks who will watch the full video can please skip the next 5 seconds ...
Palindromic Substrings
palindromic-substrings
Given a string `s`, return _the number of **palindromic substrings** in it_. A string is a **palindrome** when it reads the same backward as forward. A **substring** is a contiguous sequence of characters within the string. **Example 1:** **Input:** s = "abc " **Output:** 3 **Explanation:** Three palindromic strin...
How can we reuse a previously computed palindrome to compute a larger palindrome? If “aba” is a palindrome, is “xabax” and 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 - en...
String,Dynamic Programming
Medium
5,516
315
you guys this is your house everything go in this video I'm going to take a look at three one five counts of small numbers after self we're given an integer array and I have to return a new account array the count already has a property where each element is number of smaller elements to write up itself like five to si...
Count of Smaller Numbers After Self
count-of-smaller-numbers-after-self
Given an integer array `nums`, return _an integer array_ `counts` _where_ `counts[i]` _is the number of smaller elements to the right of_ `nums[i]`. **Example 1:** **Input:** nums = \[5,2,6,1\] **Output:** \[2,1,1,0\] **Explanation:** To the right of 5 there are **2** smaller elements (2 and 1). To the right of 2 the...
null
Array,Binary Search,Divide and Conquer,Binary Indexed Tree,Segment Tree,Merge Sort,Ordered Set
Hard
327,406,493,1482,2280
1,675
hey everybody this is larry this is day 19 of the leco february daily challenge hit the like button hit the subscribe button do join me in discord let me know what you think oh i got a brief spot okay today's problem is minimize deviation in a way um i'm still i'm in colombia's uh katahina so i've been not gonna lie i'...
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
41
hi friends welcome back today we are going to solve lint code problem 189 first missing positive uh before we start looking the details of this problem i just want to mention that i often create lead code coding solutions in java as well as java jet we interview helpful material videos uh where we discuss you know freq...
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
899
all right guys welcome to our channel code with sunny and in this video i will be talking about the problem orderly queue its index is eight double line and uh it is the hard type problem for you okay so we have been given a string s and an integer k and we can choose one of the first k letters of the string s that is ...
Orderly Queue
binary-gap
You are given a string `s` and an integer `k`. You can choose one of the first `k` letters of `s` and append it at the end of the string.. Return _the lexicographically smallest string you could have after applying the mentioned step any number of moves_. **Example 1:** **Input:** s = "cba ", k = 1 **Output:** "ac...
null
Math,Bit Manipulation
Easy
null
1,015
hey what's up guys this is chung here so let's take quickly look at today's daily challenge problem number 1015 smallest integer divisible by k so here's a description you're given like a positive integer k and you need to find the length of the smallest the length of the small is the positive integer n such that n is ...
Smallest Integer Divisible by K
smallest-integer-divisible-by-k
Given a positive integer `k`, you need to find the **length** of the **smallest** positive integer `n` such that `n` is divisible by `k`, and `n` only contains the digit `1`. Return _the **length** of_ `n`. If there is no such `n`, return -1. **Note:** `n` may not fit in a 64-bit signed integer. **Example 1:** **In...
null
null
Medium
null
161
give given two strings s and t return true if they are both one edit distance apart otherwise return false so what does it mean what edit distance it means if we make only one change in s we get it equal to t so and what is that one change it can be an insert or delete or replace let's go through some examples so you c...
One Edit Distance
one-edit-distance
Given two strings `s` and `t`, return `true` if they are both one edit distance apart, otherwise return `false`. A string `s` is said to be one distance apart from a string `t` if you can: * Insert **exactly one** character into `s` to get `t`. * Delete **exactly one** character from `s` to get `t`. * Replace *...
null
Two Pointers,String
Medium
72
234
palindrome linked list keep the height of a single linked list return true if it is palindrome or false otherwise we have example one two one so it's the same if we read uh from this direction and this one is not palindrome because this direction is 1 2 this direction is 2. so for this question I'm gonna use separate s...
Palindrome Linked List
palindrome-linked-list
Given the `head` of a singly linked list, return `true` _if it is a_ _palindrome_ _or_ `false` _otherwise_. **Example 1:** **Input:** head = \[1,2,2,1\] **Output:** true **Example 2:** **Input:** head = \[1,2\] **Output:** false **Constraints:** * The number of nodes in the list is in the range `[1, 105]`. * ...
null
Linked List,Two Pointers,Stack,Recursion
Easy
9,125,206,2236
833
hello friends and now let's do a simple question funny replaced industry to some strands will perform some replacements operation catcher plays rook of letters with new ones not necessary until it's M stars actually this is the tricky part of this product each row represents operation has three parameters are starting ...
Find And Replace in String
bus-routes
You are given a **0-indexed** string `s` that you must perform `k` replacement operations on. The replacement operations are given as three **0-indexed** parallel arrays, `indices`, `sources`, and `targets`, all of length `k`. To complete the `ith` replacement operation: 1. Check if the **substring** `sources[i]` oc...
null
Array,Hash Table,Breadth-First Search
Hard
null
813
hey everybody this is Larry this is me going to do an extra question for today I actually need to go out and get food so I'm going to just pick a medium for today I have a lot of medium problems anyway so yeah uh hit the like button hit the Subscribe button join me on Discord let me know what you think about today's me...
Largest Sum of Averages
all-paths-from-source-to-target
You are given an integer array `nums` and an integer `k`. You can partition the array into **at most** `k` non-empty adjacent subarrays. The **score** of a partition is the sum of the averages of each subarray. Note that the partition must use every integer in `nums`, and that the score is not necessarily an integer. ...
null
Backtracking,Depth-First Search,Breadth-First Search,Graph
Medium
2090
56
one so today we are looking at leap code number 56 it is a question called merge intervals and this is like i think this is probably one of the most popular questions on leap code you can see it's got 7 000 likes but if we jump down here you know i mean it's just asked all the time everywhere um last six months to a ye...
Merge Intervals
merge-intervals
Given an array of `intervals` where `intervals[i] = [starti, endi]`, merge all overlapping intervals, and return _an array of the non-overlapping intervals that cover all the intervals in the input_. **Example 1:** **Input:** intervals = \[\[1,3\],\[2,6\],\[8,10\],\[15,18\]\] **Output:** \[\[1,6\],\[8,10\],\[15,18\]\...
null
Array,Sorting
Medium
57,252,253,495,616,715,761,768,1028,2297,2319
118
given a nun active integer k how do you design an algorithm to return the first K rows of a Pascal's triangle that's about today's video last time this is where my dream started hi everyone this is Steve here and today we are going through another very classic interview question which is leave : interview question whic...
Pascal's Triangle
pascals-triangle
Given an integer `numRows`, return the first numRows of **Pascal's triangle**. In **Pascal's triangle**, each number is the sum of the two numbers directly above it as shown: **Example 1:** **Input:** numRows = 5 **Output:** \[\[1\],\[1,1\],\[1,2,1\],\[1,3,3,1\],\[1,4,6,4,1\]\] **Example 2:** **Input:** numRows = ...
null
Array,Dynamic Programming
Easy
119
524
hello everyone so today we are going to cover longest word in dictionary brutality so we are given an input of a string yes and a list of strings d and we have to return the maximum size of a word that can be formed from the string yes that is present in the list dictionary t so how do we do it let's understand this pr...
Longest Word in Dictionary through Deleting
longest-word-in-dictionary-through-deleting
Given a string `s` and a string array `dictionary`, return _the longest string in the dictionary that can be formed by deleting some of the given string characters_. If there is more than one possible result, return the longest word with the smallest lexicographical order. If there is no possible result, return the emp...
null
Array,Two Pointers,String,Sorting
Medium
720
1,935
Hello Hi Friends Welcome Back Together Into Solitude Problem 1935 Maximum Number Of But You Can Type So You Common Adopting No Data Open Create Videos Related To Javra To Interview Aa Material Edit Solution Singh Jawak So Iodine Is Point Ko Dissolution School 6065 Problems Old And Explain To Please take a look on this ...
Maximum Number of Words You Can Type
minimum-number-of-operations-to-reinitialize-a-permutation
There is a malfunctioning keyboard where some letter keys do not work. All other keys on the keyboard work properly. Given a string `text` of words separated by a single space (no leading or trailing spaces) and a string `brokenLetters` of all **distinct** letter keys that are broken, return _the **number of words** i...
It is safe to assume the number of operations isn't more than n The number is small enough to apply a brute force solution.
Array,Math,Simulation
Medium
null
1,416
hey everybody this is Larry this is day 23 of the uh what month this is April legal daily challenge hit the like button hit the Subscribe button join my Discord uh let me know what you think about this Farm uh for those of you celebrating uh do you say happy while I'm done I don't know I feel like I'm always like messi...
Restore The Array
check-if-an-array-is-consecutive
A program was supposed to print an array of integers. The program forgot to print whitespaces and the array is printed as a string of digits `s` and all we know is that all integers in the array were in the range `[1, k]` and there are no leading zeros in the array. Given the string `s` and the integer `k`, return _th...
Try sorting nums. If nums is consecutive and sorted in ascending order, then nums[i] + 1 = nums[i + 1] for every i in the range 0 ≤ i < nums.length - 1.
Array
Easy
298,549,1542
207
hey everyone welcome back today we are going to solve problem number 207 course schedule first we will see the explanation of the problem statement then the logic on the core now let's dive into the solution so in this problem we have number of courses so in this input we have four courses and we have a prerequisite 2D...
Course Schedule
course-schedule
There are a total of `numCourses` courses you have to take, labeled from `0` to `numCourses - 1`. You are given an array `prerequisites` where `prerequisites[i] = [ai, bi]` indicates that you **must** take course `bi` first if you want to take course `ai`. * For example, the pair `[0, 1]`, indicates that to take cou...
This problem is equivalent to finding if a cycle exists in a directed graph. If a cycle exists, no topological ordering exists and therefore it will be impossible to take all courses. Topological Sort via DFS - A great video tutorial (21 minutes) on Coursera explaining the basic concepts of Topological Sort. Topologica...
Depth-First Search,Breadth-First Search,Graph,Topological Sort
Medium
210,261,310,630
1,222
all right so hello again here we are let's keep going doing more problems let's take a moment to make sure the audio is working pop out the chat in a second work on next question is going to be queens that can more problems let's take a moment to make sure means I can attack the king uh number 1222 okay have to forgive...
Queens That Can Attack the King
remove-covered-intervals
On a **0-indexed** `8 x 8` chessboard, there can be multiple black queens ad one white king. You are given a 2D integer array `queens` where `queens[i] = [xQueeni, yQueeni]` represents the position of the `ith` black queen on the chessboard. You are also given an integer array `king` of length `2` where `king = [xKing...
How to check if an interval is covered by another? Compare each interval to all others and check if it is covered by any interval.
Array,Sorting
Medium
null
392
all right this league code question is called is subsequence I'm not sure if it's pronounced subsequence or a subsequent so I apologize in advance if I go back and forth between those two all right it says given a string s and a string T check if s is a subsequence of T you may assume that there is only lowercase Engli...
Is Subsequence
is-subsequence
Given two strings `s` and `t`, return `true` _if_ `s` _is a **subsequence** of_ `t`_, or_ `false` _otherwise_. A **subsequence** of a string is a new string that is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (i...
null
Two Pointers,String,Dynamic Programming
Easy
808,1051
1,759
let's solve the today's lead code challenge which is Count number of homogeneous substrings so in this problem we are given a string s and we have to find the number of homogeneous substring of s so what is the homogeneous substring uh any string is called homogeneous if all the characters of the string are same for ex...
Count Number of Homogenous Substrings
find-the-missing-ids
Given a string `s`, return _the number of **homogenous** substrings of_ `s`_._ Since the answer may be too large, return it **modulo** `109 + 7`. A string is **homogenous** if all the characters of the string are the same. A **substring** is a contiguous sequence of characters within a string. **Example 1:** **Inpu...
null
Database
Medium
1357,1420,1467
127
foreign word letter welcome to my video let us begin in this problem we are given a starting word from which we are to reach an ending word in a series of Single Character switches using words from a given list all words must be of equal length in this method we will set up a graph of all the words in the given list th...
Word Ladder
word-ladder
A **transformation sequence** from word `beginWord` to word `endWord` using a dictionary `wordList` is a sequence of words `beginWord -> s1 -> s2 -> ... -> sk` such that: * Every adjacent pair of words differs by a single letter. * Every `si` for `1 <= i <= k` is in `wordList`. Note that `beginWord` does not need ...
null
Hash Table,String,Breadth-First Search
Hard
126,433
1,423
Hello guys welcome to another video desi of wedding ude abir volume ko maximum points are given from quartz use subscribe thank you solve 123 subscribe 428 voter card maximum maximize your first look a beneficial planets account from the end again in special fruit also Din Tune Pic Whose Twitter The Channel Possible So...
Maximum Points You Can Obtain from Cards
maximum-number-of-occurrences-of-a-substring
There are several cards **arranged in a row**, and each card has an associated number of points. The points are given in the integer array `cardPoints`. In one step, you can take one card from the beginning or from the end of the row. You have to take exactly `k` cards. Your score is the sum of the points of the card...
Check out the constraints, (maxSize <=26). This means you can explore all substrings in O(n * 26). Find the Maximum Number of Occurrences of a Substring with bruteforce.
Hash Table,String,Sliding Window
Medium
null
1,690
So hello friends welcome back and in this video are going to see in the amazing problem express train china 768 toll free contact no in toilet saaf baje gym witch direction places baba play list subscribe button subscribe like and subscribe mean that subscribe assigned sleep Open play store that triad to some thing pos...
Stone Game VII
maximum-length-of-subarray-with-positive-product
Alice and Bob take turns playing a game, with **Alice starting first**. There are `n` stones arranged in a row. On each player's turn, they can **remove** either the leftmost stone or the rightmost stone from the row and receive points equal to the **sum** of the remaining stones' values in the row. The winner is the ...
Split the whole array into subarrays by zeroes since a subarray with positive product cannot contain any zero. If the subarray has even number of negative numbers, the whole subarray has positive product. Otherwise, we have two choices, either - remove the prefix till the first negative element in this subarray, or rem...
Array,Dynamic Programming,Greedy
Medium
null
743
hello everyone welcome to day 14 of lead code my challenge today we have question number 743 network delay time so in this question they have given us a network of n node labeled from 1 to n and we are also given times a list of travel times as directed edges u v and w where u is the source node v is the target node an...
Network Delay Time
closest-leaf-in-a-binary-tree
You are given a network of `n` nodes, labeled from `1` to `n`. You are also given `times`, a list of travel times as directed edges `times[i] = (ui, vi, wi)`, where `ui` is the source node, `vi` is the target node, and `wi` is the time it takes for a signal to travel from source to target. We will send a signal from a...
Convert the tree to a general graph, and do a breadth-first search. Alternatively, find the closest leaf for every node on the path from root to target.
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Medium
null
1
so in this video I want to do a coding interview problem I usually code to do problem solving because I feel like it's a really great website and has a lot of great problems that are given in interviews so that's why I usually code I also use Packer rank and others so I wanted to show you guys a problem and how I solve...
Two Sum
two-sum
Given an array of integers `nums` and an integer `target`, return _indices of the two numbers such that they add up to `target`_. You may assume that each input would have **_exactly_ one solution**, and you may not use the _same_ element twice. You can return the answer in any order. **Example 1:** **Input:** nums...
A really brute force way would be to search for all possible pairs of numbers but that would be too slow. Again, it's best to try out brute force solutions for just for completeness. It is from these brute force solutions that you can come up with optimizations. So, if we fix one of the numbers, say x, we have to scan ...
Array,Hash Table
Easy
15,18,167,170,560,653,1083,1798,1830,2116,2133,2320
983
hello everyone welcome to another one of my lead code videos and this one we'll do lead code 983 minimum cost for tickets this is today's daily challenge so we're basically given two arrays one is the number of days we want to travel or the days we want to travel and the other one is the cost which is basically the cos...
Minimum Cost For Tickets
validate-stack-sequences
You have planned some train traveling one year in advance. The days of the year in which you will travel are given as an integer array `days`. Each day is an integer from `1` to `365`. Train tickets are sold in **three different ways**: * a **1-day** pass is sold for `costs[0]` dollars, * a **7-day** pass is sold...
null
Array,Stack,Simulation
Medium
null
472
hello guys welcome to deep codes in today's video we will discuss lead code question four to seven that says concatenated words so here we are given one idea of string words without duplicates and we need to detect all concrete or concatenated words so the definition of this concatenated word is any string that is comp...
Concatenated Words
concatenated-words
Given an array of strings `words` (**without duplicates**), return _all the **concatenated words** in the given list of_ `words`. A **concatenated word** is defined as a string that is comprised entirely of at least two shorter words (not necesssarily distinct) in the given array. **Example 1:** **Input:** words = \...
null
Array,String,Dynamic Programming,Depth-First Search,Trie
Hard
140
131
hey everyone welcome back to the channel i hope you guys are doing extremely well so today we will be solving the problem palindrome partitioning from the sd sheet but before we move on to the problem if you guys are new to our channel please do consider subscribing to our channel so the problem states that you'll be g...
Palindrome Partitioning
palindrome-partitioning
Given a string `s`, partition `s` such that every substring of the partition is a **palindrome**. Return _all possible palindrome partitioning of_ `s`. **Example 1:** **Input:** s = "aab" **Output:** \[\["a","a","b"\],\["aa","b"\]\] **Example 2:** **Input:** s = "a" **Output:** \[\["a"\]\] **Constraints:** * `1...
null
String,Dynamic Programming,Backtracking
Medium
132,1871
63
Good Salary Channel Talk Etc Poverty Shrink Interview Questions Video Apps Sexual Exploitation Unique And Will Not Get subscribe The Channel Please subscribe this Video plz subscribe Channel Please subscribe and subscribe the Channel subscribe Video Subscribe Ca n't To Subscribe Online Reader Right Corner Notice Subscr...
Unique Paths II
unique-paths-ii
You are given an `m x n` integer array `grid`. There is a robot initially located at the **top-left corner** (i.e., `grid[0][0]`). The robot tries to move to the **bottom-right corner** (i.e., `grid[m - 1][n - 1]`). The robot can only move either down or right at any point in time. An obstacle and space are marked as ...
The robot can only move either down or right. Hence any cell in the first row can only be reached from the cell left to it. However, if any cell has an obstacle, you don't let that cell contribute to any path. So, for the first row, the number of ways will simply be if obstacleGrid[i][j] is not an obstacle ...
Array,Dynamic Programming,Matrix
Medium
62,1022
1,361
Hello everyone welcome to my channel Quote Surrey with Mike So today we are going to do video number 37 of the playlist of graphs, okay my playlist of graphs and concept and questions you can try if you want to understand the graph from the very basic medium level. The question is lead code number is 1361 but it is a v...
Validate Binary Tree Nodes
tiling-a-rectangle-with-the-fewest-squares
You have `n` binary tree nodes numbered from `0` to `n - 1` where node `i` has two children `leftChild[i]` and `rightChild[i]`, return `true` if and only if **all** the given nodes form **exactly one** valid binary tree. If node `i` has no left child then `leftChild[i]` will equal `-1`, similarly for the right child. ...
Can you use backtracking to solve this problem ?. Suppose you've placed a bunch of squares. Where is the natural spot to place the next square ?. The maximum number of squares to be placed will be ≤ max(n,m).
Dynamic Programming,Backtracking
Hard
null
663
Ajay Ko That Welcome back friends today they are going to solve liquid problem 864 sequential partition this problem Oscar Amazon India first interview sass you can see this year will also discuss about this problem and solution so if you have already subscribe To My Channel Please subscribe To My Channel Nav My Channe...
Equal Tree Partition
equal-tree-partition
Given the `root` of a binary tree, return `true` _if you can partition the tree into two trees with equal sums of values after removing exactly one edge on the original tree_. **Example 1:** **Input:** root = \[5,10,10,null,null,2,3\] **Output:** true **Example 2:** **Input:** root = \[1,2,10,null,null,2,20\] **Out...
null
Tree,Depth-First Search,Binary Tree
Medium
null
520
hi guys welcome to algorithms made easy today we will go through the day one problem from the oversleed coding challenge detect capital please like the video and if you are new don't forget to subscribe to our channel so that you never miss any update given a word you need to judge whether the usage of capitals in it i...
Detect Capital
detect-capital
We define the usage of capitals in a word to be right when one of the following cases holds: * All letters in this word are capitals, like `"USA "`. * All letters in this word are not capitals, like `"leetcode "`. * Only the first letter in this word is capital, like `"Google "`. Given a string `word`, return `...
null
String
Easy
2235
448
arrays are a fantastic data structure not only are they easy to visualize and understand but they also give you two pieces of information the value and the index of that value sometimes these indices can help you to write an efficient solution to a problem i am talking about the problem find the disappearing numbers in...
Find All Numbers Disappeared in an Array
find-all-numbers-disappeared-in-an-array
Given an array `nums` of `n` integers where `nums[i]` is in the range `[1, n]`, return _an array of all the integers in the range_ `[1, n]` _that do not appear in_ `nums`. **Example 1:** **Input:** nums = \[4,3,2,7,8,2,3,1\] **Output:** \[5,6\] **Example 2:** **Input:** nums = \[1,1\] **Output:** \[2\] **Constrain...
This is a really easy problem if you decide to use additional memory. For those trying to write an initial solution using additional memory, think counters! However, the trick really is to not use any additional space than what is already available to use. Sometimes, multiple passes over the input array help find the s...
Array,Hash Table
Easy
41,442,2107,2305
207
welcome to my channel so in this video i'm going to cover uh the solution to this question and also at the same time i'm going to briefly go through the general steps we should follow in the real quick interview so we are going to solve this problem and do some live coding here and we are also going to cover the proced...
Course Schedule
course-schedule
There are a total of `numCourses` courses you have to take, labeled from `0` to `numCourses - 1`. You are given an array `prerequisites` where `prerequisites[i] = [ai, bi]` indicates that you **must** take course `bi` first if you want to take course `ai`. * For example, the pair `[0, 1]`, indicates that to take cou...
This problem is equivalent to finding if a cycle exists in a directed graph. If a cycle exists, no topological ordering exists and therefore it will be impossible to take all courses. Topological Sort via DFS - A great video tutorial (21 minutes) on Coursera explaining the basic concepts of Topological Sort. Topologica...
Depth-First Search,Breadth-First Search,Graph,Topological Sort
Medium
210,261,310,630
1,828
guys welcome to my uh reconstructing session 1828 curious our number of points in that circle so you are given array with point i x i y is according it's the eyes burning until the planes uh viewers are subscribed to my channel okay so multiple points can have the same coordinate nicer you're also given a regular qr j ...
Queries on Number of Points Inside a Circle
count-ways-to-distribute-candies
You are given an array `points` where `points[i] = [xi, yi]` is the coordinates of the `ith` point on a 2D plane. Multiple points can have the **same** coordinates. You are also given an array `queries` where `queries[j] = [xj, yj, rj]` describes a circle centered at `(xj, yj)` with a radius of `rj`. For each query `...
Try to define a recursive approach. For the ith candies, there will be one of the two following cases: If the i - 1 previous candies are already distributed into k bags for the ith candy, you can have k * dp[n - 1][k] ways to distribute the ith candy. We need then to solve the state of (n - 1, k). If the i - 1 previous...
Dynamic Programming
Hard
null
848
Hello friends, in today's video we are going to discuss this plate problem shifting is the latest problem of yours, which team has given you SDO and cigarette friends, the interior has been tested and both casting gas and stuck SIM are written by the author and you have a separation. Will tell you what operation means,...
Shifting Letters
shifting-letters
You are given a string `s` of lowercase English letters and an integer array `shifts` of the same length. Call the `shift()` of a letter, the next letter in the alphabet, (wrapping around so that `'z'` becomes `'a'`). * For example, `shift('a') = 'b'`, `shift('t') = 'u'`, and `shift('z') = 'a'`. Now for each `shif...
null
null
Medium
null
1,721
hi today we are going to look at problem 17 21 swapping nodes in a linked list so we are given here of a linked list and an integer k and we have to return the head of the linked list after swapping the values of the kth node from the beginning of the linked list and case node from the end of the linked list and the li...
Swapping Nodes in a Linked List
maximum-profit-of-operating-a-centennial-wheel
You are given the `head` of a linked list, and an integer `k`. Return _the head of the linked list after **swapping** the values of the_ `kth` _node from the beginning and the_ `kth` _node from the end (the list is **1-indexed**)._ **Example 1:** **Input:** head = \[1,2,3,4,5\], k = 2 **Output:** \[1,4,3,2,5\] **Ex...
Think simulation Note that the number of turns will never be more than 50 / 4 * n
Array,Simulation
Medium
null
100
hey yo what's up my little coders let me show you in this tutorial how to solve the lethal question 100 same three basically given two binary trees we need to say if they are the same or not and two binary trees are considered the same if they are structurally identical and the nodes have the same value here are some e...
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
495
hey guys welcome back to my channel and i'm back again with another really interesting coding interview question video this time guys we are going to solve question number 495 teemo attacking in lead code before i start with the video guys if you have not yet subscribed to my channel then please do subscribe and hit th...
Teemo Attacking
teemo-attacking
Our hero Teemo is attacking an enemy Ashe with poison attacks! When Teemo attacks Ashe, Ashe gets poisoned for a exactly `duration` seconds. More formally, an attack at second `t` will mean Ashe is poisoned during the **inclusive** time interval `[t, t + duration - 1]`. If Teemo attacks again **before** the poison effe...
null
Array,Simulation
Easy
56,605,649
1,825
hello everyone let's take a look at the code 1825 it's the last question in the weekly contest and it's a hard problem and also it's a hard problem but it's not that hard it's just very complex since you may need a lot of coding and you mean to debug a lot okay let's take a look uh so if you haven't used this problem y...
Finding MK Average
find-minimum-time-to-finish-all-jobs
You are given two integers, `m` and `k`, and a stream of integers. You are tasked to implement a data structure that calculates the **MKAverage** for the stream. The **MKAverage** can be calculated using these steps: 1. If the number of the elements in the stream is less than `m` you should consider the **MKAverage*...
We can select a subset of tasks and assign it to a worker then solve the subproblem on the remaining tasks
Array,Dynamic Programming,Backtracking,Bit Manipulation,Bitmask
Hard
2114
974
I will be discussing this solution to Lead Core problem number 974 Subaru is something divisible by K so in this problem you are given an array you have to find the number of sub arrays whose sum will be divisible by K so what is the sub array a sub array is a continuous portion of an array so in this example Phi Teres...
Subarray Sums Divisible by K
reorder-data-in-log-files
Given an integer array `nums` and an integer `k`, return _the number of non-empty **subarrays** that have a sum divisible by_ `k`. A **subarray** is a **contiguous** part of an array. **Example 1:** **Input:** nums = \[4,5,0,-2,-3,1\], k = 5 **Output:** 7 **Explanation:** There are 7 subarrays with a sum divisible b...
null
Array,String,Sorting
Easy
null
1,624
so hello everyone and a very good afternoon to all of you so today we have a new problem which name is largest service string between two equal characters lead code 1624 problem so before going forther in this video please make sure that you have likeed and subscribe to this Channel and also it's my advice to all of yo...
Largest Substring Between Two Equal Characters
clone-binary-tree-with-random-pointer
Given a string `s`, return _the length of the longest substring between two equal characters, excluding the two characters._ If there is no such substring return `-1`. A **substring** is a contiguous sequence of characters within a string. **Example 1:** **Input:** s = "aa " **Output:** 0 **Explanation:** The optim...
Traverse the tree, keep a hashtable with you and create a nodecopy for each node in the tree. Start traversing the original tree again and connect the left, right and random pointers in the cloned tree the same way as the original tree with the help of the hashtable.
Hash Table,Tree,Depth-First Search,Breadth-First Search,Binary Tree
Medium
133,138,1634
509
hello coding enthusiasts welcome back to another exciting episode on called Master Quest today we are stepping into the captivating world of Fibonacci numbers and as you may notice the classical problem in computer science to demonstrate the use of recursive function right so let's get started and find a question descr...
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
478
Hello everyone! This is the LeadCode problem&nbsp; "Generate Random Points in a Circle".&nbsp;&nbsp; Given the radius and x,y positions of the&nbsp; center of the circle, write a function to&nbsp;&nbsp; generate a uniform random point in the circle.&nbsp; Input and Output values are in floating point;&nbsp;&nbsp; A poi...
Generate Random Point in a Circle
generate-random-point-in-a-circle
Given the radius and the position of the center of a circle, implement the function `randPoint` which generates a uniform random point inside the circle. Implement the `Solution` class: * `Solution(double radius, double x_center, double y_center)` initializes the object with the radius of the circle `radius` and th...
null
null
Medium
null
166
hi Ricky here this is little to question number 166 fraction to the croissant isomer this is an idiom difficult question asked at it keep it integer representing them numerator and denominator of a fraction returned a fraction in stream comment if the fraction part is repeating enclose the repeating part in classes oka...
Fraction to Recurring Decimal
fraction-to-recurring-decimal
Given two integers representing the `numerator` and `denominator` of a fraction, return _the fraction in string format_. If the fractional part is repeating, enclose the repeating part in parentheses. If multiple answers are possible, return **any of them**. It is **guaranteed** that the length of the answer string ...
No scary math, just apply elementary math knowledge. Still remember how to perform a long division? Try a long division on 4/9, the repeating part is obvious. Now try 4/333. Do you see a pattern? Notice that once the remainder starts repeating, so does the divided result. Be wary of edge cases! List out as many test ca...
Hash Table,Math,String
Medium
null
73
all right hello welcome back to my Channel today we are going to talk about political problems 73 set Matrix zeros so this is a very popular problem it is a former blind simplified list yeah I hope you can enjoy this question I'm going to use two methods so because this is a in place you must do it in place yeah so it ...
Set Matrix Zeroes
set-matrix-zeroes
Given an `m x n` integer matrix `matrix`, if an element is `0`, set its entire row and column to `0`'s. You must do it [in place](https://en.wikipedia.org/wiki/In-place_algorithm). **Example 1:** **Input:** matrix = \[\[1,1,1\],\[1,0,1\],\[1,1,1\]\] **Output:** \[\[1,0,1\],\[0,0,0\],\[1,0,1\]\] **Example 2:** **In...
If any cell of the matrix has a zero we can record its row and column number using additional memory. But if you don't want to use extra memory then you can manipulate the array instead. i.e. simulating exactly what the question says. Setting cell values to zero on the fly while iterating might lead to discrepancies. ...
Array,Hash Table,Matrix
Medium
289,2244,2259,2314
133
That's guys welcome to my channel in this video they are going to discuss playlist to problem number 133 clove husband solve question in the president new to our channel subscribe that they give no reference above no dinner connected and directed graph to please note The graph is connected native under its return of th...
Clone Graph
clone-graph
Given a reference of a node in a **[connected](https://en.wikipedia.org/wiki/Connectivity_(graph_theory)#Connected_graph)** undirected graph. Return a [**deep copy**](https://en.wikipedia.org/wiki/Object_copying#Deep_copy) (clone) of the graph. Each node in the graph contains a value (`int`) and a list (`List[Node]`)...
null
Hash Table,Depth-First Search,Breadth-First Search,Graph
Medium
138,1624,1634
217
okay guys let's solve 217 contains duplicate so we are given an integer array nums and we want to return true if any value appears at least twice in the array and we want to return false if every element is distinct okay so in the nums array of one 2 3 1 well clearly there is two ones and so a number appears at least t...
Contains Duplicate
contains-duplicate
Given an integer array `nums`, return `true` if any value appears **at least twice** in the array, and return `false` if every element is distinct. **Example 1:** **Input:** nums = \[1,2,3,1\] **Output:** true **Example 2:** **Input:** nums = \[1,2,3,4\] **Output:** false **Example 3:** **Input:** nums = \[1,1,1,...
null
Array,Hash Table,Sorting
Easy
219,220
1,695
hey everybody this is larry this is me going with q2 of the weekly contest 220 lead code uh maximum erase eurasia value so hit the like button hit the subscribe button join me on discord let me know what you think about this farm and just in general i'm gonna go over my thought process as well as the solution during th...
Maximum Erasure Value
maximum-sum-obtained-of-any-permutation
You are given an array of positive integers `nums` and want to erase a subarray containing **unique elements**. The **score** you get by erasing the subarray is equal to the **sum** of its elements. Return _the **maximum score** you can get by erasing **exactly one** subarray._ An array `b` is called to be a subarray...
Indexes with higher frequencies should be bound with larger values
Array,Greedy,Sorting,Prefix Sum
Medium
null
63
That hey guys welcome back to my channel in this video will go into solve unifil amit jeevan kya hai aapka admin to end de raha hai and it is said that you have a robot on the top left corner i.e. at 80 you have a robot on the top left corner i.e. at 80 you have a robot on the top left corner i.e. at 80 and this note i...
Unique Paths II
unique-paths-ii
You are given an `m x n` integer array `grid`. There is a robot initially located at the **top-left corner** (i.e., `grid[0][0]`). The robot tries to move to the **bottom-right corner** (i.e., `grid[m - 1][n - 1]`). The robot can only move either down or right at any point in time. An obstacle and space are marked as ...
The robot can only move either down or right. Hence any cell in the first row can only be reached from the cell left to it. However, if any cell has an obstacle, you don't let that cell contribute to any path. So, for the first row, the number of ways will simply be if obstacleGrid[i][j] is not an obstacle ...
Array,Dynamic Programming,Matrix
Medium
62,1022
1,996
late code 1996 the number of weak characters in the game you are playing a game that contains multiple characters and each of the characters has two main properties attack and defense you are given a 2d integer array properties the properties of i is equal to attack i defense i represents the properties of the eight ch...
The Number of Weak Characters in the Game
number-of-ways-to-rearrange-sticks-with-k-sticks-visible
You are playing a game that contains multiple characters, and each of the characters has **two** main properties: **attack** and **defense**. You are given a 2D integer array `properties` where `properties[i] = [attacki, defensei]` represents the properties of the `ith` character in the game. A character is said to be...
Is there a way to build the solution from a base case? How many ways are there if we fix the position of one stick?
Math,Dynamic Programming,Combinatorics
Hard
null
1,042
Hello friends, welcome to things light, today I have come with three leader questions for you, the best part is that all 23 questions are relative flowers, yes all your questions are related to which, since today is a rose day, so I am especially this Collect three problem sets which I will tell in today's video. Basic...
Flower Planting With No Adjacent
minimum-cost-to-merge-stones
You have `n` gardens, labeled from `1` to `n`, and an array `paths` where `paths[i] = [xi, yi]` describes a bidirectional path between garden `xi` to garden `yi`. In each garden, you want to plant one of 4 types of flowers. All gardens have **at most 3** paths coming into or leaving it. Your task is to choose a flowe...
null
Array,Dynamic Programming
Hard
312,1126
383
hello everyone so in this video we will be uh doing lead code problem number 383 which is Ransom note so we are given two strings one of them is Ransom note another one is magazine so we will be returning true if Ransom note can be constructed by using the letters from the magazine that means that whatever letters we h...
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
367
hey what's up uh welcome to another easy liquid question today we're going to solve lee code 367 valid perfect square uh this is going to be a very short one you're given a number and you should check whether that number is a valid perfect square so how do we solve this question well first of all what exactly is a perf...
Valid Perfect Square
valid-perfect-square
Given a positive integer num, return `true` _if_ `num` _is a perfect square or_ `false` _otherwise_. A **perfect square** is an integer that is the square of an integer. In other words, it is the product of some integer with itself. You must not use any built-in library function, such as `sqrt`. **Example 1:** **In...
null
Math,Binary Search
Easy
69,633
22
hello everybody and welcome to another episode of your favorite algorithm Channel today we're going to be doing leak code 20 to generate parentheses so this is the second parentheses problem we've seen we had just recently done valve indices so we understand what a valid string of parentheses is and what the nesting ru...
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
149
Hello gas welcome back to my channel thank you go challenge maximum points on online which line is being made in which the maximum number of points has to be returned by returning it ok the number one has to be returned and which line has to be given in which the maximum number of points is so like in this Only one lin...
Max Points on a Line
max-points-on-a-line
Given an array of `points` where `points[i] = [xi, yi]` represents a point on the **X-Y** plane, return _the maximum number of points that lie on the same straight line_. **Example 1:** **Input:** points = \[\[1,1\],\[2,2\],\[3,3\]\] **Output:** 3 **Example 2:** **Input:** points = \[\[1,1\],\[3,2\],\[5,3\],\[4,1\]...
null
Array,Hash Table,Math,Geometry
Hard
356,2287
215
hi dear folks today's lead code challenge is kth largest element in an array in today's problem we are given input as an integer array and a value of k and we have to find the kth largest element in input array for example we are given input as this array of integers and a value of k is equals to 2 then if we'll sort t...
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
59
hey guys let's take a look at number 49 at 59 spiral matrix 2 we're giving a positive integer we should generate you some spiral matrix like this about two three four five six seven eight yeah actually we have done a semanas question which is 54 spiral matrix so you if you haven't look at my video please search number ...
Spiral Matrix II
spiral-matrix-ii
Given a positive integer `n`, generate an `n x n` `matrix` filled with elements from `1` to `n2` in spiral order. **Example 1:** **Input:** n = 3 **Output:** \[\[1,2,3\],\[8,9,4\],\[7,6,5\]\] **Example 2:** **Input:** n = 1 **Output:** \[\[1\]\] **Constraints:** * `1 <= n <= 20`
null
Array,Matrix,Simulation
Medium
54,921
1,880
hello everyone welcome to coderscamp so in this video we are going to cover this problem check if word equals summation of two words and it is one of the easy category problem which is asked in lead click on test 243 here the input given is three strings the first word second word and the target and we have to return i...
Check if Word Equals Summation of Two Words
largest-merge-of-two-strings
The **letter value** of a letter is its position in the alphabet **starting from 0** (i.e. `'a' -> 0`, `'b' -> 1`, `'c' -> 2`, etc.). The **numerical value** of some string of lowercase English letters `s` is the **concatenation** of the **letter values** of each letter in `s`, which is then **converted** into an inte...
Build the result character by character. At each step, you choose a character from one of the two strings. If the next character of the first string is larger than that of the second string, or vice versa, it's optimal to use the larger one. If both are equal, think of a criteria that lets you decide which string to co...
Two Pointers,String,Greedy
Medium
null
976
Hi gas welcome and welcome back to my channel so today our problem is the largest parameter triangle so in this problem statement what have we given here, we have been given an arrangement of names and what is the largest parameter of an We want to find a triangle. Okay, so which triangle will we find? Here we have giv...
Largest Perimeter Triangle
minimum-area-rectangle
Given an integer array `nums`, return _the largest perimeter of a triangle with a non-zero area, formed from three of these lengths_. If it is impossible to form any triangle of a non-zero area, return `0`. **Example 1:** **Input:** nums = \[2,1,2\] **Output:** 5 **Explanation:** You can form a triangle with three si...
null
Array,Hash Table,Math,Geometry,Sorting
Medium
null
1,732
hey everybody this is larry this is q1 of the leeco daily uh sorry bi-weekly contest leeco daily uh sorry bi-weekly contest leeco daily uh sorry bi-weekly contest 44. uh find the highest altitude so this one um for each element of the array they just tell you the difference between the previous array so from that you j...
Find the Highest Altitude
minimum-one-bit-operations-to-make-integers-zero
There is a biker going on a road trip. The road trip consists of `n + 1` points at different altitudes. The biker starts his trip on point `0` with altitude equal `0`. You are given an integer array `gain` of length `n` where `gain[i]` is the **net gain in altitude** between points `i`​​​​​​ and `i + 1` for all (`0 <=...
The fastest way to convert n to zero is to remove all set bits starting from the leftmost one. Try some simple examples to learn the rule of how many steps are needed to remove one set bit. consider n=2^k case first, then solve for all n.
Dynamic Programming,Bit Manipulation,Memoization
Hard
2119
985
hi everyone.this look at number nine hi everyone.this look at number nine hi everyone.this look at number nine eight five some of even numbers after queries so we have a ray of integers an array of queries for each query the first one is value the one second one is index so it means we add the value to the index two nu...
Sum of Even Numbers After Queries
bag-of-tokens
You are given an integer array `nums` and an array `queries` where `queries[i] = [vali, indexi]`. For each query `i`, first, apply `nums[indexi] = nums[indexi] + vali`, then print the sum of the even values of `nums`. Return _an integer array_ `answer` _where_ `answer[i]` _is the answer to the_ `ith` _query_. **Exam...
null
Array,Two Pointers,Greedy,Sorting
Medium
null
829
Hello Hello everyone Manush and today we are going to solve a very interesting question in the address system portal, the name of which is which coating number is even, so this is a high-tech problem but we will solve this high-tech problem with high-tech problem but we will solve this high-tech problem with high-tech ...
Consecutive Numbers Sum
subdomain-visit-count
Given an integer `n`, return _the number of ways you can write_ `n` _as the sum of consecutive positive integers._ **Example 1:** **Input:** n = 5 **Output:** 2 **Explanation:** 5 = 2 + 3 **Example 2:** **Input:** n = 9 **Output:** 3 **Explanation:** 9 = 4 + 5 = 2 + 3 + 4 **Example 3:** **Input:** n = 15 **Output...
null
Array,Hash Table,String,Counting
Medium
null
367
all right let's talk about the perfect square so you are given a positive integer now so you have to recently the numbers the perfect square else false right so here's a diagram i'm going to just quickly just uh guide you through it how do you do it so you can actually traverse all the fun but you have uh you will get ...
Valid Perfect Square
valid-perfect-square
Given a positive integer num, return `true` _if_ `num` _is a perfect square or_ `false` _otherwise_. A **perfect square** is an integer that is the square of an integer. In other words, it is the product of some integer with itself. You must not use any built-in library function, such as `sqrt`. **Example 1:** **In...
null
Math,Binary Search
Easy
69,633
105
um hello so today we are going to do this problem called construct binary tree from pre-order and in order tree from pre-order and in order tree from pre-order and in order traversal so we have two arrays pre-order and in so we have two arrays pre-order and in so we have two arrays pre-order and in order um basically p...
Construct Binary Tree from Preorder and Inorder Traversal
construct-binary-tree-from-preorder-and-inorder-traversal
Given two integer arrays `preorder` and `inorder` where `preorder` is the preorder traversal of a binary tree and `inorder` is the inorder traversal of the same tree, construct and return _the binary tree_. **Example 1:** **Input:** preorder = \[3,9,20,15,7\], inorder = \[9,3,15,20,7\] **Output:** \[3,9,20,null,null,...
null
Array,Hash Table,Divide and Conquer,Tree,Binary Tree
Medium
106
47
hey everyone welcome back and let's write some more neat code today so today let's solve permutations two the follow-up to the first permutations the follow-up to the first permutations the follow-up to the first permutations problem so we're given again a list of numbers and the only difference with this problem compa...
Permutations II
permutations-ii
Given a collection of numbers, `nums`, that might contain duplicates, return _all possible unique permutations **in any order**._ **Example 1:** **Input:** nums = \[1,1,2\] **Output:** \[\[1,1,2\], \[1,2,1\], \[2,1,1\]\] **Example 2:** **Input:** nums = \[1,2,3\] **Output:** \[\[1,2,3\],\[1,3,2\],\[2,1,3\],\[2,3,...
null
Array,Backtracking
Medium
31,46,267,1038
561
group this integers into n pass A1 B1 a to B2 substitute a and b n till the sum of the minimum of a comma B for that pair for all I is maximized return the maximize sum so what do they say in the question so they are given in aperture 1432 and that is of 2N the we can form in the given okay you could see one four three...
Array Partition
array-partition-i
Given an integer array `nums` of `2n` integers, group these integers into `n` pairs `(a1, b1), (a2, b2), ..., (an, bn)` such that the sum of `min(ai, bi)` for all `i` is **maximized**. Return _the maximized sum_. **Example 1:** **Input:** nums = \[1,4,3,2\] **Output:** 4 **Explanation:** All possible pairings (ignori...
Obviously, brute force won't help here. Think of something else, take some example like 1,2,3,4. How will you make pairs to get the result? There must be some pattern. Did you observe that- Minimum element gets add into the result in sacrifice of maximum element. Still won't able to find pairs? Sort the array and try t...
Array,Greedy,Sorting,Counting Sort
Easy
2112,2248,2261
198
so in this video we are going to solve one very interesting algorithm that name has been given the house with our interesting name so thing is that you have given one array and the each index has the value so you can consider that each element of this array is a house this is the houses so each house has a certain amou...
House Robber
house-robber
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security systems connected and **it will automatically contact the police if two adjacent houses were broken into...
null
Array,Dynamic Programming
Medium
152,213,256,276,337,600,656,740,2262
5
he was a guy's knee right here I do taking coding stuff on twitch and YouTube check the description for all my information join the discord got the community and I got the study guides I'm working on patreon so just stay aware we got a very popular problem longest palindromic substring number five one of the earlier on...
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,640
hey there everyone welcome back to lead coding in this video we will be looking at the solution to problem number one of lead code weekly contest 213 name of the problem is check array formation through concatenation now you are given an area of distinct integers and an array of integers array pieces where the integers...
Check Array Formation Through Concatenation
design-a-file-sharing-system
You are given an array of **distinct** integers `arr` and an array of integer arrays `pieces`, where the integers in `pieces` are **distinct**. Your goal is to form `arr` by concatenating the arrays in `pieces` **in any order**. However, you are **not** allowed to reorder the integers in each array `pieces[i]`. Return...
Try to solve it by keeping for each file chunk, the users who have this chunk. Try to solve it by keeping all the users in the system with their owned chunks, and when you request a chunk, check all users for it.
Hash Table,Design,Heap (Priority Queue),Data Stream
Medium
355
509
let's do another one its five-year the let's do another one its five-year the let's do another one its five-year the prick is gonna okay for the Fibonacci numbers comedy you know as ever file form the sequence curve not sequence such that each number is sum between two previous numbers given an calculate F a fan okay a...
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
779
hey everyone today we are going to solve the Ral equation case symbol in grammar first of all we have rules so if we find a zero then Z creates a 0 one in the next row and if we find one then one creates a one zero in the next row so this is a very important rules okay so question is how can we find the answer so look ...
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