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
219
hey everybody this is Larry this is day 21 21st of the October Lego day challenge hit the like button hit the Subscribe button join me on Discord let me know what you think about trying to find extra 10 points about this poem contains duplicate 2 which is a easy poem supposedly which is great because I'm really tired r...
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
759
I was solving beat code problems and I was not planning to make videos of the problems that are provided but I found this one that is very interesting in the day it is not interesting for the problem itself but for the possible solutions this program 69 from the friendly and consell free time and what it is about is th...
Employee Free Time
set-intersection-size-at-least-two
We are given a list `schedule` of employees, which represents the working time for each employee. Each employee has a list of non-overlapping `Intervals`, and these intervals are in sorted order. Return the list of finite intervals representing **common, positive-length free time** for _all_ employees, also in sorted...
null
Array,Greedy,Sorting
Hard
null
210
hi everyone it's Soren today we have a problem when we are given a courses and also we are given a prerequisite for each course so for example in this case we are given a two courses zero and one right and also we are given a prerequisites so prerequisite for the course one is zero and in our case we need to return the...
Course Schedule II
course-schedule-ii
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 the topological order 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. Topolo...
Depth-First Search,Breadth-First Search,Graph,Topological Sort
Medium
207,269,310,444,630,1101,2220
257
all right welcome to this video we're gonna be doing miko prom 257 binary tree paths so I'll give you a binary tree and they want to return an array of strings representing all the paths from the root which is at the top of the tree right the one node in this example till a leaf and a leaf is a note with no children ri...
Binary Tree Paths
binary-tree-paths
Given the `root` of a binary tree, return _all root-to-leaf paths in **any order**_. A **leaf** is a node with no children. **Example 1:** **Input:** root = \[1,2,3,null,5\] **Output:** \[ "1->2->5 ", "1->3 "\] **Example 2:** **Input:** root = \[1\] **Output:** \[ "1 "\] **Constraints:** * The number of nodes ...
null
String,Backtracking,Tree,Depth-First Search,Binary Tree
Easy
113,1030,2217
1,808
so we could 1808 maximize the number of nice divisors so in this problem you need to return the maximum possible amount of nice divisors of every number of any number that has at most p f prime factors so pf is your input you need to output the biggest possible amount of nice divisors of any number that has at most bf ...
Maximize Number of Nice Divisors
stone-game-vii
You are given a positive integer `primeFactors`. You are asked to construct a positive integer `n` that satisfies the following conditions: * The number of prime factors of `n` (not necessarily distinct) is **at most** `primeFactors`. * The number of nice divisors of `n` is maximized. Note that a divisor of `n` is...
The constraints are small enough for an N^2 solution. Try using dynamic programming.
Array,Math,Dynamic Programming,Game Theory
Medium
909,1240,1522,1617,1685,1788,1896,2002,2156
130
hey guys persistent programmer here and today we're gonna do another legal question surrounded regions now before we get into the question if you haven't subscribed please go ahead and smash that subscribe button it really helps me create these videos for you okay let's go ahead and read the question okay awesome so we...
Surrounded Regions
surrounded-regions
Given an `m x n` matrix `board` containing `'X'` and `'O'`, _capture all regions that are 4-directionally surrounded by_ `'X'`. A region is **captured** by flipping all `'O'`s into `'X'`s in that surrounded region. **Example 1:** **Input:** board = \[\[ "X ", "X ", "X ", "X "\],\[ "X ", "O ", "O ", "X "\],\[ "X ", "...
null
Array,Depth-First Search,Breadth-First Search,Union Find,Matrix
Medium
200,286
1,773
hey everybody this is larry just me going with q1 of the weekly contest 230 uh count items matching rule um so this one i don't know uh hit the like button the subscribe button join my discord that's my world and those that's the number of items you have to match no i'm just kidding i mean well it would be nice if you ...
Count Items Matching a Rule
percentage-of-users-attended-a-contest
You are given an array `items`, where each `items[i] = [typei, colori, namei]` describes the type, color, and name of the `ith` item. You are also given a rule represented by two strings, `ruleKey` and `ruleValue`. The `ith` item is said to match the rule if **one** of the following is true: * `ruleKey == "type "` ...
null
Database
Easy
1338
1,680
hey everybody this is Larry this is day 24 of delete uh day 23 whoops of the legal daily challenge hit the like button and the Subscribe button join me on Discord let me know what you think about today's Farm was a little gun had a good night say and yeah let's just get started uh I'll at some point I'll bring back som...
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,047
okay so lead code practice time so in this video we have two goals the first goal is to see how we should solve this problem um then we are going to put in some code here and the next goal is to see how to solve this problem properly in real interview so let's get started so remember the first step is to try to always ...
Remove All Adjacent Duplicates In String
maximize-sum-of-array-after-k-negations
You are given a string `s` consisting of lowercase English letters. A **duplicate removal** consists of choosing two **adjacent** and **equal** letters and removing them. We repeatedly make **duplicate removals** on `s` until we no longer can. Return _the final string after all such duplicate removals have been made_...
null
Array,Greedy,Sorting
Easy
2204
1,884
A Different Se Zaveri Stand Problem Vitamin Interview Hotspot Of Which State Agro Bittu Services Solved Problem In Which Is The Problem Of To Find The Number Of Subscribe And Subscribe The Channel Problem Key Problem In Which I Am The Thing Which Talk I improved this dance problem is which help me tow clients mid-1990s...
Egg Drop With 2 Eggs and N Floors
minimum-changes-to-make-alternating-binary-string
You are given **two identical** eggs and you have access to a building with `n` floors labeled from `1` to `n`. You know that there exists a floor `f` where `0 <= f <= n` such that any egg dropped at a floor **higher** than `f` will **break**, and any egg dropped **at or below** floor `f` will **not break**. In each ...
Think about how the final string will look like. It will either start with a '0' and be like '010101010..' or with a '1' and be like '10101010..' Try both ways, and check for each way, the number of changes needed to reach it from the given string. The answer is the minimum of both ways.
String
Easy
null
52
all right guys let's do the 50 second problem with lead code and queen two follow from end queen problem now instead of outputting board configuration return the total number of distinct solution so as we uh as we did in the previous problem we're going to follow the same approach uh let's define account universal vari...
N-Queens II
n-queens-ii
The **n-queens** puzzle is the problem of placing `n` queens on an `n x n` chessboard such that no two queens attack each other. Given an integer `n`, return _the number of distinct solutions to the **n-queens puzzle**_. **Example 1:** **Input:** n = 4 **Output:** 2 **Explanation:** There are two distinct solutions ...
null
Backtracking
Hard
51
4
Everyone welcome back tu channel, I am ready and in today's video we are going to talk about Median of Tu Sorted so this is a very interesting question of binary search and if you have come to this channel by mistake then subscribe the channel immediately. Like the video, if you start this video without any time, then ...
Median of Two Sorted Arrays
median-of-two-sorted-arrays
Given two sorted arrays `nums1` and `nums2` of size `m` and `n` respectively, return **the median** of the two sorted arrays. The overall run time complexity should be `O(log (m+n))`. **Example 1:** **Input:** nums1 = \[1,3\], nums2 = \[2\] **Output:** 2.00000 **Explanation:** merged array = \[1,2,3\] and median is ...
null
Array,Binary Search,Divide and Conquer
Hard
null
1,029
Hey guys, welcome to some YouTube channel, so today we are going to show a question, its name is 216 question read, I will look at the subscribe button, if you have not subscribed again then the problem with the first question is that the question is saying that you have a list of candidates. For the interview, you are...
Two City Scheduling
vertical-order-traversal-of-a-binary-tree
A company is planning to interview `2n` people. Given the array `costs` where `costs[i] = [aCosti, bCosti]`, the cost of flying the `ith` person to city `a` is `aCosti`, and the cost of flying the `ith` person to city `b` is `bCosti`. Return _the minimum cost to fly every person to a city_ such that exactly `n` people...
null
Hash Table,Tree,Depth-First Search,Breadth-First Search,Binary Tree
Hard
null
226
Hello Guys Welcome Back To Take You Jai Hind This Video Also Developed Inverter Battery Problem Which From Day One Of The June Challenge So Let's Not Look At The Problem Statement In This Problem Veer The Very Simple Approach To Construct New In Water It Will Be Not Afraid To Solve Subscribe Now To Change The Giver Thi...
Invert Binary Tree
invert-binary-tree
Given the `root` of a binary tree, invert the tree, and return _its root_. **Example 1:** **Input:** root = \[4,2,7,1,3,6,9\] **Output:** \[4,7,2,9,6,3,1\] **Example 2:** **Input:** root = \[2,1,3\] **Output:** \[2,3,1\] **Example 3:** **Input:** root = \[\] **Output:** \[\] **Constraints:** * The number of n...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Easy
null
437
hey guys welcome back to another video and today we're going to be solving the lead code question path sum 3. all right so in this question we're given a binary tree in which each node contains an integer value so our task is to find the number of paths that sum to a given value so we're given this value called sum and...
Path Sum III
path-sum-iii
Given the `root` of a binary tree and an integer `targetSum`, return _the number of paths where the sum of the values along the path equals_ `targetSum`. The path does not need to start or end at the root or a leaf, but it must go downwards (i.e., traveling only from parent nodes to child nodes). **Example 1:** **In...
null
Tree,Depth-First Search,Binary Tree
Medium
112,113,666,687
371
hey guys welcome back to the channel today we're going to solve a little 371 sum of two integers it's a medium problem and to be honest it's not that difficult by just if you know the tricks it's it becomes super easy so you're saying give it two decimal numbers a and b we want to add them up without using the plus or ...
Sum of Two Integers
sum-of-two-integers
Given two integers `a` and `b`, return _the sum of the two integers without using the operators_ `+` _and_ `-`. **Example 1:** **Input:** a = 1, b = 2 **Output:** 3 **Example 2:** **Input:** a = 2, b = 3 **Output:** 5 **Constraints:** * `-1000 <= a, b <= 1000`
null
Math,Bit Manipulation
Medium
2
415
Hello hello everyone welcome to inflect channel in this question has its recent years in the 2nd id for most recent visit to do the past midnight children to the number two that electrolyte presentation of deposits and its very simple question art friends let's move laxative inside 158 In the input is given to words in...
Add Strings
add-strings
Given two non-negative integers, `num1` and `num2` represented as string, return _the sum of_ `num1` _and_ `num2` _as a string_. You must solve the problem without using any built-in library for handling large integers (such as `BigInteger`). You must also not convert the inputs to integers directly. **Example 1:** ...
null
Math,String,Simulation
Easy
2,43,1031
1,314
I had also today we're doing this vehicle contest 17 I'm going to start with the second problem here so prob 1314 match matrix black something so the problem says given an M by n matrix and an integer K want to return a matrix answer where each answer I check is the sum of all elements in matrix C such that R and C are...
Matrix Block Sum
matrix-block-sum
Given a `m x n` matrix `mat` and an integer `k`, return _a matrix_ `answer` _where each_ `answer[i][j]` _is the sum of all elements_ `mat[r][c]` _for_: * `i - k <= r <= i + k,` * `j - k <= c <= j + k`, and * `(r, c)` is a valid position in the matrix. **Example 1:** **Input:** mat = \[\[1,2,3\],\[4,5,6\],\[7,8...
null
null
Medium
null
478
Hello guys welcome to the video naseeb sabko degree with this problem question read point ko iss point subscribe and subscribe the Channel Ko sabsakraib subscribe and don't see the story of the giver and debit the meaning of the center of the subscribe The Video then subscribe to the Page Hello how define random point ...
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
206
welcome to september sleep code challenge today's problem is reverse linked list given the head of a singly linked list reverse the list and return the reversed list so we have a linked list now normally if we had just a list we could just reverse it and return it but you can certainly output this into an array and the...
Reverse Linked List
reverse-linked-list
Given the `head` of a singly linked list, reverse the list, and return _the reversed list_. **Example 1:** **Input:** head = \[1,2,3,4,5\] **Output:** \[5,4,3,2,1\] **Example 2:** **Input:** head = \[1,2\] **Output:** \[2,1\] **Example 3:** **Input:** head = \[\] **Output:** \[\] **Constraints:** * The number...
null
Linked List,Recursion
Easy
92,156,234,2196,2236
125
hey everyone this is question 125 Valen palindrome valid palindrome and this is also taken from the neat code.io list also taken from the neat code.io list also taken from the neat code.io list this question is easy rather straightforward so let's just jump straight into the example the question is saying given this st...
Valid Palindrome
valid-palindrome
A phrase is a **palindrome** if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. Alphanumeric characters include letters and numbers. Given a string `s`, return `true` _if it is a **palindrome**, or_ `false` _otherwise_...
null
Two Pointers,String
Easy
234,680,2130,2231
70
if you're in a coding interview avoid this common mistake you might have seen this problem before it's called climbing stairs and it's commonly used to test dynamic programming you'd probably come up with this solution where you have two base cases and we build up a dynamic programming array this is called tabulation n...
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
14
hello everyone and welcome to Python programming practice in this episode we are going to be covering elite code number fourteen longest common prefix this is another easy problem so shouldn't be super difficult but we'll see what we can do we're gonna start by reading the problem description here the problem asks us t...
Longest Common Prefix
longest-common-prefix
Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string `" "`. **Example 1:** **Input:** strs = \[ "flower ", "flow ", "flight "\] **Output:** "fl " **Example 2:** **Input:** strs = \[ "dog ", "racecar ", "car "\] **Output:** " "...
null
String
Easy
null
445
hey everybody this is larry this is day seven of the leeco daily challenge hit the like button hit the subscribe button join me on discord let me know what you think about today's prom add two numbers uh two you're given two not linked lists and you have to add them okay um what if you cannot modify them bliss in other...
Add Two Numbers II
add-two-numbers-ii
You are given two **non-empty** linked lists representing two non-negative integers. The most significant digit comes first 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 itsel...
null
Linked List,Math,Stack
Medium
2,1774
1,696
hello so in this video i am going to explain the lithgow daily challenge of 9 7 2022. the question is jumpcamp six way in this question they give us zero indexed array nums and it is a k if you are initially standing at the index 0 in one move you can jump but most k steps forward without going outside the boundaries o...
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
57
this is the 57th leco Challenge and it is called insert interval you are given an array of non-overlapping intervals an array of non-overlapping intervals an array of non-overlapping intervals called intervals where intervals I equals start I and I represent the start and the end of the IELTS interval in intervals is s...
Insert Interval
insert-interval
You are given an array of non-overlapping intervals `intervals` where `intervals[i] = [starti, endi]` represent the start and the end of the `ith` interval and `intervals` is sorted in ascending order by `starti`. You are also given an interval `newInterval = [start, end]` that represents the start and end of another i...
null
Array
Medium
56,715
1,604
hello welcome to today's video we'll be looking at lead code problem number 1604 alert using same key card three or more times in a one hour period in this problem we are told that each time a worker uses their key card a security system saves their name and the time it was used and the system will emit an alert if any...
Alert Using Same Key-Card Three or More Times in a One Hour Period
least-number-of-unique-integers-after-k-removals
LeetCode company workers use key-cards to unlock office doors. Each time a worker uses their key-card, the security system saves the worker's name and the time when it was used. The system emits an **alert** if any worker uses the key-card **three or more times** in a one-hour period. You are given a list of strings `...
Use a map to count the frequencies of the numbers in the array. An optimal strategy is to remove the numbers with the smallest count first.
Array,Hash Table,Greedy,Sorting,Counting
Medium
null
42
Which improves the interest in the liquor shops and the working committee's consumption. Are there traffic problems in these areas and is a very common problem. I have worshiped this many times but a very good collection is mandatory. That is our agro processing, preprocessing and in you. You must have understood that ...
Trapping Rain Water
trapping-rain-water
Given `n` non-negative integers representing an elevation map where the width of each bar is `1`, compute how much water it can trap after raining. **Example 1:** **Input:** height = \[0,1,0,2,1,0,1,3,2,1,2,1\] **Output:** 6 **Explanation:** The above elevation map (black section) is represented by array \[0,1,0,2,1,...
null
Array,Two Pointers,Dynamic Programming,Stack,Monotonic Stack
Hard
11,238,407,756
400
Jhal Loot Problem Loot-Loot Norms On Jhal Loot Problem Loot-Loot Norms On Jhal Loot Problem Loot-Loot Norms On Loot And Aspirations Hai To Bhi Aap Kar To Kuch Kafi Tikamgarh Movie Aa Jo Arm Hai Tu Bijli Ki Problem Before Approaching We Have Heard That Pyar Kam Raha Tha Roop Bring also, if you ask, victory will not be s...
Nth Digit
nth-digit
Given an integer `n`, return the `nth` digit of the infinite integer sequence `[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ...]`. **Example 1:** **Input:** n = 3 **Output:** 3 **Example 2:** **Input:** n = 11 **Output:** 0 **Explanation:** The 11th digit of the sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ... is a 0, which ...
null
Math,Binary Search
Medium
null
1,375
hello everyone in this video I'm going to explain to you the solution for the legal problem both Witcher 3 so basically in this way given n bugs numbered from 1 to n arranged in a row from left to right initially all the bugs are turned off so we're given an integer array light having values from 1 to N in any order an...
Number of Times Binary String Is Prefix-Aligned
find-palindrome-with-fixed-length
You have a **1-indexed** binary string of length `n` where all the bits are `0` initially. We will flip all the bits of this binary string (i.e., change them from `0` to `1`) one by one. You are given a **1-indexed** integer array `flips` where `flips[i]` indicates that the bit at index `i` will be flipped in the `ith`...
For any value of queries[i] and intLength, how can you check if there exists at least queries[i] palindromes of length intLength? Since a palindrome reads the same forwards and backwards, consider how you can efficiently find the first half (ceil(intLength/2) digits) of the palindrome.
Array,Math
Medium
9,564
252
hi everyone today we are here to tackle question 252 meeting rooms so we're given an array of meeting time intervals consisting of start and end time we want to know if a person could attend all meetings okay so first i like to think about some of the clarification questions and understanding the input and output that ...
Meeting Rooms
meeting-rooms
Given an array of meeting time `intervals` where `intervals[i] = [starti, endi]`, determine if a person could attend all meetings. **Example 1:** **Input:** intervals = \[\[0,30\],\[5,10\],\[15,20\]\] **Output:** false **Example 2:** **Input:** intervals = \[\[7,10\],\[2,4\]\] **Output:** true **Constraints:** * ...
null
Array,Sorting
Easy
56,253
443
hey everyone this is Alex welcome back to my videos on solving lead Coke problems and now we're solving problem 443 sting comprehension string comprehension given an array characters charge compress it using the following algorithm they could begin with an empty string s for each group of consecutive repeating characte...
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
872
Hello everyone welcome, the question of my channel is lead code number 872, okay, Goldman, Amazon, Microsoft, okay, now by looking at the input and output, let us understand what the question is, okay, see in the question it will be given that you have been given two trees, okay. So the question number is simple, it is...
Leaf-Similar Trees
split-array-into-fibonacci-sequence
Consider all the leaves of a binary tree, from left to right order, the values of those leaves form a **leaf value sequence**_._ For example, in the given tree above, the leaf value sequence is `(6, 7, 4, 9, 8)`. Two binary trees are considered _leaf-similar_ if their leaf value sequence is the same. Return `true` i...
null
String,Backtracking
Medium
306,1013
154
okay let's talk about find minima in rotated sort of rate too so this question is simple so uh you're given a rate but the array is somehow sorted but not exactly because it will rotate it and you just have to find the minimum based on these uh in array so you can do linear search but i'm not suggesting to do that leve...
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
142
Hi welcome question series and here we are going to attend question number 142 which is the second part of the linkless cycle. We had seen the first part of this where the question we had was that we have to detect the linked list cycle that a link Does it do cycles in the list or not? Okay, now there is the second par...
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,952
hey everybody it's peng here so today we're talking about question i did yesterday in contest 252 question one is called three divisors it's question 19 52. so given the integer n i want to turn true if n have exactly three positive divisors otherwise return false so integer n is device of n if there exists an integer ...
Three Divisors
minimum-sideway-jumps
Given an integer `n`, return `true` _if_ `n` _has **exactly three positive divisors**. Otherwise, return_ `false`. An integer `m` is a **divisor** of `n` if there exists an integer `k` such that `n = k * m`. **Example 1:** **Input:** n = 2 **Output:** false **Explantion:** 2 has only two divisors: 1 and 2. **Exampl...
At a given point, there are only 3 possible states for where the frog can be. Check all the ways to move from one point to the next and update the minimum side jumps for each lane.
Array,Dynamic Programming,Greedy
Medium
403
1,887
hello so today we are going to solve lead code problem 1887 it's today uh daily problem so the problem statement is like uh reduction operation to make the array element equal so basically they will give us a array and we have to make all the element of the array equal with some constraint we have to apply sub operatio...
Reduction Operations to Make the Array Elements Equal
minimum-degree-of-a-connected-trio-in-a-graph
Given an integer array `nums`, your goal is to make all elements in `nums` equal. To complete one operation, follow these steps: 1. Find the **largest** value in `nums`. Let its index be `i` (**0-indexed**) and its value be `largest`. If there are multiple elements with the largest value, pick the smallest `i`. 2. F...
Consider a trio with nodes u, v, and w. The degree of the trio is just degree(u) + degree(v) + degree(w) - 6. The -6 comes from subtracting the edges u-v, u-w, and v-w, which are counted twice each in the vertex degree calculation. To get the trios (u,v,w), you can iterate on u, then iterate on each w,v such that w and...
Graph
Hard
null
246
hey folks welcome back to another video today we're looking at question 246. trobo chromatic number uh the wave will be solving this problem is by using a hash map which will be used to map these numbers that look the same um at even if you flip down 180 degrees so let's get started um to be able to do that obviously w...
Strobogrammatic Number
strobogrammatic-number
Given a string `num` which represents an integer, return `true` _if_ `num` _is a **strobogrammatic number**_. A **strobogrammatic number** is a number that looks the same when rotated `180` degrees (looked at upside down). **Example 1:** **Input:** num = "69 " **Output:** true **Example 2:** **Input:** num = "88...
null
Hash Table,Two Pointers,String
Easy
247,248,1069
946
hey everybody this is larry this is february 26. uh hit the like button in the subscriber and join me on discord a couple of days left uh and let me know what you think about this really long one for me even though it's only 28 days uh okay so today's problem is validate stack sequences um okay so yeah distinct values ...
Validate Stack Sequences
smallest-range-ii
Given two integer arrays `pushed` and `popped` each with distinct values, return `true` _if this could have been the result of a sequence of push and pop operations on an initially empty stack, or_ `false` _otherwise._ **Example 1:** **Input:** pushed = \[1,2,3,4,5\], popped = \[4,5,3,2,1\] **Output:** true **Explana...
null
Array,Math,Greedy,Sorting
Medium
null
1,750
hey guys welcome to a new video in today's video we're going to look at lead code problem and the problem's name is minimum length of string after deleting similar ends so we given a string s which consists of only characters a b and c you are asked to apply the following algorithm on the string any number of times so ...
Minimum Length of String After Deleting Similar Ends
check-if-two-expression-trees-are-equivalent
Given a string `s` consisting only of characters `'a'`, `'b'`, and `'c'`. You are asked to apply the following algorithm on the string any number of times: 1. Pick a **non-empty** prefix from the string `s` where all the characters in the prefix are equal. 2. Pick a **non-empty** suffix from the string `s` where all...
Count for each variable how many times it appeared in the first tree. Do the same for the second tree and check if the count is the same for both tree.
Tree,Depth-First Search,Binary Tree
Medium
1736
55
all right this lead code question is called jump game it's just given an array of non-negative integers you are initially non-negative integers you are initially non-negative integers you are initially positioned at the first index of the array each element in the array represents your maximum jump length at that posit...
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
1,921
Problem of the day of Hello Lit code is medium level question of Eliminate Maximum Number of Monsters. In this we are given two arrays of distance and speed so basically what is saying in this is that one is playing a video game and both the arrays are Each monster has a whistle. The distance array of the monsters is d...
Eliminate Maximum Number of Monsters
eliminate-maximum-number-of-monsters
You are playing a video game where you are defending your city from a group of `n` monsters. You are given a **0-indexed** integer array `dist` of size `n`, where `dist[i]` is the **initial distance** in kilometers of the `ith` monster from the city. The monsters walk toward the city at a **constant** speed. The speed...
null
null
Medium
null
443
Hai gas welcome and welcome back to me channel so today our problem is sting compression so what is given in this problem statement, you read it once and understand what is the problem statement. If you still do not understand then no problem we What will we do with this problem? Through the example, we will understand...
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
301
I'm looking at it, and now let's take a look at the tender cer problem. This is a very difficult problem for me, but I'll try to raise it step by step. First, I wrote down what I know. 4 First, you will understand the problem. The input value is in the myth. Please tell me the problem. The hospital bed Zao is using. It...
Remove Invalid Parentheses
remove-invalid-parentheses
Given a string `s` that contains parentheses and letters, remove the minimum number of invalid parentheses to make the input string valid. Return _a list of **unique strings** that are valid with the minimum number of removals_. You may return the answer in **any order**. **Example 1:** **Input:** s = "()())() " **...
Since we don't know which of the brackets can possibly be removed, we try out all the options! We can use recursion to try out all possibilities for the given expression. For each of the brackets, we have 2 options: We keep the bracket and add it to the expression that we are building on the fly during recursion....
String,Backtracking,Breadth-First Search
Hard
20,2095
63
in this video we'll be going over the brute force recursive approach for unique paths too so a robot is located at the top left corner of a m times n grid marked start in the diagram so here the robot can only move either down or right at any point in time the robot is trying to reach the bottom right corner of the gri...
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
760
Hello Hi Friends Welcome Back Today We Are Going To Solving Code Problem 830 50 Grams Mapping Sunidhi Chauhan Of The Google Interview Questions Vacancy So Let's Will Go Through The Description Of A Given To Least He Ended And Devotion And Places Of Grams And Means Of Graph Being Made Here And Amazing The Order Of Eleme...
Find Anagram Mappings
bold-words-in-string
You are given two integer arrays `nums1` and `nums2` where `nums2` is **an anagram** of `nums1`. Both arrays may contain duplicates. Return _an index mapping array_ `mapping` _from_ `nums1` _to_ `nums2` _where_ `mapping[i] = j` _means the_ `ith` _element in_ `nums1` _appears in_ `nums2` _at index_ `j`. If there are mu...
First, determine which letters are bold and store that information in mask[i] = if i-th character is bold. Then, insert the tags at the beginning and end of groups. The start of a group is if and only if (mask[i] and (i == 0 or not mask[i-1])), and the end of a group is similar.
Array,Hash Table,String,Trie,String Matching
Medium
null
904
hey everyone welcome back and let's write some more neat code today so today let's solve the problem fruit into baskets this is a pretty long problem description but the problem is actually simple I think the best thing you can learn from this problem is how to take like a long description like this and then break it d...
Fruit Into Baskets
leaf-similar-trees
You are visiting a farm that has a single row of fruit trees arranged from left to right. The trees are represented by an integer array `fruits` where `fruits[i]` is the **type** of fruit the `ith` tree produces. You want to collect as much fruit as possible. However, the owner has some strict rules that you must foll...
null
Tree,Depth-First Search,Binary Tree
Easy
null
263
Hi Rand, so today we are going to do the first question of our Maths playlist which is a very good version and it has been asked in Microsoft, Facebook and Google. This is its sample version of its easy part which was also asked in the challenge today. Let us solve this question, Amazon and Facebook did not ask, it is ...
Ugly Number
ugly-number
An **ugly number** is a positive integer whose prime factors are limited to `2`, `3`, and `5`. Given an integer `n`, return `true` _if_ `n` _is an **ugly number**_. **Example 1:** **Input:** n = 6 **Output:** true **Explanation:** 6 = 2 \* 3 **Example 2:** **Input:** n = 1 **Output:** true **Explanation:** 1 has n...
null
Math
Easy
202,204,264
1,091
hey what is up guys for this question i'm going to be solving shortest path in binary matrix which essentially asks for finding the longest the length of the shortest clear path in a 2d array and a clear path is essentially the path from the top left cell which is marked as a zero to the bottom right cell which is also...
Shortest Path in Binary Matrix
maximum-average-subtree
Given an `n x n` binary matrix `grid`, return _the length of the shortest **clear path** in the matrix_. If there is no clear path, return `-1`. A **clear path** in a binary matrix is a path from the **top-left** cell (i.e., `(0, 0)`) to the **bottom-right** cell (i.e., `(n - 1, n - 1)`) such that: * All the visite...
Can you find the sum of values and the number of nodes for every sub-tree ? Can you find the sum of values and the number of nodes for a sub-tree given the sum of values and the number of nodes of it's left and right sub-trees ? Use depth first search to recursively find the solution for the children of a node then use...
Tree,Depth-First Search,Binary Tree
Medium
2126
1,262
well all my problems are invisible to me this is one two six two greatest sum divisible by three all right let's go ahead and get right into this problem so you're given an integer array nums return the maximum possible sum of elements of the array such that it is divisible by three pretty simple problem description ri...
Greatest Sum Divisible by Three
online-majority-element-in-subarray
Given an integer array `nums`, return _the **maximum possible sum** of elements of the array such that it is divisible by three_. **Example 1:** **Input:** nums = \[3,6,5,1,8\] **Output:** 18 **Explanation:** Pick numbers 3, 6, 1 and 8 their sum is 18 (maximum sum divisible by 3). **Example 2:** **Input:** nums = \...
What's special about a majority element ? A majority element appears more than half the length of the array number of times. If we tried a random index of the array, what's the probability that this index has a majority element ? It's more than 50% if that array has a majority element. Try a random index for a proper n...
Array,Binary Search,Design,Binary Indexed Tree,Segment Tree
Hard
null
1,492
hey everybody this is larry this is day four of the december leeco daily challenge uh hit the like button hit the subscribe button join me in discord let me know what you think about taste farm uh if you're new to stream i usually solve this live and i talk about my thought process as i'm reading this for the first tim...
The kth Factor of n
time-needed-to-inform-all-employees
You are given two positive integers `n` and `k`. A factor of an integer `n` is defined as an integer `i` where `n % i == 0`. Consider a list of all factors of `n` sorted in **ascending order**, return _the_ `kth` _factor_ in this list or return `-1` if `n` has less than `k` factors. **Example 1:** **Input:** n = 12,...
The company can be represented as a tree, headID is always the root. Store for each node the time needed to be informed of the news. Answer is the max time a leaf node needs to be informed.
Tree,Depth-First Search,Breadth-First Search
Medium
104,124
1,866
hey everyone welcome back and let's write some more neat code today so today let's solve the brand new problem from today's elite code contest number of ways to rearrange sticks with k sticks visible a pretty long name and this is a pretty difficult problem and it happens to be a dynamic programming problem so as with ...
Number of Ways to Rearrange Sticks With K Sticks Visible
restore-the-array-from-adjacent-pairs
There are `n` uniquely-sized sticks whose lengths are integers from `1` to `n`. You want to arrange the sticks such that **exactly** `k` sticks are **visible** from the left. A stick is **visible** from the left if there are no **longer** sticks to the **left** of it. * For example, if the sticks are arranged `[1,3,...
Find the first element of nums - it will only appear once in adjacentPairs. The adjacent pairs are like edges of a graph. Perform a depth-first search from the first element.
Array,Hash Table
Medium
null
743
hi everyone so they talk about network delay time so you are given the endnotes and then basically you have the time array at any time the race we want to give you uh the source destination and how much time it will take from a source to a target and then what you have to do is you want to send the signal from no k and...
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,602
Hai gas welcome tu today's video and today we are going to do lead code problem 1602 named find nearest right node in binary tree so we are given a root okay and what we have to return is nearest node on d se level date is tu D right of view and return null if u it is d right most note in d level so basically what we h...
Find Nearest Right Node in Binary Tree
find-nearest-right-node-in-binary-tree
Given the `root` of a binary tree and a node `u` in the tree, return _the **nearest** node on the **same level** that is to the **right** of_ `u`_, or return_ `null` _if_ `u` _is the rightmost node in its level_. **Example 1:** **Input:** root = \[1,2,3,null,4,5,6\], u = 4 **Output:** 5 **Explanation:** The nearest n...
null
null
Medium
null
138
hello and welcome to another video in this video we're going to be working on compilist with random pointer so in this problem you're given a linked list of length n and it's a normal linked list except now every single node has a random pointer as well and that pointer can point to any other node in the linked list or...
Copy List with Random Pointer
copy-list-with-random-pointer
A linked list of length `n` is given such that each node contains an additional random pointer, which could point to any node in the list, or `null`. Construct a [**deep copy**](https://en.wikipedia.org/wiki/Object_copying#Deep_copy) of the list. The deep copy should consist of exactly `n` **brand new** nodes, where e...
Just iterate the linked list and create copies of the nodes on the go. Since a node can be referenced from multiple nodes due to the random pointers, make sure you are not making multiple copies of the same node. You may want to use extra space to keep old node ---> new node mapping to prevent creating multiples copies...
Hash Table,Linked List
Medium
133,1624,1634
883
hello welcome today let try to solve another lead code problem 883 production area of 3D shapes so we are giving a 3D shape actually this shape is just a grid so this means uh each of the rows and each of the columns it would be like a square for this array yeah and we can check yeah as you can see the grid dot length ...
Projection Area of 3D Shapes
car-fleet
You are given an `n x n` `grid` where we place some `1 x 1 x 1` cubes that are axis-aligned with the `x`, `y`, and `z` axes. Each value `v = grid[i][j]` represents a tower of `v` cubes placed on top of the cell `(i, j)`. We view the projection of these cubes onto the `xy`, `yz`, and `zx` planes. A **projection** is ...
null
Array,Stack,Sorting,Monotonic Stack
Medium
1902,2317
1,515
hey everybody this is Larry this is q4 for the reason kinda sit to like magnets of the eye one join my discord and hang out and chat about these problems anyway for best position for a service center so for this problem I think I'm trying to figure out how to best describe it I think well first of all you're wondering ...
Best Position for a Service Centre
find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k
A delivery company wants to build a new service center in a new city. The company knows the positions of all the customers in this city on a 2D-Map and wants to build the new center in a position such that **the sum of the euclidean distances to all customers is minimum**. Given an array `positions` where `positions[i...
Generate all Fibonacci numbers up to the limit (they are few). Use greedy solution, taking at every time the greatest Fibonacci number which is smaller than or equal to the current number. Subtract this Fibonacci number from the current number and repeat again the process.
Greedy
Medium
null
1,209
hello everyone welcome or welcome back to my channel so today we are going to discuss another problem is remove all adjacent duplicates in string so we will be given a string and an integer k a k duplicate removal consists of choosing k adjacent and equal letters from s and removing them so k adjacent equal letters mea...
Remove All Adjacent Duplicates in String II
design-bounded-blocking-queue
You are given a string `s` and an integer `k`, a `k` **duplicate removal** consists of choosing `k` adjacent and equal letters from `s` and removing them, causing the left and the right side of the deleted substring to concatenate together. We repeatedly make `k` **duplicate removals** on `s` until we no longer can. ...
null
Concurrency
Medium
null
1,905
hey everyone welcome back and let's write some more neat code today so today let's solve count sub islands a problem from today's leak code contest we're given two different grids m by n so basically each of these grids is guaranteed to be the exact same size that's good for us they're all containing either zeros or on...
Count Sub Islands
design-authentication-manager
You are given two `m x n` binary matrices `grid1` and `grid2` containing only `0`'s (representing water) and `1`'s (representing land). An **island** is a group of `1`'s connected **4-directionally** (horizontal or vertical). Any cells outside of the grid are considered water cells. An island in `grid2` is considered ...
Using a map, track the expiry times of the tokens. When generating a new token, add it to the map with its expiry time. When renewing a token, check if it's on the map and has not expired yet. If so, update its expiry time. To count unexpired tokens, iterate on the map and check for each token if it's not expired yet.
Hash Table,Design
Medium
null
73
hey everyone today we are going to solve the readable question set Matrix zeros so this is a one of our brand 75 literal questions so you are given M by an integer Matrix if an element is zero set its entire row and the column to zeros so you must do it in place so let's see the example so you are given this Matrix out...
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
1,887
hello and welcome to another video in this video we're going to be working on reduction operations to make the array elements equal and so in this problem you're given an injur array nums and your goal is to make all elements and nums equal to complete one operation follow the steps find the largest value in nums and f...
Reduction Operations to Make the Array Elements Equal
minimum-degree-of-a-connected-trio-in-a-graph
Given an integer array `nums`, your goal is to make all elements in `nums` equal. To complete one operation, follow these steps: 1. Find the **largest** value in `nums`. Let its index be `i` (**0-indexed**) and its value be `largest`. If there are multiple elements with the largest value, pick the smallest `i`. 2. F...
Consider a trio with nodes u, v, and w. The degree of the trio is just degree(u) + degree(v) + degree(w) - 6. The -6 comes from subtracting the edges u-v, u-w, and v-w, which are counted twice each in the vertex degree calculation. To get the trios (u,v,w), you can iterate on u, then iterate on each w,v such that w and...
Graph
Hard
null
7
hello welcome to Nets @os today in this hello welcome to Nets @os today in this hello welcome to Nets @os today in this video we will discuss about how to reverse indie job earlier I have discussed how to reverse string now we are covering lead code part so today we will cover reverse indie job so let's understand what...
Reverse Integer
reverse-integer
Given a signed 32-bit integer `x`, return `x` _with its digits reversed_. If reversing `x` causes the value to go outside the signed 32-bit integer range `[-231, 231 - 1]`, then return `0`. **Assume the environment does not allow you to store 64-bit integers (signed or unsigned).** **Example 1:** **Input:** x = 123 ...
null
Math
Medium
8,190,2238
8
hello today we'll be working on lead code number eight string the integer a to I stands for ASCII to integer and our function is given a string and we need to extract the first number characters from the string so let's go over the different things that we need to do in order to get the correct answer all right first w...
String to Integer (atoi)
string-to-integer-atoi
Implement the `myAtoi(string s)` function, which converts a string to a 32-bit signed integer (similar to C/C++'s `atoi` function). The algorithm for `myAtoi(string s)` is as follows: 1. Read in and ignore any leading whitespace. 2. Check if the next character (if not already at the end of the string) is `'-'` or `...
null
String
Medium
7,65,2168
1,025
welcome ladies and gentlemen boys and girls today we're going to solve another coolest question which is divisive game okay so this question is cool man so it deserved like for me because this person is very interesting this person doesn't likes from myself okay so let's see what the question is think so the question t...
Divisor Game
minimum-cost-for-tickets
Alice and Bob take turns playing a game, with Alice starting first. Initially, there is a number `n` on the chalkboard. On each player's turn, that player makes a move consisting of: * Choosing any `x` with `0 < x < n` and `n % x == 0`. * Replacing the number `n` on the chalkboard with `n - x`. Also, if a player...
null
Array,Dynamic Programming
Medium
322
234
all right let's talk about the parent drum nicholas so you're giving the head of the single linguist so return true if it's a parent drum so this is an example and then there are a couple ways to solve these questions and the easy way is using the recursion so you just find out the last note in the linked list then you...
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
1,422
hello friends so today we can discuss this question from weekly contest 186 problem number one for two to maximum school after splitting a string you are given a string s of zeros and ones return the maximum score after splitting the string into two non-empty sub the string into two non-empty sub the string into two no...
Maximum Score After Splitting a String
divide-array-in-sets-of-k-consecutive-numbers
Given a string `s` of zeros and ones, _return the maximum score after splitting the string into two **non-empty** substrings_ (i.e. **left** substring and **right** substring). The score after splitting a string is the number of **zeros** in the **left** substring plus the number of **ones** in the **right** substring...
If the smallest number in the possible-to-split array is V, then numbers V+1, V+2, ... V+k-1 must contain there as well. You can iteratively find k sets and remove them from array until it becomes empty. Failure to do so would mean that array is unsplittable.
Array,Hash Table,Greedy,Sorting
Medium
659,2261
1,091
what is going on everybody it's your boy average leader here with another video and today we're tackling number 1091 shortest path in binary matrix this question is commonly asked by amazon google facebook oracle snapchat and this question was also requested to me by one of my most active subscribers santosh i see you ...
Shortest Path in Binary Matrix
maximum-average-subtree
Given an `n x n` binary matrix `grid`, return _the length of the shortest **clear path** in the matrix_. If there is no clear path, return `-1`. A **clear path** in a binary matrix is a path from the **top-left** cell (i.e., `(0, 0)`) to the **bottom-right** cell (i.e., `(n - 1, n - 1)`) such that: * All the visite...
Can you find the sum of values and the number of nodes for every sub-tree ? Can you find the sum of values and the number of nodes for a sub-tree given the sum of values and the number of nodes of it's left and right sub-trees ? Use depth first search to recursively find the solution for the children of a node then use...
Tree,Depth-First Search,Binary Tree
Medium
2126
981
um hello so today we are going to do this problem which is part of lead codes um daily challenge time based key value store so the problem says is we have a time-based key value data structure time-based key value data structure time-based key value data structure where we can store multiple values for the same key a d...
Time Based Key-Value Store
delete-columns-to-make-sorted
Design a time-based key-value data structure that can store multiple values for the same key at different time stamps and retrieve the key's value at a certain timestamp. Implement the `TimeMap` class: * `TimeMap()` Initializes the object of the data structure. * `void set(String key, String value, int timestamp)...
null
Array,String
Easy
null
429
hello everyone welcome to learn how flow in this video we'll discuss another little problem that is the nre treat or label order traversal so when it's in re you mean it's like the number of child is uh n so what is a binary means we have two children right that's half we have but when you say a that means it can have ...
N-ary Tree Level Order Traversal
n-ary-tree-level-order-traversal
Given an n-ary tree, return the _level order_ traversal of its nodes' values. _Nary-Tree input serialization is represented in their level order traversal, each group of children is separated by the null value (See examples)._ **Example 1:** **Input:** root = \[1,null,3,2,4,null,5,6\] **Output:** \[\[1\],\[3,2,4\],\...
null
null
Medium
null
763
so hello friends today we're gonna discuss a very interesting problem from lead code problem name partition labels so i will be putting out a lot of content on code complete coding as you know but i will be also putting up like a lot of content now on different topics wide variety of topics such that you can practice a...
Partition Labels
special-binary-string
You are given a string `s`. We want to partition the string into as many parts as possible so that each letter appears in at most one part. Note that the partition is done so that after concatenating all the parts in order, the resultant string should be `s`. Return _a list of integers representing the size of these ...
Draw a line from (x, y) to (x+1, y+1) if we see a "1", else to (x+1, y-1). A special substring is just a line that starts and ends at the same y-coordinate, and that is the lowest y-coordinate reached. Call a mountain a special substring with no special prefixes - ie. only at the beginning and end is the lowest y-coo...
String,Recursion
Hard
678
496
[applause] [applause] [applause] [ [ [ applause] [ applause] [ applause] Hello interesting problem name is this next cricketer written curious mines one square in return d answer ok answer is re and this is answer of I is nothing but d next cricketer element ok and explain you What it is question is saying about this e...
Next Greater Element I
next-greater-element-i
The **next greater element** of some element `x` in an array is the **first greater** element that is **to the right** of `x` in the same array. You are given two **distinct 0-indexed** integer arrays `nums1` and `nums2`, where `nums1` is a subset of `nums2`. For each `0 <= i < nums1.length`, find the index `j` such ...
null
Array,Hash Table,Stack,Monotonic Stack
Easy
503,556,739,2227
225
hey everybody this is larry this is day fifth oh cinco de mayo huh uh anyway and i forgot yesterday was may 4th you know may the fourth be with you i don't know i mean i'm just a nerd i guess so i did forget it so maybe not that much of one but anyway uh how does it go felice cinco de mayo i guess uh yeah happy i don't...
Implement Stack using Queues
implement-stack-using-queues
Implement a last-in-first-out (LIFO) stack using only two queues. The implemented stack should support all the functions of a normal stack (`push`, `top`, `pop`, and `empty`). Implement the `MyStack` class: * `void push(int x)` Pushes element x to the top of the stack. * `int pop()` Removes the element on the top...
null
Stack,Design,Queue
Easy
232
509
at lead code 509 fibonacci number and we're just going to solve this in the context of looking at recursion as a tree we're not going to look at the most efficient way to solve this we're just going to look at the recursive way and the idea behind that is i just want to give a little bit of a primer or a warm up into t...
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
8
hello and welcome back to this cracking fang youtube channel today we're going to be solving lead code problem number eight string to integer let's read the question prompt implement the my a2i function which converts a string to a 32-bit signed integer 32-bit signed integer 32-bit signed integer what we want to do is ...
String to Integer (atoi)
string-to-integer-atoi
Implement the `myAtoi(string s)` function, which converts a string to a 32-bit signed integer (similar to C/C++'s `atoi` function). The algorithm for `myAtoi(string s)` is as follows: 1. Read in and ignore any leading whitespace. 2. Check if the next character (if not already at the end of the string) is `'-'` or `...
null
String
Medium
7,65,2168
882
hey what's up guys uh this is sean here so this time lead code number 882 reachable nodes in subdivided graph okay so apparently this is a graph problem right so we're given like graphics unknown labeled from 0 to n minus 1 and then we will subdivide each edge into in the graph into a chain of nodes with number of the ...
Reachable Nodes In Subdivided Graph
peak-index-in-a-mountain-array
You are given an undirected graph (the **"original graph "**) with `n` nodes labeled from `0` to `n - 1`. You decide to **subdivide** each edge in the graph into a chain of nodes, with the number of new nodes varying between each edge. The graph is given as a 2D array of `edges` where `edges[i] = [ui, vi, cnti]` indic...
null
Array,Binary Search
Easy
162,1185,1766
1,296
let's go to question number 1296 divide array in set of k conjecture numbers this is medium question let's get into it given an array of integer norms and a positive integer k find whether it's possible to divide this array into set of k conjecture numbers return to if is password or wise return first let's check the e...
Divide Array in Sets of K Consecutive Numbers
kth-ancestor-of-a-tree-node
Given an array of integers `nums` and a positive integer `k`, check whether it is possible to divide this array into sets of `k` consecutive numbers. Return `true` _if it is possible_. Otherwise, return `false`. **Example 1:** **Input:** nums = \[1,2,3,3,4,4,5,6\], k = 4 **Output:** true **Explanation:** Array can b...
The queries must be answered efficiently to avoid time limit exceeded verdict. Use sparse table (dynamic programming application) to travel the tree upwards in a fast way.
Binary Search,Dynamic Programming,Tree,Depth-First Search,Breadth-First Search,Design
Hard
null
1,010
Hello Hi Everyone Welcome To My Channel It's All The Problem Players Of Song With Total Duration Divisible By 60 Is Problem Thursday Songs Time Duration In Time And Where To Find Number Of Players At That Time Duration Tyohaar Molu 60 subscribe and subscribe the Channel U Will Start From It will start from plus one tim...
Pairs of Songs With Total Durations Divisible by 60
powerful-integers
You are given a list of songs where the `ith` song has a duration of `time[i]` seconds. Return _the number of pairs of songs for which their total duration in seconds is divisible by_ `60`. Formally, we want the number of indices `i`, `j` such that `i < j` with `(time[i] + time[j]) % 60 == 0`. **Example 1:** **Input...
null
Hash Table,Math
Medium
null
889
Ajay Ko Hi Products Dinesh Kumar Website For Wedding Within the video, I will show you the method by generating the binary Jio SIM free and poster and Sir, you will get pre-order and poster and Sir, you will get pre-order and poster and Sir, you will get pre-order and post graduation and I will use the same to regenera...
Construct Binary Tree from Preorder and Postorder Traversal
buddy-strings
Given two integer arrays, `preorder` and `postorder` where `preorder` is the preorder traversal of a binary tree of **distinct** values and `postorder` is the postorder traversal of the same tree, reconstruct and return _the binary tree_. If there exist multiple answers, you can **return any** of them. **Example 1:**...
null
Hash Table,String
Easy
1777,1915
1,881
hello friends welcome to coding interviews channel hope you are doing great if you haven't subscribed to my channel yet please go ahead and subscribe i have created bunch of playlists to cover various categories of problems such as bfs dfs stacks cues dynamic programming and so on please check them out i have uploaded ...
Maximum Value after Insertion
closest-subsequence-sum
You are given a very large integer `n`, represented as a string,​​​​​​ and an integer digit `x`. The digits in `n` and the digit `x` are in the **inclusive** range `[1, 9]`, and `n` may represent a **negative** number. You want to **maximize** `n`**'s numerical value** by inserting `x` anywhere in the decimal represen...
The naive solution is to check all possible subsequences. This works in O(2^n). Divide the array into two parts of nearly is equal size. Consider all subsets of one part and make a list of all possible subset sums and sort this list. Consider all subsets of the other part, and for each one, let its sum = x, do binary s...
Array,Two Pointers,Dynamic Programming,Bit Manipulation,Bitmask
Hard
2108,2162
1
hello everyone in this video we're going to see the solution for the leak code problem to some so basically we're given an error of integers and we have to return the indices of the two numbers that add up to a specific target for example given this integer array and the target is 9 you can see that 2 &amp; 7 add targe...
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
141
hello everyone in this video we're going to be going through lead code problem 141 which is linked list cycle this problem States given head the head of a linked list determine if the link list has a cycle in it now there's a cycle in a link list if there is some node in the list that can be reached Again by continuous...
Linked List Cycle
linked-list-cycle
Given `head`, the head of a linked list, determine if the linked list has a cycle in it. There is a cycle in a linked list if there is some node in the list that can be reached again by continuously following the `next` pointer. Internally, `pos` is used to denote the index of the node that tail's `next` pointer is co...
null
Hash Table,Linked List,Two Pointers
Easy
142,202
289
um hello so today we are going to solve this problem called game of life um it's part of lit code daily challenge uh so it's called april challenge so the problem is basically um about the game of life which the kind of the rules are described here so we have m by n grid of cells each cell has an initial state which is...
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
635
hey everybody this is Larry this is January 24th of 2023 it is me doing an extra question so let's get to it oh nope any difficulty is fine as long as I haven't done it before and today's problem is 6 35 a premium problem for design log storage system hit the like button hit the Subscribe button join me on Discord uh l...
Design Log Storage System
design-log-storage-system
You are given several logs, where each log contains a unique ID and timestamp. Timestamp is a string that has the following format: `Year:Month:Day:Hour:Minute:Second`, for example, `2017:01:01:23:59:59`. All domains are zero-padded decimal numbers. Implement the `LogSystem` class: * `LogSystem()` Initializes the `...
null
Hash Table,String,Design,Ordered Set
Medium
588
114
we need to convert it to english so let's try to find out quite a question we have given the root of binary tree platinum trend to link this simply says we have given binary tree one two three four one five six we need to converting serial number one two three ascending order with the help of several methods so in this...
Flatten Binary Tree to Linked List
flatten-binary-tree-to-linked-list
Given the `root` of a binary tree, flatten the tree into a "linked list ": * The "linked list " should use the same `TreeNode` class where the `right` child pointer points to the next node in the list and the `left` child pointer is always `null`. * The "linked list " should be in the same order as a [**pre-order*...
If you notice carefully in the flattened tree, each node's right child points to the next node of a pre-order traversal.
Linked List,Stack,Tree,Depth-First Search,Binary Tree
Medium
766,1796
203
hey everybody today I'll be doing another lead code one two three uh one not one two three two zero three remove linkless elements and this is an easy one and we have already done a problem similar to this in which we have removed the duplicates from the list uh this follows the same concept whenever we reach our targe...
Remove Linked List Elements
remove-linked-list-elements
Given the `head` of a linked list and an integer `val`, remove all the nodes of the linked list that has `Node.val == val`, and return _the new head_. **Example 1:** **Input:** head = \[1,2,6,3,4,5,6\], val = 6 **Output:** \[1,2,3,4,5\] **Example 2:** **Input:** head = \[\], val = 1 **Output:** \[\] **Example 3:**...
null
Linked List,Recursion
Easy
27,237,2216
771
foreign problem and the problem's name is dwells and Stones so in this question we are given two strings dwells and Stones so this string denotes the stones we have so our task is to know how many of the stones we have are also jewels and the characters inside these two strings are case sensitive which means lowercase ...
Jewels and Stones
encode-n-ary-tree-to-binary-tree
You're given strings `jewels` representing the types of stones that are jewels, and `stones` representing the stones you have. Each character in `stones` is a type of stone you have. You want to know how many of the stones you have are also jewels. Letters are case sensitive, so `"a "` is considered a different type o...
null
Tree,Depth-First Search,Breadth-First Search,Design,Binary Tree
Hard
765
435
hello everyone welcome to my channel coding together my name is vikas ojha today we will see another lead code problem non-overlapping intervals that's the non-overlapping intervals that's the non-overlapping intervals that's the question number 435 it's a medium type question so we are given an array of intervals wher...
Non-overlapping Intervals
non-overlapping-intervals
Given an array of intervals `intervals` where `intervals[i] = [starti, endi]`, return _the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping_. **Example 1:** **Input:** intervals = \[\[1,2\],\[2,3\],\[3,4\],\[1,3\]\] **Output:** 1 **Explanation:** \[1,3\] can be removed ...
null
Array,Dynamic Programming,Greedy,Sorting
Medium
452
392
foreign welcome back to my channel and today we guys are going to solve a new lead code question that is subsequence so guys just before starting to solve this question please do subscribe to the channel hit the like button press the Bell icon button and bookmark the playlist so that you can get the updates from the ch...
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,701
Hi everyone welcome to my YouTube channel, today we are not very good, the average waiting time is 1701, we will understand what is this problem and what is required from us, there is a restaurant with single. There is one chef in our restaurant and there is only one chef in the restaurant, okay, there is only one chef...
Average Waiting Time
remove-max-number-of-edges-to-keep-graph-fully-traversable
There is a restaurant with a single chef. You are given an array `customers`, where `customers[i] = [arrivali, timei]:` * `arrivali` is the arrival time of the `ith` customer. The arrival times are sorted in **non-decreasing** order. * `timei` is the time needed to prepare the order of the `ith` customer. When a ...
Build the network instead of removing extra edges. Suppose you have the final graph (after removing extra edges). Consider the subgraph with only the edges that Alice can traverse. What structure does this subgraph have? How many edges are there? Use disjoint set union data structure for both Alice and Bob. Always use ...
Union Find,Graph
Hard
null
1,168
hi everyone with Kelvin here so let's discuss about be weekly contest 7 for question optimized water distribution in the village so we are having n houses in a finished and then there is an option to put water source to each of the house with given cost in variable called wells so first house needs need cost of one to ...
Optimize Water Distribution in a Village
duplicate-zeros
There are `n` houses in a village. We want to supply water for all the houses by building wells and laying pipes. For each house `i`, we can either build a well inside it directly with cost `wells[i - 1]` (note the `-1` due to **0-indexing**), or pipe in water from another well to it. The costs to lay pipes between ho...
This is a great introductory problem for understanding and working with the concept of in-place operations. The problem statement clearly states that we are to modify the array in-place. That does not mean we cannot use another array. We just don't have to return anything. A better way to solve this would be without us...
Array,Two Pointers
Easy
null
1,209
Had a big Ajit Mahajan welcome talk on WhatsApp so this video into this video will be talking about drama number 209 also called as remove duplicates in spring 21 year 2006 champions so let's get a given string yes okay duplicate removal consists of Choosing to that descent and equal latest from this and removing them ...
Remove All Adjacent Duplicates in String II
design-bounded-blocking-queue
You are given a string `s` and an integer `k`, a `k` **duplicate removal** consists of choosing `k` adjacent and equal letters from `s` and removing them, causing the left and the right side of the deleted substring to concatenate together. We repeatedly make `k` **duplicate removals** on `s` until we no longer can. ...
null
Concurrency
Medium
null
4
hello friends welcome to good Hecker this coach material here we're going saw mininum - so Deena risk only father they mininum - so Deena risk only father they mininum - so Deena risk only father they are two saudi-iranian are two saudi-iranian are two saudi-iranian and lungs - of size m and respectively and lungs - of...
Median of Two Sorted Arrays
median-of-two-sorted-arrays
Given two sorted arrays `nums1` and `nums2` of size `m` and `n` respectively, return **the median** of the two sorted arrays. The overall run time complexity should be `O(log (m+n))`. **Example 1:** **Input:** nums1 = \[1,3\], nums2 = \[2\] **Output:** 2.00000 **Explanation:** merged array = \[1,2,3\] and median is ...
null
Array,Binary Search,Divide and Conquer
Hard
null
1,508
hey everybody this is Larry this is me going over range summer sorted sub-arrays sums keep two of the reason sub-arrays sums keep two of the reason sub-arrays sums keep two of the reason contests yeah so basically I don't there may be wasted on doing a more clever way but given that n is only a thousand you can actuall...
Range Sum of Sorted Subarray Sums
longest-happy-prefix
You are given the array `nums` consisting of `n` positive integers. You computed the sum of all non-empty continuous subarrays from the array and then sorted them in non-decreasing order, creating a new array of `n * (n + 1) / 2` numbers. _Return the sum of the numbers from index_ `left` _to index_ `right` (**indexed ...
Use Longest Prefix Suffix (KMP-table) or String Hashing.
String,Rolling Hash,String Matching,Hash Function
Hard
2326
1,481
hello friends welcome to the coding interviews channel hope you are doing great if you haven't subscribed to the channel yet please go ahead and subscribe I have created bunch of playlists to cover various categories of problems dealing with stacks queues linked lists trees graphs and also there are several playlists t...
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
242
hey what's up back to leak code again today i'm going to be doing the valid anagram with javascript this is asking to compare two strings and to see if they are anagrams of each other or essentially if the two words have all the same letters in them and if so just return the true if they don't have all the same letters...
Valid Anagram
valid-anagram
Given two strings `s` and `t`, return `true` _if_ `t` _is an anagram of_ `s`_, and_ `false` _otherwise_. An **Anagram** is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. **Example 1:** **Input:** s = "anagram", t = "nagaram" **...
null
Hash Table,String,Sorting
Easy
49,266,438
1,603
hey everybody this is larry this is me going over q1 of the recent bi-weekly contest 36 uh design parking bi-weekly contest 36 uh design parking bi-weekly contest 36 uh design parking system so this is actually i actually was a little bit slow on this one uh well for me and you'll see why when you see me stop this live...
Design Parking System
running-sum-of-1d-array
Design a parking system for a parking lot. The parking lot has three kinds of parking spaces: big, medium, and small, with a fixed number of slots for each size. Implement the `ParkingSystem` class: * `ParkingSystem(int big, int medium, int small)` Initializes object of the `ParkingSystem` class. The number of slot...
Think about how we can calculate the i-th number in the running sum from the (i-1)-th number.
Array,Prefix Sum
Easy
null
471
everyone welcome to my channel so in this video i'm going to cover the solution to this question calling code string with stratis lens and also at the same time i'm going to briefly cover the general steps we should follow in coding interview so let's get started before we start the real question for today i would real...
Encode String with Shortest Length
encode-string-with-shortest-length
Given a string `s`, encode the string such that its encoded length is the shortest. The encoding rule is: `k[encoded_string]`, where the `encoded_string` inside the square brackets is being repeated exactly `k` times. `k` should be a positive integer. If an encoding process does not make the string shorter, then do n...
null
String,Dynamic Programming
Hard
394,726
1,539
good morning in this question we are gonna see Keith missing positive number although it is marked as easy but if you go on to the integrities of this question to find out okay how to do the better solution then it's actually a medium but yeah let's see that the problem says that we are given an array called error of p...
Kth Missing Positive Number
diagonal-traverse-ii
Given an array `arr` of positive integers sorted in a **strictly increasing order**, and an integer `k`. Return _the_ `kth` _**positive** integer that is **missing** from this array._ **Example 1:** **Input:** arr = \[2,3,4,7,11\], k = 5 **Output:** 9 **Explanation:** The missing positive integers are \[1,5,6,8,9,10...
Notice that numbers with equal sums of row and column indexes belong to the same diagonal. Store them in tuples (sum, row, val), sort them, and then regroup the answer.
Array,Sorting,Heap (Priority Queue)
Medium
null
295
hi folks today let's talk about the code 295 find median front data stream okay fun fact about this problem i added this problem to the code say second between builder is um this guy and my purifier is also sky yes i edit about like 10 problems to lead code yeah so let's take a look at this problem if you haven't reall...
Find Median from Data Stream
find-median-from-data-stream
The **median** is the middle value in an ordered integer list. If the size of the list is even, there is no middle value, and the median is the mean of the two middle values. * For example, for `arr = [2,3,4]`, the median is `3`. * For example, for `arr = [2,3]`, the median is `(2 + 3) / 2 = 2.5`. Implement the M...
null
Two Pointers,Design,Sorting,Heap (Priority Queue),Data Stream
Hard
480,1953,2207
867
good morning min what is up nerds and don't worry I'm probably the biggest nerd here today I'm working on transpose matrix so I need you to know how to do this before I did a problem I posted yesterday my slack channel called rotate image so that was basically prerequisite so I'm gonna go over this one real quick this ...
Transpose Matrix
new-21-game
Given a 2D integer array `matrix`, return _the **transpose** of_ `matrix`. The **transpose** of a matrix is the matrix flipped over its main diagonal, switching the matrix's row and column indices. **Example 1:** **Input:** matrix = \[\[1,2,3\],\[4,5,6\],\[7,8,9\]\] **Output:** \[\[1,4,7\],\[2,5,8\],\[3,6,9\]\] **E...
null
Math,Dynamic Programming,Sliding Window,Probability and Statistics
Medium
null