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
645
foreign mismatch in uh JavaScript um well I'm going to use a hash table to do this so what I'm going to do is create a hash table and then when we're creating it we'll be able to see if there's duplicate in it and then after that so this will get the duplicate and then after that what we'll do is we'll search in the ta...
Set Mismatch
set-mismatch
You have a set of integers `s`, which originally contains all the numbers from `1` to `n`. Unfortunately, due to some error, one of the numbers in `s` got duplicated to another number in the set, which results in **repetition of one** number and **loss of another** number. You are given an integer array `nums` represe...
null
Array,Hash Table,Bit Manipulation,Sorting
Easy
287
371
hello everyone welcome back and today we are looking at question 371 which is sum of two integers so we are given two integers a and b and we want to return the sum of these two integers without using the plus and the minus okay now so example one is saying a equals one b equals to two one plus two equals three now exa...
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
130
hi everyone so let's talk about surround regions so you are given um by a matrix so containing x and circle capture all regions that are four directional surrounding by x so all so a region is captured by flipping o z uh oo into x in the surrounding region so for example if you have uh three or uh three o inside a uh t...
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
795
hey everybody this is larry this is the 17th of june uh on the june lead code daily challenge hit the like button hit the subscribe button join me on discord let me know what you think about today's problem uh and it is loading number of subways with bounded maximums so usually i uh solve these live so if it's a little...
Number of Subarrays with Bounded Maximum
k-th-symbol-in-grammar
Given an integer array `nums` and two integers `left` and `right`, return _the number of contiguous non-empty **subarrays** such that the value of the maximum array element in that subarray is in the range_ `[left, right]`. The test cases are generated so that the answer will fit in a **32-bit** integer. **Example 1:...
Try to represent the current (N, K) in terms of some (N-1, prevK). What is prevK ?
Math,Bit Manipulation,Recursion
Medium
null
304
hello guys welcome back to tech dose and in this video we will see the range sum query on a 2d matrix problem which is from lead code number 304 in this problem given a 2d matrix handle multiple queries of the following type so calculate the sum of the elements of the matrix inside the rectangle defined by the upper le...
Range Sum Query 2D - Immutable
range-sum-query-2d-immutable
Given a 2D matrix `matrix`, handle multiple queries of the following type: * Calculate the **sum** of the elements of `matrix` inside the rectangle defined by its **upper left corner** `(row1, col1)` and **lower right corner** `(row2, col2)`. Implement the `NumMatrix` class: * `NumMatrix(int[][] matrix)` Initial...
null
Array,Design,Matrix,Prefix Sum
Medium
303,308
791
hi everyone what's up all good so today we will be solving the question custom sord is so let's see what is this question saying so as you can see from the name that custom salt anding so like we do need to we might need to do some sort custom sorting on a string okay so let's see what's the question you are given two ...
Custom Sort String
split-bst
You are given two strings order and s. All the characters of `order` are **unique** and were sorted in some custom order previously. Permute the characters of `s` so that they match the order that `order` was sorted. More specifically, if a character `x` occurs before a character `y` in `order`, then `x` should occur ...
Use recursion. If root.val <= V, you split root.right into two halves, then join it's left half back on root.right.
Tree,Binary Search Tree,Recursion,Binary Tree
Medium
450
995
hey everybody this is larry this is me doing a bonus question for extra practice one that i haven't done before by using a random thing hit the like button hit the subscribe button join me on discord let me know what you think about this method do you have a question do you have a problem uh let me know in the descript...
Minimum Number of K Consecutive Bit Flips
minimum-number-of-k-consecutive-bit-flips
You are given a binary array `nums` and an integer `k`. A **k-bit flip** is choosing a **subarray** of length `k` from `nums` and simultaneously changing every `0` in the subarray to `1`, and every `1` in the subarray to `0`. Return _the minimum number of **k-bit flips** required so that there is no_ `0` _in the arra...
null
null
Hard
null
103
Ajay Ko that welcome back friends today we are going to solid code problem 103 liner district level and driver surf he start looking details about this problem and its implementation just want to mention that if you really don't solution videos in java and java j2ee interview related Helpful Material 100 Please subscri...
Binary Tree Zigzag Level Order Traversal
binary-tree-zigzag-level-order-traversal
Given the `root` of a binary tree, return _the zigzag level order traversal of its nodes' values_. (i.e., from left to right, then right to left for the next level and alternate between). **Example 1:** **Input:** root = \[3,9,20,null,null,15,7\] **Output:** \[\[3\],\[20,9\],\[15,7\]\] **Example 2:** **Input:** roo...
null
Tree,Breadth-First Search,Binary Tree
Medium
102
131
welcome to me tim solving legal problems this question is called palindrome partitioning all right given a string s partition s such that every substring of the partition is a palindrome we turn all possible pound partitionings of s a palindrome string is a string that reads the same backward as forward so what does it...
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
128
welcome to june's lego challenge today's problem is longest consecutive sequence given an unsorted array of integers nums return the length of the longest consecutive element sequence you must write an algorithm that runs in o event time but let's forget that for a second uh say that we had this list of numbers what is...
Longest Consecutive Sequence
longest-consecutive-sequence
Given an unsorted array of integers `nums`, return _the length of the longest consecutive elements sequence._ You must write an algorithm that runs in `O(n)` time. **Example 1:** **Input:** nums = \[100,4,200,1,3,2\] **Output:** 4 **Explanation:** The longest consecutive elements sequence is `[1, 2, 3, 4]`. Therefor...
null
Array,Hash Table,Union Find
Medium
298,2278
247
hey guys how's it going this is JC who is not good at algorithms in this video I'm going to take a look at 2:47 strobo I'm going to take a look at 2:47 strobo I'm going to take a look at 2:47 strobo dramatic number two a stripper chromatic number is a number that looks like the same we rotated 180 degrees look it up up...
Strobogrammatic Number II
strobogrammatic-number-ii
Given an integer `n`, return all the **strobogrammatic numbers** that are of length `n`. You may return the answer in **any order**. A **strobogrammatic number** is a number that looks the same when rotated `180` degrees (looked at upside down). **Example 1:** **Input:** n = 2 **Output:** \["11","69","88","96"\] **...
Try to use recursion and notice that it should recurse with n - 2 instead of n - 1.
Array,String,Recursion
Medium
246,248,2202
3
hello everyone welcome to the channel today's question is longest substring without repeating characters we are given with a string we need to find the length of longest substring without repeating characters so let's jump to the pendant paper and let's see how this example work and how we can find the solution for thi...
Longest Substring Without Repeating Characters
longest-substring-without-repeating-characters
Given a string `s`, find the length of the **longest** **substring** without repeating characters. **Example 1:** **Input:** s = "abcabcbb " **Output:** 3 **Explanation:** The answer is "abc ", with the length of 3. **Example 2:** **Input:** s = "bbbbb " **Output:** 1 **Explanation:** The answer is "b ", with t...
null
Hash Table,String,Sliding Window
Medium
159,340,1034,1813,2209
465
hello everyone this is official sendo today let's look at the problems uh lit code for cd5 optimal account balancing if you like my videos please subscribe my channel and you can find the complete proper list in video description below let's move on the problem so in these problems um we are given a list of transaction...
Optimal Account Balancing
optimal-account-balancing
You are given an array of transactions `transactions` where `transactions[i] = [fromi, toi, amounti]` indicates that the person with `ID = fromi` gave `amounti $` to the person with `ID = toi`. Return _the minimum number of transactions required to settle the debt_. **Example 1:** **Input:** transactions = \[\[0,1,1...
null
Array,Dynamic Programming,Backtracking,Bit Manipulation,Bitmask
Hard
null
217
hello everyone welcome back and today we are looking at question 217 which is contains duplicate the question is straightforward we are given a nums array and we want to see if this array contains any duplicates if the answer is yes the output should be true but if all the numbers are distinct then we don't have any du...
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
424
so initially a b served as a potential candidate of my substream later on it was replaced by Babb which become a lot which became a longer substrate so the intuition which I'm trying to talk about is this is the core formula which you have to use so today let's talk about this question called longest repeating characte...
Longest Repeating Character Replacement
longest-repeating-character-replacement
You are given a string `s` and an integer `k`. You can choose any character of the string and change it to any other uppercase English character. You can perform this operation at most `k` times. Return _the length of the longest substring containing the same letter you can get after performing the above operations_. ...
null
Hash Table,String,Sliding Window
Medium
340,1046,2119,2134,2319
137
Welcome to Coding Makeover. Today we will solve question number 137. The topic is single number. It will be repeated three times. We have to find D single element except one and that will be our result. We have to solve this question in linear time complexity. If You have seen my previous video ' Ek time tha hai se num...
Single Number II
single-number-ii
Given an integer array `nums` where every element appears **three times** except for one, which appears **exactly once**. _Find the single element and return it_. You must implement a solution with a linear runtime complexity and use only constant extra space. **Example 1:** **Input:** nums = \[2,2,3,2\] **Output:**...
null
Array,Bit Manipulation
Medium
136,260
1,909
all right guys so first let's get into it so here we have 1909 remove one element to make it make the array strictly increasing so let's just read over it once given a zero indexed integer array nums return true if it can be made strictly increasing after removing exactly one element or false otherwise if the array is ...
Remove One Element to Make the Array Strictly Increasing
buildings-with-an-ocean-view
Given a **0-indexed** integer array `nums`, return `true` _if it can be made **strictly increasing** after removing **exactly one** element, or_ `false` _otherwise. If the array is already strictly increasing, return_ `true`. The array `nums` is **strictly increasing** if `nums[i - 1] < nums[i]` for each index `(1 <= ...
You can traverse the buildings from the nearest to the ocean to the furthest. Keep with you the maximum to the right while traversing to determine if you can see the ocean or not.
Array,Stack,Monotonic Stack
Medium
1305
1,048
Is it a face or is Chand Mila the one with eyes like the ocean, tell me what is your name Chand Mila [ Chand Mila [ Chand Mila Is Is Is this the one with eyes like the ocean, tell me what is your name [ this the one with eyes like the ocean, tell me what is your name [ this the one with eyes like the ocean, tell me wha...
Longest String Chain
clumsy-factorial
You are given an array of `words` where each word consists of lowercase English letters. `wordA` is a **predecessor** of `wordB` if and only if we can insert **exactly one** letter anywhere in `wordA` **without changing the order of the other characters** to make it equal to `wordB`. * For example, `"abc "` is a **...
null
Math,Stack,Simulation
Medium
null
114
Jhal Ajay Ko Hello friends welcome to my YouTube channel Teacher was today in this video are going to point question flat in the country to link description what to do is to convert to a form and how to do that what is traversal preorder traversal kaisa hota Means the ghrun is simple so like if this then its traversal ...
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
230
hey folks welcome back to another video today we're looking at question 230 k smallest element in bst uh so the way we'll be approaching this problem is by actually using inorder traversal so what is inaudible it's actually um traversing through a bsd such that it'll give us um an order which is non-non-uh decreasing w...
Kth Smallest Element in a BST
kth-smallest-element-in-a-bst
Given the `root` of a binary search tree, and an integer `k`, return _the_ `kth` _smallest value (**1-indexed**) of all the values of the nodes in the tree_. **Example 1:** **Input:** root = \[3,1,4,null,2\], k = 1 **Output:** 1 **Example 2:** **Input:** root = \[5,3,6,2,4,null,null,1\], k = 3 **Output:** 3 **Cons...
Try to utilize the property of a BST. Try in-order traversal. (Credits to @chan13) What if you could modify the BST node's structure? The optimal runtime complexity is O(height of BST).
Tree,Depth-First Search,Binary Search Tree,Binary Tree
Medium
94,671
1,859
So today we will do the question sorting the sequence, we will do the sentence question, so what is in it is that we have been given an input, the sentence string, in which we have been given some words, behind which their sequence is written, which number will come on which, like That will come at number two, this wil...
Sorting the Sentence
change-minimum-characters-to-satisfy-one-of-three-conditions
A **sentence** is a list of words that are separated by a single space with no leading or trailing spaces. Each word consists of lowercase and uppercase English letters. A sentence can be **shuffled** by appending the **1-indexed word position** to each word then rearranging the words in the sentence. * For example...
Iterate on each letter in the alphabet, and check the smallest number of operations needed to make it one of the following: the largest letter in a and smaller than the smallest one in b, vice versa, or let a and b consist only of this letter. For the first 2 conditions, take care that you can only change characters to...
Hash Table,String,Counting,Prefix Sum
Medium
null
446
okay friends let's solve their arithmetic slices Chuck problem a sequence of numbers called arithmetic if eita consists of at least three elements and if the distance between any two consecutive elements is the same so in this problem we needed to culture the subsequence there are their arithmetic slices in the previou...
Arithmetic Slices II - Subsequence
arithmetic-slices-ii-subsequence
Given an integer array `nums`, return _the number of all the **arithmetic subsequences** of_ `nums`. A sequence of numbers is called arithmetic if it consists of **at least three elements** and if the difference between any two consecutive elements is the same. * For example, `[1, 3, 5, 7, 9]`, `[7, 7, 7, 7]`, and ...
null
Array,Dynamic Programming
Hard
413
155
hey what's up guys babybear4812 coming at you one more time and today we're doing an older problem uh it's problem 155 it's called min stock it's an object oriented design problem so i think it's a really cool one and i think it's super deceptively marked as easy because it is not easy this one definitely isn't easy at...
Min Stack
min-stack
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. Implement the `MinStack` class: * `MinStack()` initializes the stack object. * `void push(int val)` pushes the element `val` onto the stack. * `void pop()` removes the element on the top of the stack. * `int top(...
Consider each node in the stack having a minimum value. (Credits to @aakarshmadhavan)
Stack,Design
Easy
239,716
42
hello and welcome back to the cracking Fang YouTube channel today we're solving one of the most legendary problems on lead code number 42 trapping rainwater before we get into the question prompt if you haven't already done number 11 container with most water stop this video go do that one because this problem hinges a...
Trapping Rain Water
trapping-rain-water
Given `n` non-negative integers representing an elevation map where the width of each bar is `1`, compute how much water it can trap after raining. **Example 1:** **Input:** height = \[0,1,0,2,1,0,1,3,2,1,2,1\] **Output:** 6 **Explanation:** The above elevation map (black section) is represented by array \[0,1,0,2,1,...
null
Array,Two Pointers,Dynamic Programming,Stack,Monotonic Stack
Hard
11,238,407,756
1,299
let's solve leak code $12.99 replace let's solve leak code $12.99 replace let's solve leak code $12.99 replace elements with a greatest element on the right side so we're given an array and we want to take each element in the array for example 17 and replace it with the greatest element on the right side of it so we sc...
Replace Elements with Greatest Element on Right Side
k-concatenation-maximum-sum
Given an array `arr`, replace every element in that array with the greatest element among the elements to its right, and replace the last element with `-1`. After doing so, return the array. **Example 1:** **Input:** arr = \[17,18,5,4,6,1\] **Output:** \[18,6,6,6,1,-1\] **Explanation:** - index 0 --> the greatest e...
How to solve the problem for k=1 ? Use Kadane's algorithm for k=1. What are the possible cases for the answer ? The answer is the maximum between, the answer for k=1, the sum of the whole array multiplied by k, or the maximum suffix sum plus the maximum prefix sum plus (k-2) multiplied by the whole array sum for k > 1.
Array,Dynamic Programming
Medium
null
232
hey guys welcome or welcome back to my channel so today we are going to discuss another problem is Implement queue using stacks so in this problem we'll be we'll have to implement a first and first out queue using only two stacks so we can take two stacks and we have to implement a q the implemented queue should suppor...
Implement Queue using Stacks
implement-queue-using-stacks
Implement a first in first out (FIFO) queue using only two stacks. The implemented queue should support all the functions of a normal queue (`push`, `peek`, `pop`, and `empty`). Implement the `MyQueue` class: * `void push(int x)` Pushes element x to the back of the queue. * `int pop()` Removes the element from th...
null
Stack,Design,Queue
Easy
225
1,329
hey what's up guys John here today I want to talk about this distorting problem here number 1329 sword the matrix there diagonally so okay so let's take a look you're given M times in size matrix and you need to sort out adamance diagonally which means from left from top left corner to the bottom right corner it has to...
Sort the Matrix Diagonally
minimum-cost-to-move-chips-to-the-same-position
A **matrix diagonal** is a diagonal line of cells starting from some cell in either the topmost row or leftmost column and going in the bottom-right direction until reaching the matrix's end. For example, the **matrix diagonal** starting from `mat[2][0]`, where `mat` is a `6 x 3` matrix, includes cells `mat[2][0]`, `ma...
The first move keeps the parity of the element as it is. The second move changes the parity of the element. Since the first move is free, if all the numbers have the same parity, the answer would be zero. Find the minimum cost to make all the numbers have the same parity.
Array,Math,Greedy
Easy
1895
515
all right let's talk about the find largest value in each tree rule so given a root of binary tree written the array of the largest value in each row in the three hours so this is the tree and then what you actually need to do is you traverse every single level and then find the largest one and then the range is betwee...
Find Largest Value in Each Tree Row
find-largest-value-in-each-tree-row
Given the `root` of a binary tree, return _an array of the largest value in each row_ of the tree **(0-indexed)**. **Example 1:** **Input:** root = \[1,3,2,5,3,null,9\] **Output:** \[1,3,9\] **Example 2:** **Input:** root = \[1,2,3\] **Output:** \[1,3\] **Constraints:** * The number of nodes in the tree will be...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Medium
null
117
Hello hello and welcome to day itself in the assembly at 40 today's questions flirting next ride point is not second od ministry and you need to play list next right points for it's not byte fold electronics ride point if given winners will send you are soaking Date for the First Women Purpose 9X Elements Write for Sec...
Populating Next Right Pointers in Each Node II
populating-next-right-pointers-in-each-node-ii
Given a binary tree struct Node { int val; Node \*left; Node \*right; Node \*next; } Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set to `NULL`. Initially, all next pointers are set to `NULL`. **Example 1:** **Input:** root = \[1,2,3...
null
Linked List,Tree,Depth-First Search,Breadth-First Search,Binary Tree
Medium
116
1,029
hi I'm today I'll be doing the problem to city scheduling there are two and people a company is planning to interview the cost of flying the eighth person to city a is costs of I of zero and the cost of flying the ithe person to city B is costs of I of one so return the minimum cost to fly every person to a city such t...
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
169
what's up youtube today we're going to take a look at leaker problem number 169 majority element marked as easy let's get into it so this one has a lot of upwards quite easy to understand and the problem statement is just a few lines given an area of size n find the maturity element is the element that appears more tha...
Majority Element
majority-element
Given an array `nums` of size `n`, return _the majority element_. The majority element is the element that appears more than `⌊n / 2⌋` times. You may assume that the majority element always exists in the array. **Example 1:** **Input:** nums = \[3,2,3\] **Output:** 3 **Example 2:** **Input:** nums = \[2,2,1,1,1,2,...
null
Array,Hash Table,Divide and Conquer,Sorting,Counting
Easy
229,1102
32
hello everyone welcome to another episode of coding decoded my name is sanjay rudeja i'm working as technical architect sd4 at adobe and here i present the 697 of daily liquid problem the question that we have in today's longest valid parenthesis it's a hard level question on lead code but i don't feel the same for all...
Longest Valid Parentheses
longest-valid-parentheses
Given a string containing just the characters `'('` and `')'`, return _the length of the longest valid (well-formed) parentheses_ _substring_. **Example 1:** **Input:** s = "(() " **Output:** 2 **Explanation:** The longest valid parentheses substring is "() ". **Example 2:** **Input:** s = ")()()) " **Output:** ...
null
String,Dynamic Programming,Stack
Hard
20
72
Del code problem number 72 edit distance so this problem gives us two strings word one and word two and the goal is to return the minimum number of operations required to re convert the string word one to word two so here it gives us three operations we can either insert a character delete a character or replace a char...
Edit Distance
edit-distance
Given two strings `word1` and `word2`, return _the minimum number of operations required to convert `word1` to `word2`_. You have the following three operations permitted on a word: * Insert a character * Delete a character * Replace a character **Example 1:** **Input:** word1 = "horse ", word2 = "ros " **O...
null
String,Dynamic Programming
Hard
161,583,712,1105,2311
17
we're looking at lead code at number 17 letter combinations of a phone number this is a very frequently asked question we can see here that amazon microsoft facebook i mean everyone's asking this question just even the last in the last six months um even in the last year even the last two years this question is frequen...
Letter Combinations of a Phone Number
letter-combinations-of-a-phone-number
Given a string containing digits from `2-9` inclusive, return all possible letter combinations that the number could represent. Return the answer in **any order**. A mapping of digits to letters (just like on the telephone buttons) is given below. Note that 1 does not map to any letters. **Example 1:** **Input:** di...
null
Hash Table,String,Backtracking
Medium
22,39,401
1,091
Hello Everyone Most Interesting Shot In The Soil Which Can Travel From Top To Bottom And Elements Subscribe Iss Time Se Chalkar Algorithm And It's Not Its Roles And Have A Chance Of Moving Element To All The Best All The Last Gautam A And Sunao Share Dozen Condition That You Can Travel In All Directions 31000 Must Subs...
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
130
Hello guys welcome back on trek to join this video will see 10 round entries problem wish to meet on date 17th June challenge so let's not look at the problem statement in this problem is requested to capture and 1000 latest examples to understand you can see a GROUP OF VALUES ARE YAAR COLLECTION ONLINE TOP 200 AND SUB...
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,738
Label Ab To-Do List Wali Mantra Contest Prestage Label Ab To-Do List Wali Mantra Contest Prestage Label Ab To-Do List Wali Mantra Contest Prestage Plant Question Middle Age subscribe to the Page if you liked The Video then subscribe to the Video then subscribe to ki aisa video mein blood pressure not valid k samsung du...
Find Kth Largest XOR Coordinate Value
maximal-network-rank
You are given a 2D `matrix` of size `m x n`, consisting of non-negative integers. You are also given an integer `k`. The **value** of coordinate `(a, b)` of the matrix is the XOR of all `matrix[i][j]` where `0 <= i <= a < m` and `0 <= j <= b < n` **(0-indexed)**. Find the `kth` largest value **(1-indexed)** of all th...
Try every pair of different cities and calculate its network rank. The network rank of two vertices is almost the sum of their degrees. How can you efficiently check if there is a road connecting two different cities?
Graph
Medium
null
1,944
hello and welcome back to the cracking fang youtube channel today we're going to be solving lead code problem 1944 number of visible people in a queue there are n people standing in a queue and they are numbered from 0 to n minus 1 in left to right order you are given an array of heights of distinct integers where heig...
Number of Visible People in a Queue
truncate-sentence
There are `n` people standing in a queue, and they numbered from `0` to `n - 1` in **left to right** order. You are given an array `heights` of **distinct** integers where `heights[i]` represents the height of the `ith` person. A person can **see** another person to their right in the queue if everybody in between is ...
It's easier to solve this problem on an array of strings so parse the string to an array of words After return the first k words as a sentence
Array,String
Easy
null
1,678
Jhaal Hello Guys my name is Faisla Welcome to our YouTube channel and today we will go to call this question whose name is that parcel interpretation then the previous one question Pollard subscribe to a bend in the terrorist end and bell in mode video will go so this Don't forget to subscribe for 40 days Printers Inte...
Goal Parser Interpretation
number-of-ways-to-split-a-string
You own a **Goal Parser** that can interpret a string `command`. The `command` consists of an alphabet of `"G "`, `"() "` and/or `"(al) "` in some order. The Goal Parser will interpret `"G "` as the string `"G "`, `"() "` as the string `"o "`, and `"(al) "` as the string `"al "`. The interpreted strings are then concat...
There is no way if the sum (number of '1's) is not divisible by the number of splits. So sum%3 should be 0. Preffix s1 , and suffix s3 should have sum/3 characters '1'. Follow up: Can you generalize the problem with numbers between [-10^9, 10^9] such the sum between subarrays s1, s2, s3 are the same?
Math,String
Medium
548
873
hello so today i'm going to take a look at this problem called length of longest fibonacci sequence and the problem says that we get um we get a list of positive numbers and we want to return the length of the longest subsequence of that array um that has length 3 and that satisfies the property a that equal to a i min...
Length of Longest Fibonacci Subsequence
guess-the-word
A sequence `x1, x2, ..., xn` is _Fibonacci-like_ if: * `n >= 3` * `xi + xi+1 == xi+2` for all `i + 2 <= n` Given a **strictly increasing** array `arr` of positive integers forming a sequence, return _the **length** of the longest Fibonacci-like subsequence of_ `arr`. If one does not exist, return `0`. A **subseq...
null
Array,Math,String,Interactive,Game Theory
Hard
null
209
hello yeah so it's 6 July 2023 today's Challenge and Lead code is sum it's a medium level question we'll see what the question States the question states that they've been given a nums Vector nums area and then a Target we have to return the minimum length of a sub array whose sum is greater than or E greater than or e...
Minimum Size Subarray Sum
minimum-size-subarray-sum
Given an array of positive integers `nums` and a positive integer `target`, return _the **minimal length** of a_ _subarray_ _whose sum is greater than or equal to_ `target`. If there is no such subarray, return `0` instead. **Example 1:** **Input:** target = 7, nums = \[2,3,1,2,4,3\] **Output:** 2 **Explanation:** Th...
null
Array,Binary Search,Sliding Window,Prefix Sum
Medium
76,325,718,1776,2211,2329
864
hello friends today let's solve the shortest parts to get all keys the problem is similar we are given two dimensional grid but we have the dot the at and the smaller letters are keys and the capital i mean the lowercase letters are keys and the capital upper case of the letters are locks and we start at the starting p...
Shortest Path to Get All Keys
image-overlap
You are given an `m x n` grid `grid` where: * `'.'` is an empty cell. * `'#'` is a wall. * `'@'` is the starting point. * Lowercase letters represent keys. * Uppercase letters represent locks. You start at the starting point and one move consists of walking one space in one of the four cardinal directions. ...
null
Array,Matrix
Medium
null
419
all right let's talk about the battleship in the board so we're given a biometric and then there's an x and then there's a dot in the 2d array so you want to return the number of the battery sheet on the board so this question is super straightforward so the bandage is going to be horizontal or vertical right and then ...
Battleships in a Board
battleships-in-a-board
Given an `m x n` matrix `board` where each cell is a battleship `'X'` or empty `'.'`, return _the number of the **battleships** on_ `board`. **Battleships** can only be placed horizontally or vertically on `board`. In other words, they can only be made of the shape `1 x k` (`1` row, `k` columns) or `k x 1` (`k` rows, ...
null
Array,Depth-First Search,Matrix
Medium
null
1,011
Hi gas welcome and welcome back tu my channel so today we are going tu discuss in adar problem problems bhi shift from van tu andar wooden days ok so same amount of days are given and all the packages c have tu shift from adar Weaving dies the days are dis package on de conveyor belt has weight this so this zero packet...
Capacity To Ship Packages Within D Days
flip-binary-tree-to-match-preorder-traversal
A conveyor belt has packages that must be shipped from one port to another within `days` days. The `ith` package on the conveyor belt has a weight of `weights[i]`. Each day, we load the ship with packages on the conveyor belt (in the order given by `weights`). We may not load more weight than the maximum weight capaci...
null
Tree,Depth-First Search,Binary Tree
Medium
null
122
alright so today's 35 of the April lead coding challenge the question is best time to buy and sell stock - we have a time to buy and sell stock - we have a time to buy and sell stock - we have a already representing the stock price at the I so we are only looking at a one stock and basically we're looking at the back h...
Best Time to Buy and Sell Stock II
best-time-to-buy-and-sell-stock-ii
You are given an integer array `prices` where `prices[i]` is the price of a given stock on the `ith` day. On each day, you may decide to buy and/or sell the stock. You can only hold **at most one** share of the stock at any time. However, you can buy it then immediately sell it on the **same day**. Find and return _t...
null
Array,Dynamic Programming,Greedy
Medium
121,123,188,309,714
141
hello everyone welcome to another video um this is the first video of the series on lead code and today we're going to talk about uh Le lead code 141 so uh on the left side we can see the problem and on the right side we're going to go through the problem find out ideas and ways to approach it so uh let's go through th...
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
423
hello everyone welcome to my youtube channel the question for today is reconstruct original digits from english all right so given a non-empty english all right so given a non-empty english all right so given a non-empty string the string is not empty containing out of order english representation of digits from zero t...
Reconstruct Original Digits from English
reconstruct-original-digits-from-english
Given a string `s` containing an out-of-order English representation of digits `0-9`, return _the digits in **ascending** order_. **Example 1:** **Input:** s = "owoztneoer" **Output:** "012" **Example 2:** **Input:** s = "fviefuro" **Output:** "45" **Constraints:** * `1 <= s.length <= 105` * `s[i]` is one of ...
null
Hash Table,Math,String
Medium
null
653
hey everyone welcome back and today we will be doing another lead code problem six five three two some for input is a binary search tree this is also October 9 lead code Challenge and we are doing it this is an easy one given the root of a binary tree a search tree and our Target number K return true if there exists Tw...
Two Sum IV - Input is a BST
two-sum-iv-input-is-a-bst
Given the `root` of a binary search tree and an integer `k`, return `true` _if there exist two elements in the BST such that their sum is equal to_ `k`, _or_ `false` _otherwise_. **Example 1:** **Input:** root = \[5,3,6,2,4,null,7\], k = 9 **Output:** true **Example 2:** **Input:** root = \[5,3,6,2,4,null,7\], k = ...
null
Hash Table,Two Pointers,Tree,Depth-First Search,Breadth-First Search,Binary Search Tree,Binary Tree
Easy
1,167,170,1150
565
hello everyone and welcome back to another video so today we're going to be solving the lead code question area nesting all right so this question is actually pretty interesting because to actually solve it there is a pattern that you have to observe so what i want to do with this question is to kind of show you how yo...
Array Nesting
array-nesting
You are given an integer array `nums` of length `n` where `nums` is a permutation of the numbers in the range `[0, n - 1]`. You should build a set `s[k] = {nums[k], nums[nums[k]], nums[nums[nums[k]]], ... }` subjected to the following rule: * The first element in `s[k]` starts with the selection of the element `num...
null
Array,Depth-First Search
Medium
339,341,364
315
Hello Everyone, today we are going to solve the question on Questions Page Account of Smaller Number After Sale List on 23rd July Challenge 220 In question we have to tell the name of Agri Forest and we have to tell that it is the husband of Egg Particular Index which is number six on the right side of it. What is the ...
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
71
hello everyone welcome to our channel code with sunny and in this video we will be talking about the problem simplify path and it is the medium problem of the daily lead code challenge and its index is seven one okay so before moving on to discuss this problem let me talk about how we can what type of concept that is b...
Simplify Path
simplify-path
Given a string `path`, which is an **absolute path** (starting with a slash `'/'`) to a file or directory in a Unix-style file system, convert it to the simplified **canonical path**. In a Unix-style file system, a period `'.'` refers to the current directory, a double period `'..'` refers to the directory up a level,...
null
String,Stack
Medium
null
134
Hello hi everyone welcome to my channel it's all the gas station problem this is the work of my favorite problem s well s decision problems very favorite in interviews and this problem gas this man found electricity company interview solution to this problem and tricks and saw her end Gas Stations on a Circular Route W...
Gas Station
gas-station
There are `n` gas stations along a circular route, where the amount of gas at the `ith` station is `gas[i]`. You have a car with an unlimited gas tank and it costs `cost[i]` of gas to travel from the `ith` station to its next `(i + 1)th` station. You begin the journey with an empty tank at one of the gas stations. Gi...
null
Array,Greedy
Medium
1346
143
Hello hello everyone welcome back to my channel suggestion or going to discuss the problem hands free mode as it is very interesting problem relative problems yoga ban on head office in least 23 can be represented on the other hand English team in Rio the list to be N follow inform oo hain surya tu report delete means ...
Reorder List
reorder-list
You are given the head of a singly linked-list. The list can be represented as: L0 -> L1 -> ... -> Ln - 1 -> Ln _Reorder the list to be on the following form:_ L0 -> Ln -> L1 -> Ln - 1 -> L2 -> Ln - 2 -> ... You may not modify the values in the list's nodes. Only nodes themselves may be changed. **Example 1:** **...
null
Linked List,Two Pointers,Stack,Recursion
Medium
2216
363
Hello everyone welcome back to my channel Kunjbihari is going to discuss my own problem the problem in 4 inches is maximum material triangle no longer knowledge day off problem no problem is a combination of volume maximum and the second problem is maximum knowledge by combining these two this is The problem is a combi...
Max Sum of Rectangle No Larger Than K
max-sum-of-rectangle-no-larger-than-k
Given an `m x n` matrix `matrix` and an integer `k`, return _the max sum of a rectangle in the matrix such that its sum is no larger than_ `k`. It is **guaranteed** that there will be a rectangle with a sum no larger than `k`. **Example 1:** **Input:** matrix = \[\[1,0,1\],\[0,-2,3\]\], k = 2 **Output:** 2 **Explana...
null
Array,Binary Search,Dynamic Programming,Matrix,Ordered Set
Hard
null
1,863
hello everyone so in this video let us talk about a easy problem from lead code the problem name is sum of all subsets or total so the problem statement goes like this that the zor total of any array is defined as the bitwise door of all its helmet okay now what your overall problem statement is that for a given array ...
Sum of All Subset XOR Totals
sum-of-all-subset-xor-totals
The **XOR total** of an array is defined as the bitwise `XOR` of **all its elements**, or `0` if the array is **empty**. * For example, the **XOR total** of the array `[2,5,6]` is `2 XOR 5 XOR 6 = 1`. Given an array `nums`, return _the **sum** of all **XOR totals** for every **subset** of_ `nums`. **Note:** Subset...
null
null
Easy
null
4
Ajay is like Hello Guys Money members, Sachin Gautam himself is going to ask this question, the name of which is Media will ask for a note. Okay, yes, we had asked this question in the previous video in a like and manner, Media After SM question, we have come up with it. By applying logic, basically you have been place...
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
49
okay guys let's solve 49 which is group anagrams it's one of my favorite problems so we're given an array of strings and we want to group The anagrams together and you can return that answer in any order so we have strings is a list of various strings and we want to return a list of strings where each inner list is all...
Group Anagrams
group-anagrams
Given an array of strings `strs`, group **the anagrams** together. You can return the answer in **any order**. An **Anagram** is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. **Example 1:** **Input:** strs = \["eat","tea","tan...
null
Hash Table,String,Sorting
Medium
242,249
1,814
Hello, how are you? Well, we're going to do an l code today instead of doing the next linear one, we're going to try to get in there and start maintaining a streak of doing the problem of the day. Let's see how long we can keep it up. I 'm not very good. to maintain streaks 'm not very good. to maintain streaks 'm not ...
Count Nice Pairs in an Array
jump-game-vi
You are given an array `nums` that consists of non-negative integers. Let us define `rev(x)` as the reverse of the non-negative integer `x`. For example, `rev(123) = 321`, and `rev(120) = 21`. A pair of indices `(i, j)` is **nice** if it satisfies all of the following conditions: * `0 <= i < j < nums.length` * `nu...
Let dp[i] be "the maximum score to reach the end starting at index i". The answer for dp[i] is nums[i] + max{dp[i+j]} for 1 <= j <= k. That gives an O(n*k) solution. Instead of checking every j for every i, keep track of the largest dp[i] values in a heap and calculate dp[i] from right to left. When the largest value i...
Array,Dynamic Programming,Queue,Sliding Window,Heap (Priority Queue),Monotonic Queue
Medium
239,2001
572
welcome back to uncle Jess today's question is Luke code 572 subtree of another tree we're given a tree and we're given a sub tree and we need to work out whether this sub tree can be found within this tree now this question is very similar to the code 100 same tree which I've made a video for now if you want to go che...
Subtree of Another Tree
subtree-of-another-tree
Given the roots of two binary trees `root` and `subRoot`, return `true` if there is a subtree of `root` with the same structure and node values of `subRoot` and `false` otherwise. A subtree of a binary tree `tree` is a tree that consists of a node in `tree` and all of this node's descendants. The tree `tree` could als...
Which approach is better here- recursive or iterative? If recursive approach is better, can you write recursive function with its parameters? Two trees s and t are said to be identical if their root values are same and their left and right subtrees are identical. Can you write this in form of recursive formulae? Recurs...
Tree,Depth-First Search,String Matching,Binary Tree,Hash Function
Easy
250,508
368
hey everyone today we'll be solving Le problem number 368 largest divisible subset in this problem we are given a set of distinct positive integer nums and we have to return the largest subset answer such that every pair answer I answer J of elements in the subset satisfying these two condition either the answer is div...
Largest Divisible Subset
largest-divisible-subset
Given a set of **distinct** positive integers `nums`, return the largest subset `answer` such that every pair `(answer[i], answer[j])` of elements in this subset satisfies: * `answer[i] % answer[j] == 0`, or * `answer[j] % answer[i] == 0` If there are multiple solutions, return any of them. **Example 1:** **Inp...
null
Array,Math,Dynamic Programming,Sorting
Medium
null
1,203
hey everybody this is Larry this is day 19. is it now I lied day 20 of the league code daily challenge hit the like button hit the Subscribe button drop in this card let me know what you think about this poem uh just a quick minor update um uh yeah the tailbone the contest earlier today uh for me it's earlier today eve...
Sort Items by Groups Respecting Dependencies
print-in-order
There are `n` items each belonging to zero or one of `m` groups where `group[i]` is the group that the `i`\-th item belongs to and it's equal to `-1` if the `i`\-th item belongs to no group. The items and the groups are zero indexed. A group can have no item belonging to it. Return a sorted list of the items such that...
null
Concurrency
Easy
1187
1,423
Quick guys welcome back to my channel like this video we are going to solve maximum points you can get phone calls so what is this problem statement given here you have been given one card points some points have been given in this and given here But it is given here that it is said that you have to pick quartz, there ...
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
740
hey everybody this is larry this is day fifth of the leeco martial challenge hit the like button hit the subscribe button join me on discord let me know what you think about this prom and today and general life um yeah so i today is my last evening in median uh medellin uh so ah i am uh not 100 sober say but we will le...
Delete and Earn
delete-and-earn
You are given an integer array `nums`. You want to maximize the number of points you get by performing the following operation any number of times: * Pick any `nums[i]` and delete it to earn `nums[i]` points. Afterwards, you must delete **every** element equal to `nums[i] - 1` and **every** element equal to `nums[i]...
If you take a number, you might as well take them all. Keep track of what the value is of the subset of the input with maximum M when you either take or don't take M.
Array,Hash Table,Dynamic Programming
Medium
198
1,816
hello everyone welcome to another video now this video is uh different because it is about strings okay uh but it also has an element of arrays as well which we'll be using uh but uh basically this question is about string and it is quite a simple one the question is really simple uh we are given two things right now u...
Truncate Sentence
lowest-common-ancestor-of-a-binary-tree-iv
A **sentence** is a list of words that are separated by a single space with no leading or trailing spaces. Each of the words consists of **only** uppercase and lowercase English letters (no punctuation). * For example, `"Hello World "`, `"HELLO "`, and `"hello world hello world "` are all sentences. You are given a...
Starting from the root, traverse the left and the right subtrees, checking if one of the nodes exist there. If one of the subtrees doesn't contain any given node, the LCA can be the node returned from the other subtree If both subtrees contain nodes, the LCA node is the current node.
Tree,Depth-First Search,Binary Tree
Medium
235,236,1218,1780,1790,1816
921
hello guys welcome to my channel and today we're going to be looking at leeco knight 21 minimum add to make parenthesis valid so given a string as of left parenthesis and right parenthesis we add the minimum number of parentheses and in any position so that results parentheses string is valid formally a parenthesis str...
Minimum Add to Make Parentheses Valid
spiral-matrix-iii
A parentheses string is valid if and only if: * It is the empty string, * It can be written as `AB` (`A` concatenated with `B`), where `A` and `B` are valid strings, or * It can be written as `(A)`, where `A` is a valid string. You are given a parentheses string `s`. In one move, you can insert a parenthesis at...
null
Array,Matrix,Simulation
Medium
54,59
1,557
hey guys this is steve here today we're going to go through legal problem 1557 minimum number of vertices to reach all nodes let's take a look at the problem first given a directed acyclic graph in dac with n vertices numbered from 0 to n minus 1 and an array address where address i is from i and 2i which means the fir...
Minimum Number of Vertices to Reach All Nodes
check-if-a-string-contains-all-binary-codes-of-size-k
Given a **directed acyclic graph**, with `n` vertices numbered from `0` to `n-1`, and an array `edges` where `edges[i] = [fromi, toi]` represents a directed edge from node `fromi` to node `toi`. Find _the smallest set of vertices from which all nodes in the graph are reachable_. It's guaranteed that a unique solution ...
We need only to check all sub-strings of length k. The number of distinct sub-strings should be exactly 2^k.
Hash Table,String,Bit Manipulation,Rolling Hash,Hash Function
Medium
null
1,026
Hello everyone, if we watch today's lead code challenge, a very interesting question has come. Let us see the question. Maximum difference between node and ancestor. If you want to know what is node and this ancestor, ancestors are basically your four fathers. Like if you are a You include yourself, your parents and th...
Maximum Difference Between Node and Ancestor
string-without-aaa-or-bbb
Given the `root` of a binary tree, find the maximum value `v` for which there exist **different** nodes `a` and `b` where `v = |a.val - b.val|` and `a` is an ancestor of `b`. A node `a` is an ancestor of `b` if either: any child of `a` is equal to `b` or any child of `a` is an ancestor of `b`. **Example 1:** **Input...
null
String,Greedy
Medium
null
242
in this video we're going to solve the problem valid anagrams on lead code so given two strings A and B return true if a is an anagram of B and false otherwise so just for recap what exactly is an anagram it is a word or phrase that can be formed by rearranging the letters of the other word or phrase so for example we ...
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,791
we have another question here let's see uh the question says find the center of a star graph okay that's really uh we should receive the question and then we'll solve it okay so uh as the undirected star graph consists of nodes level from 1 to n as Java graph is a graph where the center node is exactly as ish node and ...
Find Center of Star Graph
richest-customer-wealth
There is an undirected **star** graph consisting of `n` nodes labeled from `1` to `n`. A star graph is a graph where there is one **center** node and **exactly** `n - 1` edges that connect the center node with every other node. You are given a 2D integer array `edges` where each `edges[i] = [ui, vi]` indicates that th...
Calculate the wealth of each customer Find the maximum element in array.
Array,Matrix
Easy
null
1,385
yeahyeah Hi everyone, I'm a programmer. Today I will introduce to you the problem of finding the value of the distance between two arrays of integers. The detailed problem requires us as follows. two integer arrays in boxes d1 and d2 and a number D problem. Request to return the distance value between two numbers A. Th...
Find the Distance Value Between Two Arrays
number-of-ways-to-build-house-of-cards
Given two integer arrays `arr1` and `arr2`, and the integer `d`, _return the distance value between the two arrays_. The distance value is defined as the number of elements `arr1[i]` such that there is not any element `arr2[j]` where `|arr1[i]-arr2[j]| <= d`. **Example 1:** **Input:** arr1 = \[4,5,8\], arr2 = \[10,9...
If a row has k triangles, how many cards does it take to build that row? It takes 3 * k - 1 cards. If you still have i cards left, and on the previous row there were k triangles, what are the possible ways to build the current row? You can start at 1 triangle and continue adding more until you run out of cards or reach...
Math,Dynamic Programming
Medium
815
257
hey guys this is it called 257 binary tree paths given a binary tree return our route to live pets a leaf is a node with no children so if an example here a binary tree and the output is a list of string which each node is a string follow followed by an arrow okay so it is to be a ADSs exercise where you need where we ...
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
643
so hello everyone i am a software development engineer so we are starting with this lead code premium top interview problem series we will be discussing each and every problem which are mentioned on the lead code top interviews and also this will help you to crack your next coding interview in the top notch product-bas...
Maximum Average Subarray I
maximum-average-subarray-i
You are given an integer array `nums` consisting of `n` elements, and an integer `k`. Find a contiguous subarray whose **length is equal to** `k` that has the maximum average value and return _this value_. Any answer with a calculation error less than `10-5` will be accepted. **Example 1:** **Input:** nums = \[1,12,...
null
Array,Sliding Window
Easy
644,2211
343
and in female Betim a part of internal bodyguards there interpret but I can't also Break which I called Christ I may have maximized correct that he's more sane here in front Benfica the even more beautiful woman isn't it who knows television reading there's that one to celebrate this birthday school so I don't even rem...
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
703
hey everyone today we are going to substitute for the question case largest element in your Stream So design your class to find the case largest element in your stream note that it is a case largest element in the solid order not the case distinct element Implement case largest cross so case largest taking a digital k ...
Kth Largest Element in a Stream
kth-largest-element-in-a-stream
Design a class to find the `kth` largest element in a stream. Note that it is the `kth` largest element in the sorted order, not the `kth` distinct element. Implement `KthLargest` class: * `KthLargest(int k, int[] nums)` Initializes the object with the integer `k` and the stream of integers `nums`. * `int add(int...
null
null
Easy
null
7
Fifth, my name is Ayush Mishra and you have given this dress to Nishan. Today we are going to talk about our second problem on the list, the name of the problem is our reverse entry. This is the last problem. We looked at all the names that without VPN. Click on our I button and do n't forget to subscribe here Question...
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
282
welcome back to the cracking Thing YouTube channel I want to apologize for the lapse in videos my MacBook Pro died on me and by the time I got it repaired from Apple it's now been two weeks later so hence the lack of videos anyway we are now back and today we're going to be solving 282 expression ad operators so let's ...
Expression Add Operators
expression-add-operators
Given a string `num` that contains only digits and an integer `target`, return _**all possibilities** to insert the binary operators_ `'+'`_,_ `'-'`_, and/or_ `'*'` _between the digits of_ `num` _so that the resultant expression evaluates to the_ `target` _value_. Note that operands in the returned expressions **shoul...
Note that a number can contain multiple digits. Since the question asks us to find all of the valid expressions, we need a way to iterate over all of them. (Hint: Recursion!) We can keep track of the expression string and evaluate it at the very end. But that would take a lot of time. Can we keep track of the expressio...
Math,String,Backtracking
Hard
150,224,227,241,494
242
hey guys today we'll be taking a look at valid anagram uh this problem is a very popular sub problem and uh variations of it show up a lot in more difficult lego problems all right so we'll be taking a look at the intuitive solution for this and then doing a slight bit of optimization to get to our final one which we'l...
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,685
hey everyone today we are going to solve theal question sum of absolute difference in a sorted array okay so let me explain with this example 2 three5 in this case output is 435 so that's because we calculate like this so at index zero 2 - 2 + 2 - 3 plus 2 - 5 and index zero 2 - 2 + 2 - 3 plus 2 - 5 and index zero 2 - ...
Sum of Absolute Differences in a Sorted Array
stone-game-v
You are given an integer array `nums` sorted in **non-decreasing** order. Build and return _an integer array_ `result` _with the same length as_ `nums` _such that_ `result[i]` _is equal to the **summation of absolute differences** between_ `nums[i]` _and all the other elements in the array._ In other words, `result[i...
We need to try all possible divisions for the current row to get the max score. As calculating all possible divisions will lead us to calculate some sub-problems more than once, we need to think of dynamic programming.
Array,Math,Dynamic Programming,Game Theory
Hard
909,1240,1522,1617,1788,1808,2002,2156
153
hey what is up guys welcome back to another Elite code video today we are going to be solving find minimum and rotated sorted array um if you haven't already be sure to check out the search and rotated sorted array video that I put up um because it'll definitely help you get a better understanding of how we're going to...
Find Minimum in Rotated Sorted Array
find-minimum-in-rotated-sorted-array
Suppose an array of length `n` sorted in ascending order is **rotated** between `1` and `n` times. For example, the array `nums = [0,1,2,4,5,6,7]` might become: * `[4,5,6,7,0,1,2]` if it was rotated `4` times. * `[0,1,2,4,5,6,7]` if it was rotated `7` times. Notice that **rotating** an array `[a[0], a[1], a[2], ....
Array was originally in ascending order. Now that the array is rotated, there would be a point in the array where there is a small deflection from the increasing sequence. eg. The array would be something like [4, 5, 6, 7, 0, 1, 2]. You can divide the search space into two and see which direction to go. Can you think ...
Array,Binary Search
Medium
33,154
9
hello everyone today we are going to solve the lead code question number nine pale androme number given an integer X return true if x is a pantr and false otherwise we are given an example here where X is 121 if you reverse 121 it will be again 121 so it is a pant Drome so we are returning true there is another example...
Palindrome Number
palindrome-number
Given an integer `x`, return `true` _if_ `x` _is a_ _**palindrome**__, and_ `false` _otherwise_. **Example 1:** **Input:** x = 121 **Output:** true **Explanation:** 121 reads as 121 from left to right and from right to left. **Example 2:** **Input:** x = -121 **Output:** false **Explanation:** From left to right, i...
Beware of overflow when you reverse the integer.
Math
Easy
234,1375
1,996
hello and welcome back to the cracking fang youtube channel today we're going to be solving lead code problem 1996 number of weak characters in the game before we get into the question you guys know the drill please subscribe if you haven't already and drop a like on the video it really helps me grow alright you are pl...
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,415
hello yours welcome back to my channel I hope you are enjoying all the problems that I am uploading but you haven't subscribed yet please go ahead and subscribe to my channel and share among your friends so today's problem is the Keith lexicographical string of all happy strings of length and a happy string is a string...
The k-th Lexicographical String of All Happy Strings of Length n
students-and-examinations
A **happy string** is a string that: * consists only of letters of the set `['a', 'b', 'c']`. * `s[i] != s[i + 1]` for all values of `i` from `1` to `s.length - 1` (string is 1-indexed). For example, strings **"abc ", "ac ", "b "** and **"abcbabcbcb "** are all happy strings and strings **"aa ", "baa "** and **"a...
null
Database
Easy
null
556
hey what's up guys this is john here so today let's take a look at uh today's daily challenge problem the number 556 next greater element number three so it's like a medium problem okay you're given like a positive integer n and find the smallest integer which has exactly the same digits existing in the integer and is ...
Next Greater Element III
next-greater-element-iii
Given a positive integer `n`, find _the smallest integer which has exactly the same digits existing in the integer_ `n` _and is greater in value than_ `n`. If no such positive integer exists, return `-1`. **Note** that the returned integer should fit in **32-bit integer**, if there is a valid answer but it does not fi...
null
Math,Two Pointers,String
Medium
496,503,1997
3
hi this is josh with over-the-shoulder hi this is josh with over-the-shoulder hi this is josh with over-the-shoulder coding where i help you prepare for software engineering interviews by guiding you through solving real problems today we're back with lead code problems and we are working on number three longest substr...
Longest Substring Without Repeating Characters
longest-substring-without-repeating-characters
Given a string `s`, find the length of the **longest** **substring** without repeating characters. **Example 1:** **Input:** s = "abcabcbb " **Output:** 3 **Explanation:** The answer is "abc ", with the length of 3. **Example 2:** **Input:** s = "bbbbb " **Output:** 1 **Explanation:** The answer is "b ", with t...
null
Hash Table,String,Sliding Window
Medium
159,340,1034,1813,2209
1,910
hey everybody this is larry this is me going with q2 of the bi-weekly me going with q2 of the bi-weekly me going with q2 of the bi-weekly contest 35 remove all occurrences of a substring so this one is actually the concept is not hard but the analysis is and i think that's where i spend most of my time doing the contes...
Remove All Occurrences of a Substring
check-if-binary-string-has-at-most-one-segment-of-ones
Given two strings `s` and `part`, perform the following operation on `s` until **all** occurrences of the substring `part` are removed: * Find the **leftmost** occurrence of the substring `part` and **remove** it from `s`. Return `s` _after removing all occurrences of_ `part`. A **substring** is a contiguous seque...
It's guaranteed to have at least one segment The string size is small so you can count all segments of ones with no that have no adjacent ones.
String
Easy
1999
693
hey everybody this is Larry this is February uh as some of you might know uh when I get a Yeezy is or this prom that I've done before I would try to do uh a random RNG PR that haven't done before so yeah let's RNG this thing up how many problems do I have wow nine pages of this so what is that like at least 450 or some...
Binary Number with Alternating Bits
binary-number-with-alternating-bits
Given a positive integer, check whether it has alternating bits: namely, if two adjacent bits will always have different values. **Example 1:** **Input:** n = 5 **Output:** true **Explanation:** The binary representation of 5 is: 101 **Example 2:** **Input:** n = 7 **Output:** false **Explanation:** The binary repr...
null
Bit Manipulation
Easy
191
1,721
hi everyone welcome to my youtube channel i hope y'all are doing extremely well so today in this video we are going to solve the problem swapping notes in a linked list so first of all we'll be understanding the problem statement and then the logic part and then we'll be moving to the coding part right but before proce...
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
314
hello everyone welcome to soda this is Rina and today we are going to look at the most asked question at Facebook or meta in the last six months so if you say uh if I look for all the Facebook problems and I'm looking for the six months and if I sort them by frequency we get a problem binary tree vertical order travel ...
Binary Tree Vertical Order Traversal
binary-tree-vertical-order-traversal
Given the `root` of a binary tree, return _**the vertical order traversal** of its nodes' values_. (i.e., from top to bottom, column by column). If two nodes are in the same row and column, the order should be from **left to right**. **Example 1:** **Input:** root = \[3,9,20,null,null,15,7\] **Output:** \[\[9\],\[3,...
null
Hash Table,Tree,Depth-First Search,Breadth-First Search,Binary Tree
Medium
102
1,675
Shri Ram Doctor Saheb, all of you will be very good and ask question, you have set up the question like it is very big impossible banna from 24th August, it is a good thing, let's go to Shiv, is it made by him or not, end updates object Auspicious and updated o ok-ok second was quite good quite ok-ok second was quite g...
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
459
hey guys welcome back to another video and today we're going to be solving the leaka question repeated substring pattern all right so in this question we're given a non-empty string given a non-empty string given a non-empty string and we need to check if it can be constructed by taking a substring of it and appending ...
Repeated Substring Pattern
repeated-substring-pattern
Given a string `s`, check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. **Example 1:** **Input:** s = "abab " **Output:** true **Explanation:** It is the substring "ab " twice. **Example 2:** **Input:** s = "aba " **Output:** false **Example 3:** ...
null
String,String Matching
Easy
28,686
1,689
hello everyone i hope you all are doing well so today we will be discussing the problem number one six eight nine that is partitioning into minimum number of decimal numbers the problem says that given a string n that represents a positive decimal integer return the minimum number of positive dashi binary numbers neede...
Partitioning Into Minimum Number Of Deci-Binary Numbers
detect-pattern-of-length-m-repeated-k-or-more-times
A decimal number is called **deci-binary** if each of its digits is either `0` or `1` without any leading zeros. For example, `101` and `1100` are **deci-binary**, while `112` and `3001` are not. Given a string `n` that represents a positive decimal integer, return _the **minimum** number of positive **deci-binary** n...
Use a three-layer loop to check all possible patterns by iterating through all possible starting positions, all indexes less than m, and if the character at the index is repeated k times.
Array,Enumeration
Easy
1764
27
hey everyone today let's solve the lead code 27 which is remove element if you followed along with our last video on static arrays you would have been left with this lead code challenge we're going to break it down today the problem asks you to remove all instances of a particular value in an array in place so given an...
Remove Element
remove-element
Given an integer array `nums` and an integer `val`, remove all occurrences of `val` in `nums` [**in-place**](https://en.wikipedia.org/wiki/In-place_algorithm). The order of the elements may be changed. Then return _the number of elements in_ `nums` _which are not equal to_ `val`. Consider the number of elements in `nu...
The problem statement clearly asks us to modify the array in-place and it also says that the element beyond the new length of the array can be anything. Given an element, we need to remove all the occurrences of it from the array. We don't technically need to remove that element per-say, right? We can move all the occu...
Array,Two Pointers
Easy
26,203,283
1,306
hello friends so today in this video we're gonna discuss three problems from lead code all the three problems are related to each other the three problems are jump game one jump game two and jump game three the first problem in the last problem is a medium level problem and the second problem is a hard level problem so...
Jump Game III
minimum-absolute-difference
Given an array of non-negative integers `arr`, you are initially positioned at `start` index of the array. When you are at index `i`, you can jump to `i + arr[i]` or `i - arr[i]`, check if you can reach to **any** index with value 0. Notice that you can not jump outside of the array at any time. **Example 1:** **Inp...
Find the minimum absolute difference between two elements in the array. The minimum absolute difference must be a difference between two consecutive elements in the sorted array.
Array,Sorting
Easy
2248
875
hey everyone welcome back and let's write some more neat code today so today let's solve coco eating bananas but before we do i just want to say that if you do have any requested problems you can feel free to leave those in the comments i do have a large backlog of requested problems that i'm working through so it may ...
Koko Eating Bananas
longest-mountain-in-array
Koko loves to eat bananas. There are `n` piles of bananas, the `ith` pile has `piles[i]` bananas. The guards have gone and will come back in `h` hours. Koko can decide her bananas-per-hour eating speed of `k`. Each hour, she chooses some pile of bananas and eats `k` bananas from that pile. If the pile has less than `k...
null
Array,Two Pointers,Dynamic Programming,Enumeration
Medium
1766,2205
102
welcome back to code Meets World today we're looking at elak code problem number 102 which is binary tree level order traversal so I've got a tree drawn on the Whiteboard here and our task is to print the values in level order level one would just be this three level two would be this 9 and 20 and level three would be ...
Binary Tree Level Order Traversal
binary-tree-level-order-traversal
Given the `root` of a binary tree, return _the level order traversal of its nodes' values_. (i.e., from left to right, level by level). **Example 1:** **Input:** root = \[3,9,20,null,null,15,7\] **Output:** \[\[3\],\[9,20\],\[15,7\]\] **Example 2:** **Input:** root = \[1\] **Output:** \[\[1\]\] **Example 3:** **I...
null
Tree,Breadth-First Search,Binary Tree
Medium
103,107,111,314,637,764,1035
1,267
okay so hello and welcome here we are another question this is going to be count servers that communicate and I'm going to go ahead and um check the audio and then pop the chat out count servers that okay audio is working and pop the chat out so this is leode 1267 and I kind of just want to keep solving these questions...
Count Servers that Communicate
remove-zero-sum-consecutive-nodes-from-linked-list
You are given a map of a server center, represented as a `m * n` integer matrix `grid`, where 1 means that on that cell there is a server and 0 means that it is no server. Two servers are said to communicate if they are on the same row or on the same column. Return the number of servers that communicate with any o...
Convert the linked list into an array. While you can find a non-empty subarray with sum = 0, erase it. Convert the array into a linked list.
Hash Table,Linked List
Medium
1618
21
Once hello guys welcome to study in forum st you looking at the hello how to merge to for at least for practice will do problem statement and tourism places next doubt about what is the problem and this you can find very great den welcome back on tried and Tried to change its form into problems Latest notification for ...
Merge Two Sorted Lists
merge-two-sorted-lists
You are given the heads of two sorted linked lists `list1` and `list2`. Merge the two lists in a one **sorted** list. The list should be made by splicing together the nodes of the first two lists. Return _the head of the merged linked list_. **Example 1:** **Input:** list1 = \[1,2,4\], list2 = \[1,3,4\] **Output:**...
null
Linked List,Recursion
Easy
23,88,148,244,1774,2071
1,005
hello guys I'm this video Problem on maximize sum of array after K negations so given array we in inte K and modify the array in the following way so choose any index and replace the element of that index with itation so you should apply this process exactly K times and you may choose the same index multiple times so w...
Maximize Sum Of Array After K Negations
univalued-binary-tree
Given an integer array `nums` and an integer `k`, modify the array in the following way: * choose an index `i` and replace `nums[i]` with `-nums[i]`. You should apply this process exactly `k` times. You may choose the same index `i` multiple times. Return _the largest possible sum of the array after modifying it i...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Easy
1609
86
hello and welcome to another video so in this video we're going to be working on problem number 86 partition list and in this problem given the head of a linked list and a value X participant partition it such that all nodes less than x come before nodes that are greater than or equal to X and you should preserve the o...
Partition List
partition-list
Given the `head` of a linked list and a value `x`, partition it such that all nodes **less than** `x` come before nodes **greater than or equal** to `x`. You should **preserve** the original relative order of the nodes in each of the two partitions. **Example 1:** **Input:** head = \[1,4,3,2,5,2\], x = 3 **Output:**...
null
Linked List,Two Pointers
Medium
2265
1,785
hello everyone so today we are going to cover minimum element to add to form a given sum so the input given here is an integer array and an integer variable limit and gold so we have to return the minimum number of elements we need to add to make the sum of the array equal to gold so now let's understand this with an e...
Minimum Elements to Add to Form a Given Sum
hopper-company-queries-ii
You are given an integer array `nums` and two integers `limit` and `goal`. The array `nums` has an interesting property that `abs(nums[i]) <= limit`. Return _the minimum number of elements you need to add to make the sum of the array equal to_ `goal`. The array must maintain its property that `abs(nums[i]) <= limit`. ...
null
Database
Hard
262,1779,1795,2376