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
1,689
Hello Hi Everyone Welcome to Channel Irfan YouTube Channel Please subscribe button first so let's solve all the problem partition in terminal number 110 008 123 092 and did not give positive and return positive energy number two for example subscribe for Live video plus two plus 332 how To do is third like very kind of...
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
26
hello everyone in this video we're going to see the solution to the lead code problem remove duplicates from sorted array so we're given a sorted array and we have to remove the duplicates in place such that each element appear only once and we have to return the new line but we don't have to allocate any extra space w...
Remove Duplicates from Sorted Array
remove-duplicates-from-sorted-array
Given an integer array `nums` sorted in **non-decreasing order**, remove the duplicates [**in-place**](https://en.wikipedia.org/wiki/In-place_algorithm) such that each unique element appears only **once**. The **relative order** of the elements should be kept the **same**. Then return _the number of unique elements in_...
In this problem, the key point to focus on is the input array being sorted. As far as duplicate elements are concerned, what is their positioning in the array when the given array is sorted? Look at the image above for the answer. If we know the position of one of the elements, do we also know the positioning of all th...
Array,Two Pointers
Easy
27,80
1,787
hey what's up guys uh this is chung here so today uh let's take a look at uh late code 1787 make the xor of all segments equal to zero yeah so this one is pretty i think it's a quite difficult one so you're given like an array of numbers and an integer k here and the xor of a segment left to right uh basically it's a x...
Make the XOR of All Segments Equal to Zero
sum-of-absolute-differences-in-a-sorted-array
You are given an array `nums`​​​ and an integer `k`​​​​​. The XOR of a segment `[left, right]` where `left <= right` is the `XOR` of all the elements with indices between `left` and `right`, inclusive: `nums[left] XOR nums[left+1] XOR ... XOR nums[right]`. Return _the minimum number of elements to change in the array_...
Absolute difference is the same as max(a, b) - min(a, b). How can you use this fact with the fact that the array is sorted? For nums[i], the answer is (nums[i] - nums[0]) + (nums[i] - nums[1]) + ... + (nums[i] - nums[i-1]) + (nums[i+1] - nums[i]) + (nums[i+2] - nums[i]) + ... + (nums[n-1] - nums[i]). It can be simplifi...
Array,Math,Prefix Sum
Medium
null
139
all right so today we'll be looking at the problem word break so this is another common dynamic programming problem so let's just jump right into it so given a non-empty string s and a so given a non-empty string s and a so given a non-empty string s and a dictionary word dict containing a list of non-empty words deter...
Word Break
word-break
Given a string `s` and a dictionary of strings `wordDict`, return `true` if `s` can be segmented into a space-separated sequence of one or more dictionary words. **Note** that the same word in the dictionary may be reused multiple times in the segmentation. **Example 1:** **Input:** s = "leetcode ", wordDict = \[ "...
null
Hash Table,String,Dynamic Programming,Trie,Memoization
Medium
140
68
hello everyone today I'm going to talk about question which is a hard level question in Unicode it's caught text justification we're given array of words and widths called max width so you're going to format the text such that the each line has exactly max West characters and it's fully justified and if you look at the...
Text Justification
text-justification
Given an array of strings `words` and a width `maxWidth`, format the text such that each line has exactly `maxWidth` characters and is fully (left and right) justified. You should pack your words in a greedy approach; that is, pack as many words as you can in each line. Pad extra spaces `' '` when necessary so that ea...
null
Array,String,Simulation
Hard
1714,2260
1,952
hello guys my name is Ursula and welcome back to my channel and today we will be solving a new lead code portion that is three divisors with the help of python let's read out the question and the question says given an integer and return to if n is exactly three positive devices otherwise return false and integer m is ...
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,184
uh so this question is distance between bus stop so basically you give integer array and also the starting and destination so what you're doing is you know Traverse the integer array the distant array right so in this Z represent what the distance between bus stop Z to one this represent one so two will represent anoth...
Distance Between Bus Stops
car-pooling
A bus has `n` stops numbered from `0` to `n - 1` that form a circle. We know the distance between all pairs of neighboring stops where `distance[i]` is the distance between the stops number `i` and `(i + 1) % n`. The bus goes along both directions i.e. clockwise and counterclockwise. Return the shortest distance betw...
Sort the pickup and dropoff events by location, then process them in order.
Array,Sorting,Heap (Priority Queue),Simulation,Prefix Sum
Medium
253
1,372
Ajay said that hey guys now in this site for wedding and in today's video we will learn to solve a problem basically which is called long, it is only for 15 days, first tip so let us understand this problem, what is this problem and then move towards its solution. Okay, let's see, first of all you will get the question...
Longest ZigZag Path in a Binary Tree
check-if-it-is-a-good-array
You are given the `root` of a binary tree. A ZigZag path for a binary tree is defined as follow: * Choose **any** node in the binary tree and a direction (right or left). * If the current direction is right, move to the right child of the current node; otherwise, move to the left child. * Change the direction f...
Eq. ax+by=1 has solution x, y if gcd(a,b) = 1. Can you generalize the formula?. Check Bézout's lemma.
Array,Math,Number Theory
Hard
null
1,704
hey everyone welcome back to our coding Series today we are going to tackle an interesting problem that involves strings and a bite of a character counting if you are ready let's get D it this is a problem statement you are given a string this is our problem statement determine if Str helps are like means you are given...
Determine if String Halves Are Alike
special-positions-in-a-binary-matrix
You are given a string `s` of even length. Split this string into two halves of equal lengths, and let `a` be the first half and `b` be the second half. Two strings are **alike** if they have the same number of vowels (`'a'`, `'e'`, `'i'`, `'o'`, `'u'`, `'A'`, `'E'`, `'I'`, `'O'`, `'U'`). Notice that `s` contains uppe...
Keep track of 1s in each row and in each column. Then while iterating over matrix, if the current position is 1 and current row as well as current column contains exactly one occurrence of 1.
Array,Matrix
Easy
null
311
uh lead code practice time there are two goals the first one is to see how to solve this problem and then put in some code there a solution and then the code and the second one is to see how to behave during a real interview uh suppose you're given the question so let's get started so remember always the first step is ...
Sparse Matrix Multiplication
sparse-matrix-multiplication
Given two [sparse matrices](https://en.wikipedia.org/wiki/Sparse_matrix) `mat1` of size `m x k` and `mat2` of size `k x n`, return the result of `mat1 x mat2`. You may assume that multiplication is always possible. **Example 1:** **Input:** mat1 = \[\[1,0,0\],\[-1,0,3\]\], mat2 = \[\[7,0,0\],\[0,0,0\],\[0,0,1\]\] **O...
null
Array,Hash Table,Matrix
Medium
null
380
Hello hello guys welcome to good that medicine today will go through the date when problem in all delete random please like video any fear you don't forget to subscribe to our channel this mixture plate design data structures in operation in which light from inside your mind and intellect And Elements Of Duplicate Valu...
Insert Delete GetRandom O(1)
insert-delete-getrandom-o1
Implement the `RandomizedSet` class: * `RandomizedSet()` Initializes the `RandomizedSet` object. * `bool insert(int val)` Inserts an item `val` into the set if not present. Returns `true` if the item was not present, `false` otherwise. * `bool remove(int val)` Removes an item `val` from the set if present. Retur...
null
Array,Hash Table,Math,Design,Randomized
Medium
381
724
hey guys like guys let's look at seven to five find the pivot index we're given a array of integers we will find the pivot index which means the sum of the left numbers is right to some of the numbers to right if note not exist we should read term minus one if there are multiple we should return left most favorite inde...
Find Pivot Index
find-pivot-index
Given an array of integers `nums`, calculate the **pivot index** of this array. The **pivot index** is the index where the sum of all the numbers **strictly** to the left of the index is equal to the sum of all the numbers **strictly** to the index's right. If the index is on the left edge of the array, then the left...
We can precompute prefix sums P[i] = nums[0] + nums[1] + ... + nums[i-1]. Then for each index, the left sum is P[i], and the right sum is P[P.length - 1] - P[i] - nums[i].
Array,Prefix Sum
Easy
560,2102,2369
771
Hello viewers welcome back to years and this video will see jobs and stones problem Vishram list to day two of the match challenge so let's look at problem statement problems youth springs representing the life to those were present in stones character in life you have You want to know how to change a rented u and all ...
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
853
hey everyone welcome to my channel so in this video i'm going to try to solve this problem try to put some code in and also at the same time i'm going to follow the general interview steps while trying to solve this problem so first of all let's read through this question to get a good understanding so there are end ca...
Car Fleet
most-profit-assigning-work
There are `n` cars going to the same destination along a one-lane road. The destination is `target` miles away. You are given two integer array `position` and `speed`, both of length `n`, where `position[i]` is the position of the `ith` car and `speed[i]` is the speed of the `ith` car (in miles per hour). A car can n...
null
Array,Two Pointers,Binary Search,Greedy,Sorting
Medium
2180
129
Hello friends today I'm going to solve liquid problem number 129 some route to Leaf numbers in this problem we are given the root of a binary tree and each of the node consists of values starting from 0 to 9 only and we have a route to Leaf path and for each of this root to lift path if you represent the path in the fo...
Sum Root to Leaf Numbers
sum-root-to-leaf-numbers
You are given the `root` of a binary tree containing digits from `0` to `9` only. Each root-to-leaf path in the tree represents a number. * For example, the root-to-leaf path `1 -> 2 -> 3` represents the number `123`. Return _the total sum of all root-to-leaf numbers_. Test cases are generated so that the answer w...
null
Tree,Depth-First Search,Binary Tree
Medium
112,124,1030
307
what's up everyone today we're gonna be going over Fenwick tree and then we're gonna be going over leak code through 0-7 now this video is gonna be a little 0-7 now this video is gonna be a little 0-7 now this video is gonna be a little bit longer than my usual ones because I'm gonna actually explain the data structure...
Range Sum Query - Mutable
range-sum-query-mutable
Given an integer array `nums`, handle multiple queries of the following types: 1. **Update** the value of an element in `nums`. 2. Calculate the **sum** of the elements of `nums` between indices `left` and `right` **inclusive** where `left <= right`. Implement the `NumArray` class: * `NumArray(int[] nums)` Initi...
null
Array,Design,Binary Indexed Tree,Segment Tree
Medium
303,308
19
I really don't understand why this problem is categorized under medium difficulty or rather I can tell you guys a sweet little trick that can make this problem super simple so let's find it out Hello friends welcome back to my Channel first I will explain the problem statement and we will look at some sample test cases...
Remove Nth Node From End of List
remove-nth-node-from-end-of-list
Given the `head` of a linked list, remove the `nth` node from the end of the list and return its head. **Example 1:** **Input:** head = \[1,2,3,4,5\], n = 2 **Output:** \[1,2,3,5\] **Example 2:** **Input:** head = \[1\], n = 1 **Output:** \[\] **Example 3:** **Input:** head = \[1,2\], n = 1 **Output:** \[1\] **C...
Maintain two pointers and update one with a delay of n steps.
Linked List,Two Pointers
Medium
528,1618,2216
1,078
foreign welcome back to my channel and today we guys are going to solve a new lead code question that is occurrences after big Ram so guys let's understand this question uh given to the strings first and second considering considerate occurrences in some text of the form first second third went first second comes immed...
Occurrences After Bigram
remove-outermost-parentheses
Given two strings `first` and `second`, consider occurrences in some text of the form `"first second third "`, where `second` comes immediately after `first`, and `third` comes immediately after `second`. Return _an array of all the words_ `third` _for each occurrence of_ `"first second third "`. **Example 1:** **In...
Can you find the primitive decomposition? The number of ( and ) characters must be equal.
String,Stack
Easy
null
299
Bluetooth adjustment - Support Bluetooth adjustment - Support Bluetooth adjustment - Support and request of rebels So let's see the question, this is the question. Okay, so let's see the question. We have the question of the crossroads game. Okay, so in that house, this mistake, the soldier is in it for him, so what ar...
Bulls and Cows
bulls-and-cows
You are playing the **[Bulls and Cows](https://en.wikipedia.org/wiki/Bulls_and_Cows)** game with your friend. You write down a secret number and ask your friend to guess what the number is. When your friend makes a guess, you provide a hint with the following info: * The number of "bulls ", which are digits in the ...
null
Hash Table,String,Counting
Medium
null
408
hello and welcome back to the cracking fang youtube channel today we're going to be solving lead code problem 408 valid word abbreviation a string can be abbreviated by replacing any number of non-adjacent non-empty any number of non-adjacent non-empty any number of non-adjacent non-empty substrings with their lengths ...
Valid Word Abbreviation
valid-word-abbreviation
A string can be **abbreviated** by replacing any number of **non-adjacent**, **non-empty** substrings with their lengths. The lengths **should not** have leading zeros. For example, a string such as `"substitution "` could be abbreviated as (but not limited to): * `"s10n "` ( `"s ubstitutio n "`) * `"sub4u4 "` ( ...
null
Two Pointers,String
Easy
411,527,2184
297
hello welcome back to my channel and today we have leeco 297 serialized and deceiving binary tree and this question is often asked by a lot of companies like facebook amazon microsoft is a really popular question and it's also rated as hard question so let's take a look at this question now so now as you read this desc...
Serialize and Deserialize Binary Tree
serialize-and-deserialize-binary-tree
Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection link to be reconstructed later in the same or another computer environment. Design an algorithm to serialize and deserialize a bi...
null
String,Tree,Depth-First Search,Breadth-First Search,Design,Binary Tree
Hard
271,449,652,765
766
I'm having a really good hair day alright let's get started hello everyone this is programmer Mitch coming at you with a nether algorithms data structures problem today we're gonna be talking about leak code 766 so a relatively recent one called the top blitz matrix which I had not heard of before doing this problem ma...
Toeplitz Matrix
flatten-a-multilevel-doubly-linked-list
Given an `m x n` `matrix`, return _`true` if the matrix is Toeplitz. Otherwise, return `false`._ A matrix is **Toeplitz** if every diagonal from top-left to bottom-right has the same elements. **Example 1:** **Input:** matrix = \[\[1,2,3,4\],\[5,1,2,3\],\[9,5,1,2\]\] **Output:** true **Explanation:** In the above gr...
null
Linked List,Depth-First Search,Doubly-Linked List
Medium
114,1796
208
hey everybody this is larry this is october 7th but we're doing eighth day of the leeco dairy challenge hit the like button to subscribe and join me in disco let me know what you think about today's farm and all that other good stuff did i quit on i thought i did okay um yeah and i usually stop this live so it's a litt...
Implement Trie (Prefix Tree)
implement-trie-prefix-tree
A [**trie**](https://en.wikipedia.org/wiki/Trie) (pronounced as "try ") or **prefix tree** is a tree data structure used to efficiently store and retrieve keys in a dataset of strings. There are various applications of this data structure, such as autocomplete and spellchecker. Implement the Trie class: * `Trie()` ...
null
Hash Table,String,Design,Trie
Medium
211,642,648,676,1433,1949
1,824
hey everybody this is larry this is me over q3 of the weekly contest uh 236 or something like that uh minimum sideway jumps so for they're actually you know this is the shortest path problem as you may guess by just the minimum station uh and yeah um but this is a little bit tricky uh i to be honest this seems very uh ...
Minimum Sideway Jumps
maximum-number-of-eaten-apples
There is a **3 lane road** of length `n` that consists of `n + 1` **points** labeled from `0` to `n`. A frog **starts** at point `0` in the **second** lane and wants to jump to point `n`. However, there could be obstacles along the way. You are given an array `obstacles` of length `n + 1` where each `obstacles[i]` (**...
It's optimal to finish the apples that will rot first before those that will rot last You need a structure to keep the apples sorted by their finish time
Array,Greedy,Heap (Priority Queue)
Medium
null
1,897
hi everyone welcome back to the channel and today to solve Le code daily challenge problem number 1,897 redistribute characters to pick 1,897 redistribute characters to pick 1,897 redistribute characters to pick all strings equal so first we're going to look into the problem statement then we'll check out the approach ...
Redistribute Characters to Make All Strings Equal
maximize-palindrome-length-from-subsequences
You are given an array of strings `words` (**0-indexed**). In one operation, pick two **distinct** indices `i` and `j`, where `words[i]` is a non-empty string, and move **any** character from `words[i]` to **any** position in `words[j]`. Return `true` _if you can make **every** string in_ `words` _**equal** using **a...
Let's ignore the non-empty subsequence constraint. We can concatenate the two strings and find the largest palindromic subsequence with dynamic programming. Iterate through every pair of characters word1[i] and word2[j], and see if some palindrome begins with word1[i] and ends with word2[j]. This ensures that the subse...
String,Dynamic Programming
Hard
516
434
this is lead code 434 the name of this coding challenge is number of segments in a string giving a string s we have to return the number of segments in the string a segment here is not exactly a word it's not like in plain language we would have a sequence of characters consisting of words and we exclude the punctuatio...
Number of Segments in a String
number-of-segments-in-a-string
Given a string `s`, return _the number of segments in the string_. A **segment** is defined to be a contiguous sequence of **non-space characters**. **Example 1:** **Input:** s = "Hello, my name is John " **Output:** 5 **Explanation:** The five segments are \[ "Hello, ", "my ", "name ", "is ", "John "\] **Exam...
null
String
Easy
null
901
hello quarters today I'm solving liquid problem number 901 online stock span um so we are asked to design an algorithm that collects daily code prices and then return the span of stock price for current day so what's in Span or span is um the maximum number of consecutive days uh for which all the prices are less than ...
Online Stock Span
advantage-shuffle
Design an algorithm that collects daily price quotes for some stock and returns **the span** of that stock's price for the current day. The **span** of the stock's price in one day is the maximum number of consecutive days (starting from that day and going backward) for which the stock price was less than or equal to ...
null
Array,Greedy,Sorting
Medium
null
140
In this video we will discuss the problem of the word break, in this problem you have been given a string, a gift has been given and you have to make a sentence from it. After the word valid dictionary means that which is before the word off space. Will you consider, that word should be in your dictionary. We understan...
Word Break II
word-break-ii
Given a string `s` and a dictionary of strings `wordDict`, add spaces in `s` to construct a sentence where each word is a valid dictionary word. Return all such possible sentences in **any order**. **Note** that the same word in the dictionary may be reused multiple times in the segmentation. **Example 1:** **Input:...
null
Hash Table,String,Dynamic Programming,Backtracking,Trie,Memoization
Hard
139,472
523
welcome to lead code JavaScript a channel where we solve every single little question using JavaScript today we have 533 contiguous Savory sum this is a medium question however it has a shortly low acceptance rate of below 30 percent and the reason for this is that this question might be a bit more mathematical than al...
Continuous Subarray Sum
continuous-subarray-sum
Given an integer array nums and an integer k, return `true` _if_ `nums` _has a **good subarray** or_ `false` _otherwise_. A **good subarray** is a subarray where: * its length is **at least two**, and * the sum of the elements of the subarray is a multiple of `k`. **Note** that: * A **subarray** is a contiguo...
null
Array,Hash Table,Math,Prefix Sum
Medium
560,2119,2240
294
let's continue to solve lead code problem Flip Game 2 294 yeah so it's the same like before but this time the current state is going to be the plus and minus sign yeah and it can be any lens so the length can be 1 to 60 and the current state I should be plus or minus sign yeah and we also need to calculate the wrun tim...
Flip Game II
flip-game-ii
You are playing a Flip Game with your friend. You are given a string `currentState` that contains only `'+'` and `'-'`. You and your friend take turns to flip **two consecutive** `"++ "` into `"-- "`. The game ends when a person can no longer make a move, and therefore the other person will be the winner. Return `tru...
null
Math,Dynamic Programming,Backtracking,Memoization,Game Theory
Medium
292,293,375,464
1,340
hello and welcome back to the cracking Thing YouTube channel today we're solving lead code problem 1340 Jump game five I have not made one of these videos in a long time so hopefully I'm not too rusty anyway let's read the question prompt given an array of integers and an integer D in one step you can jump from index I...
Jump Game V
the-dining-philosophers
Given an array of integers `arr` and an integer `d`. In one step you can jump from index `i` to index: * `i + x` where: `i + x < arr.length` and `0 < x <= d`. * `i - x` where: `i - x >= 0` and `0 < x <= d`. In addition, you can only jump from index `i` to index `j` if `arr[i] > arr[j]` and `arr[i] > arr[k]` for a...
null
Concurrency
Medium
null
88
hello everyone welcome back and today we are looking at question 88 which is merge sorted array so we are given two integer arrays nums one unknowns two both of which are sorted in an non-decreasing fashion sorted in an non-decreasing fashion sorted in an non-decreasing fashion which means both of which are sorted in a...
Merge Sorted Array
merge-sorted-array
You are given two integer arrays `nums1` and `nums2`, sorted in **non-decreasing order**, and two integers `m` and `n`, representing the number of elements in `nums1` and `nums2` respectively. **Merge** `nums1` and `nums2` into a single array sorted in **non-decreasing order**. The final sorted array should not be re...
You can easily solve this problem if you simply think about two elements at a time rather than two arrays. We know that each of the individual arrays is sorted. What we don't know is how they will intertwine. Can we take a local decision and arrive at an optimal solution? If you simply consider one element each at a ti...
Array,Two Pointers,Sorting
Easy
21,1019,1028
934
hi everyone let's start solving today's lead code daily challenge question which is 934 shortest page so as part of this question we are given an encross and binary Matrix where one represent length and 0 represent water and there are exactly two islands in a grid and we need to return the smallest number of zeros we n...
Shortest Bridge
bitwise-ors-of-subarrays
You are given an `n x n` binary matrix `grid` where `1` represents land and `0` represents water. An **island** is a 4-directionally connected group of `1`'s not connected to any other `1`'s. There are **exactly two islands** in `grid`. You may change `0`'s to `1`'s to connect the two islands to form **one island**. ...
null
Array,Dynamic Programming,Bit Manipulation
Medium
null
863
Hello everyone welcome to me channel we are going to do video number 29 question is quite popular today number 1863 medium but it is going to be very easy because in a very simple way we will make it very basic from what we know we will make this To the question and this video is on approach one, a separate video will ...
All Nodes Distance K in Binary Tree
sum-of-distances-in-tree
Given the `root` of a binary tree, the value of a target node `target`, and an integer `k`, return _an array of the values of all nodes that have a distance_ `k` _from the target node._ You can return the answer in **any order**. **Example 1:** **Input:** root = \[3,5,1,6,2,0,8,null,null,7,4\], target = 5, k = 2 **O...
null
Dynamic Programming,Tree,Depth-First Search,Graph
Hard
1021,2175
947
Try to make a connection, how will the connection be made, like zero is zero, okay, now whoever is coming, in whose settings there is zero, you will get the connection with him, okay and you will get the zero, okay, now the connection is made, now the connection with whom. Build them and see which connection is next. O...
Most Stones Removed with Same Row or Column
online-election
On a 2D plane, we place `n` stones at some integer coordinate points. Each coordinate point may have at most one stone. A stone can be removed if it shares either **the same row or the same column** as another stone that has not been removed. Given an array `stones` of length `n` where `stones[i] = [xi, yi]` represen...
null
Array,Hash Table,Binary Search,Design
Medium
1483
310
hi everyone there let's sological question called minimum height tree well the higher the tree is defined as numbers edges on the longest downward pass between the root and the in other words the number stages are the distance between the root and leave and we want to list our own minimum time trees root labels in othe...
Minimum Height Trees
minimum-height-trees
A tree is an undirected graph in which any two vertices are connected by _exactly_ one path. In other words, any connected graph without simple cycles is a tree. Given a tree of `n` nodes labelled from `0` to `n - 1`, and an array of `n - 1` `edges` where `edges[i] = [ai, bi]` indicates that there is an undirected edg...
How many MHTs can a graph have at most?
Depth-First Search,Breadth-First Search,Graph,Topological Sort
Medium
207,210
148
hello everyone welcome to our channel code with sunny and in this video we will be talking about the problem medium problem called sort list its index is 148 and it is the daily problem of the lead code for the month of february day 24 okay so yeah this problem is totally related to the concepts of linked list and like...
Sort List
sort-list
Given the `head` of a linked list, return _the list after sorting it in **ascending order**_. **Example 1:** **Input:** head = \[4,2,1,3\] **Output:** \[1,2,3,4\] **Example 2:** **Input:** head = \[-1,5,3,4,0\] **Output:** \[-1,0,3,4,5\] **Example 3:** **Input:** head = \[\] **Output:** \[\] **Constraints:** * ...
null
Linked List,Two Pointers,Divide and Conquer,Sorting,Merge Sort
Medium
21,75,147,1992
1,743
Hello everyone welcome to my channel code share with me so today I am going to do video number 8 of my hash map hashset playlist lead code number 1743 is marked medium but its solution is quite easy but I liked this question very much ok I Made this question for the first time, the name of the question is Restore the A...
Restore the Array From Adjacent Pairs
count-substrings-that-differ-by-one-character
There is an integer array `nums` that consists of `n` **unique** elements, but you have forgotten it. However, you do remember every pair of adjacent elements in `nums`. You are given a 2D integer array `adjacentPairs` of size `n - 1` where each `adjacentPairs[i] = [ui, vi]` indicates that the elements `ui` and `vi` a...
Take every substring of s, change a character, and see how many substrings of t match that substring. Use a Trie to store all substrings of t as a dictionary.
Hash Table,String,Dynamic Programming
Medium
2256
218
hey everybody oh this is Larry this is day 30 up it's his last day it is the last day yay congratulate yourself a little bit especially if you finish it hit the like button hit the Subscribe button join me on Discord let me know what you think about today's Forum oh what I thought we could already do this okay apparent...
The Skyline Problem
the-skyline-problem
A city's **skyline** is the outer contour of the silhouette formed by all the buildings in that city when viewed from a distance. Given the locations and heights of all the buildings, return _the **skyline** formed by these buildings collectively_. The geometric information of each building is given in the array `buil...
null
Array,Divide and Conquer,Binary Indexed Tree,Segment Tree,Line Sweep,Heap (Priority Queue),Ordered Set
Hard
699
922
yeahyeah Hi everyone, I'm a programmer. Today I'm going to introduce to you a mathematical problem with pronouns like this: you a mathematical problem with pronouns like this: you a mathematical problem with pronouns like this: arrange a piece by grouping. This is problem number 2 in the series. The article series We G...
Sort Array By Parity II
possible-bipartition
Given an array of integers `nums`, half of the integers in `nums` are **odd**, and the other half are **even**. Sort the array so that whenever `nums[i]` is odd, `i` is **odd**, and whenever `nums[i]` is even, `i` is **even**. Return _any answer array that satisfies this condition_. **Example 1:** **Input:** nums =...
null
Depth-First Search,Breadth-First Search,Union Find,Graph
Medium
null
1,590
with this problem make some divisible by V so you haven't given the array and its sum can be anything can be used by P or cannot be divisible by B but you want to make this array into something uh which have a sum divisible by P so let's say if the array is 3 1 4 2 and P is equal to 6 right and uh currently the sum you...
Make Sum Divisible by P
make-sum-divisible-by-p
Given an array of positive integers `nums`, remove the **smallest** subarray (possibly **empty**) such that the **sum** of the remaining elements is divisible by `p`. It is **not** allowed to remove the whole array. Return _the length of the smallest subarray that you need to remove, or_ `-1` _if it's impossible_. A ...
null
null
Medium
null
1,415
hello Fenster emigrant talk part the record 14:15 the case is talk part the record 14:15 the case is talk part the record 14:15 the case is like a graphic stream all have strings of length and here her happy string is defined as computer contains only a pc suite nettles and easy torjussen network is not current adjacen...
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
961
hey what's going on guys it's ilya bella here i recording stuff on youtube share the description for all my information i do all little problems uh make sure you subscribe to the channel give me a big thumbs up to support it and this is called and repeated element in size 2 n array an array uh a of size 2n draw n plus ...
N-Repeated Element in Size 2N Array
long-pressed-name
You are given an integer array `nums` with the following properties: * `nums.length == 2 * n`. * `nums` contains `n + 1` **unique** elements. * Exactly one element of `nums` is repeated `n` times. Return _the element that is repeated_ `n` _times_. **Example 1:** **Input:** nums = \[1,2,3,3\] **Output:** 3 **...
null
Two Pointers,String
Easy
null
1,026
Hello hello everyone welcome to my channel it's all the problem maximum difference between noida and sister for giving the root of binary tree for india maximum very form which day and different note se ease with difference between noida and noida sector 9 we no differences of mother and Child of child in the system wi...
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
1,697
hey everybody this is Larry this is day 29 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 problem uh let me also check for the extra points okay no extra coins um and also uh there'll be the premium problem later so definitely hit th...
Checking Existence of Edge Length Limited Paths
strings-differ-by-one-character
An undirected graph of `n` nodes is defined by `edgeList`, where `edgeList[i] = [ui, vi, disi]` denotes an edge between nodes `ui` and `vi` with distance `disi`. Note that there may be **multiple** edges between two nodes. Given an array `queries`, where `queries[j] = [pj, qj, limitj]`, your task is to determine for e...
BruteForce, check all pairs and verify if they differ in one character. O(n^2 * m) where n is the number of words and m is the length of each string. O(m^2 * n), Use hashset, to insert all possible combinations adding a character "*". For example: If dict[i] = "abc", insert ("*bc", "a*c" and "ab*").
Hash Table,String,Rolling Hash,Hash Function
Medium
2256
127
hello everyone welcome to day twenty fourth of july code challenge and today's question is word lighter two and even before starting the question i would like to apologize i was a little late as i was busy with my some personal work i just reached home back in the evening and now i'm there in front of the laptop solvin...
Word Ladder
word-ladder
A **transformation sequence** from word `beginWord` to word `endWord` using a dictionary `wordList` is a sequence of words `beginWord -> s1 -> s2 -> ... -> sk` such that: * Every adjacent pair of words differs by a single letter. * Every `si` for `1 <= i <= k` is in `wordList`. Note that `beginWord` does not need ...
null
Hash Table,String,Breadth-First Search
Hard
126,433
9
hello all welcome to another video solution by code runner in this video we will be looking at the palindrome number problem on lead code and this video will provide you with the c plus solution of this problem i have also made a video for the python solution of this problem and if you are more comfortable with python ...
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,170
yeahyeah Hi everyone, I'm a programmer. Today I'll introduce to you a proportional problem like this: you a proportional problem like this: you a proportional problem like this: Compare strings by the number of times the smallest element appears. The detailed problem sequence is as follows. We will define a callback fu...
Compare Strings by Frequency of the Smallest Character
shortest-common-supersequence
Let the function `f(s)` be the **frequency of the lexicographically smallest character** in a non-empty string `s`. For example, if `s = "dcce "` then `f(s) = 2` because the lexicographically smallest character is `'c'`, which has a frequency of 2. You are given an array of strings `words` and another array of query s...
We can find the length of the longest common subsequence between str1[i:] and str2[j:] (for all (i, j)) by using dynamic programming. We can use this information to recover the longest common supersequence.
String,Dynamic Programming
Hard
1250
136
hi everybody welcome to my channel let's solve the lead code problem one three six single number it is a like very common problem in interviews so let's use the problem statement and under to understand the example so given a non-empty array of integers every non-empty array of integers every non-empty array of integer...
Single Number
single-number
Given a **non-empty** array of integers `nums`, every element appears _twice_ except for one. Find that single one. You must implement a solution with a linear runtime complexity and use only constant extra space. **Example 1:** **Input:** nums = \[2,2,1\] **Output:** 1 **Example 2:** **Input:** nums = \[4,1,2,1,2...
null
Array,Bit Manipulation
Easy
137,260,268,287,389
961
hey everybody this is larry this is me doing the uh a bonus question for august 6 2022. um i'm trying to still complete uh oh what the why oh this is frequency i did um yeah i'm trying to do one that i haven't done before and i pick it randomly uh today's problem earlier problem was poor pigs and it was poor me it took...
N-Repeated Element in Size 2N Array
long-pressed-name
You are given an integer array `nums` with the following properties: * `nums.length == 2 * n`. * `nums` contains `n + 1` **unique** elements. * Exactly one element of `nums` is repeated `n` times. Return _the element that is repeated_ `n` _times_. **Example 1:** **Input:** nums = \[1,2,3,3\] **Output:** 3 **...
null
Two Pointers,String
Easy
null
124
welcome back to algojs today's question is leak code 124 binary tree maximum path sum so a path in a binary tree is a sequence of nodes where each pair of adjacent nodes in the sequence has an edge connecting them a node can only appear in the sequence at most once note that the path does not need to pass through the r...
Binary Tree Maximum Path Sum
binary-tree-maximum-path-sum
A **path** in a binary tree is a sequence of nodes where each pair of adjacent nodes in the sequence has an edge connecting them. A node can only appear in the sequence **at most once**. Note that the path does not need to pass through the root. The **path sum** of a path is the sum of the node's values in the path. ...
null
Dynamic Programming,Tree,Depth-First Search,Binary Tree
Hard
112,129,666,687,1492
882
hey everybody this is larry this is me going over day 12 of the september eco day challenge hit the like button here to subscribe for enjoyment discord smash order whatever buttons uh anyway today's problem is reach above know it's in subtitle so i usually solve these live so if it's a little bit slow you know skip ahe...
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
933
hey everybody this is larry this is the first day of october yay of the lego daily challenge uh let me know what you think about this problem uh usually i saw of this live and then i will go over to as much as i can what my thought process is how i approach it and how i attack it's not like the usual explanation video ...
Number of Recent Calls
increasing-order-search-tree
You have a `RecentCounter` class which counts the number of recent requests within a certain time frame. Implement the `RecentCounter` class: * `RecentCounter()` Initializes the counter with zero recent requests. * `int ping(int t)` Adds a new request at time `t`, where `t` represents some time in milliseconds, a...
null
Stack,Tree,Depth-First Search,Binary Search Tree,Binary Tree
Easy
null
57
hello and welcome back to the cracking Fang YouTube channel today we are solving yet again another interval problem this time number 57 insert interval you were given an array of non-overlapping intervals non-overlapping intervals non-overlapping intervals where intervals of I equals start of I end of I representing th...
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,834
hello guys welcome to code enzyme and in this video we are going to discuss the problem 1834 of lead code the single threaded CPU and in this playlist I discuss daily the elite code problems so let's see the problem statement you are given n task labeled from 0 to n minus 1 which are represented by a 2d integer array w...
Single-Threaded CPU
minimum-number-of-people-to-teach
You are given `n`​​​​​​ tasks labeled from `0` to `n - 1` represented by a 2D integer array `tasks`, where `tasks[i] = [enqueueTimei, processingTimei]` means that the `i​​​​​​th`​​​​ task will be available to process at `enqueueTimei` and will take `processingTimei` to finish processing. You have a single-threaded CPU...
You can just use brute force and find out for each language the number of users you need to teach Note that a user can appear in multiple friendships but you need to teach that user only once
Array,Greedy
Medium
null
1,254
Soon dynasty or there will be children here and subscribing will give normal number of cost Ireland okay number five is silent question which we have done like this concept base system I am telling you this okay I am please request you I will make this humble request that you please attend this rider, he will board the...
Number of Closed Islands
deepest-leaves-sum
Given a 2D `grid` consists of `0s` (land) and `1s` (water). An _island_ is a maximal 4-directionally connected group of `0s` and a _closed island_ is an island **totally** (all left, top, right, bottom) surrounded by `1s.` Return the number of _closed islands_. **Example 1:** **Input:** grid = \[\[1,1,1,1,1,1,1,0\],...
Traverse the tree to find the max depth. Traverse the tree again to compute the sum required.
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Medium
null
1,608
okay we're going to be doing lead code 1608 special array with x elements greater than or equal x so you are given an array called nums which consists of non-negative integers which consists of non-negative integers which consists of non-negative integers nums is considered special if there exists a number x such that ...
Special Array With X Elements Greater Than or Equal X
calculate-salaries
You are given an array `nums` of non-negative integers. `nums` is considered **special** if there exists a number `x` such that there are **exactly** `x` numbers in `nums` that are **greater than or equal to** `x`. Notice that `x` **does not** have to be an element in `nums`. Return `x` _if the array is **special**, ...
null
Database
Medium
null
1,688
hey everyone today we are going to solve theal question count of matches in tournament okay so this question is very easy so let's jump into the code directly so first of all initialize result variable with zero and start iteration so each team gets paired with another team so total match should be n/ another team so t...
Count of Matches in Tournament
the-most-recent-orders-for-each-product
You are given an integer `n`, the number of teams in a tournament that has strange rules: * If the current number of teams is **even**, each team gets paired with another team. A total of `n / 2` matches are played, and `n / 2` teams advance to the next round. * If the current number of teams is **odd**, one team ...
null
Database
Medium
1671,1735
124
hey everyone welcome back and let's write some more neat code today so today let's solve binary tree maximum path sum and yes this is another problem from the blind 75 leak code list so this is a list of 75 common leak code questions and today we're going to be solving this tree question binary tree maximum pathsome th...
Binary Tree Maximum Path Sum
binary-tree-maximum-path-sum
A **path** in a binary tree is a sequence of nodes where each pair of adjacent nodes in the sequence has an edge connecting them. A node can only appear in the sequence **at most once**. Note that the path does not need to pass through the root. The **path sum** of a path is the sum of the node's values in the path. ...
null
Dynamic Programming,Tree,Depth-First Search,Binary Tree
Hard
112,129,666,687,1492
35
okay guys now we get go to the 35th problem and he goes search insert position you're sorted Arrieta talking tell you it return the index if the target is found if not return the index where it would be if it was inserted in order so let's stop we will approach this dislike any search so H will be Nam stolen nice one w...
Search Insert Position
search-insert-position
Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You must write an algorithm with `O(log n)` runtime complexity. **Example 1:** **Input:** nums = \[1,3,5,6\], target = 5 **Output:** 2 **Exa...
null
Array,Binary Search
Easy
278
1,870
Hello everyone welcome, you are not my channel, okay why will it be easy because there are many similar questions, okay if you have made that then this will be made or if people have made this, then that is the similar question which I will give you now after some fear. I will give a list of similar questions, they wil...
Minimum Speed to Arrive on Time
minimum-speed-to-arrive-on-time
You are given a floating-point number `hour`, representing the amount of time you have to reach the office. To commute to the office, you must take `n` trains in sequential order. You are also given an integer array `dist` of length `n`, where `dist[i]` describes the distance (in kilometers) of the `ith` train ride. E...
null
null
Medium
null
1,827
Hello guys welcome song in two videos only according suggestion this problem dress ko minimum operation sukrauli increase the giver nitya re naam lai re naam se tire ko subscribe now to ki sadar distity increase so you can change account ok what to do is The difference between the two and the three to go to the first a...
Minimum Operations to Make the Array Increasing
invalid-tweets
You are given an integer array `nums` (**0-indexed**). In one operation, you can choose an element of the array and increment it by `1`. * For example, if `nums = [1,2,3]`, you can choose to increment `nums[1]` to make `nums = [1,**3**,3]`. Return _the **minimum** number of operations needed to make_ `nums` _**stri...
null
Database
Easy
null
4
in this video we are going to find the median of two sorted arrays this is lead code problem number four and it's a lead code hard problem and it has been asked in Google Amazon Apple Microsoft and many more interviews so let's see the problem statement so it says that you are given two arrays and these are sorted so y...
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
4
hello everyone welcome back here is vanamsen with another recording session and today we got something really uh special for you finding the medium of two sources errors but in Rust and you hear this right we are diving into rust for a crisp fast and safe solution to a classic problem so before we Unleash the Power 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
821
welcome to february's lee code challenge today's problem is shortest distance to a character given a string s and a character c that occurs in s we turn an array of integers where the length is equal to the length of the string and the answer i is the shortest distance from s of i to the character c in s if we have thi...
Shortest Distance to a Character
bricks-falling-when-hit
Given a string `s` and a character `c` that occurs in `s`, return _an array of integers_ `answer` _where_ `answer.length == s.length` _and_ `answer[i]` _is the **distance** from index_ `i` _to the **closest** occurrence of character_ `c` _in_ `s`. The **distance** between two indices `i` and `j` is `abs(i - j)`, where...
null
Array,Union Find,Matrix
Hard
2101,2322
381
how's it going guys with another video here in this video we're going to do number 381 insert delete get random of one duplicates allowed so this is a follow-up to a prop that i've this is a follow-up to a prop that i've this is a follow-up to a prop that i've also done on the channel so i do recommend that you guys go...
Insert Delete GetRandom O(1) - Duplicates allowed
insert-delete-getrandom-o1-duplicates-allowed
`RandomizedCollection` is a data structure that contains a collection of numbers, possibly duplicates (i.e., a multiset). It should support inserting and removing specific elements and also reporting a random element. Implement the `RandomizedCollection` class: * `RandomizedCollection()` Initializes the empty `Rand...
null
Array,Hash Table,Math,Design,Randomized
Hard
380
77
Hello everyone welcome you are going to do me channel ok lead code number 77 is medium mark but it is not medium at all ok the name of the question is combinations this is going to be a very easy problem because the template which is very family of back tracking is exactly like this OK, but today I will clear a very co...
Combinations
combinations
Given two integers `n` and `k`, return _all possible combinations of_ `k` _numbers chosen from the range_ `[1, n]`. You may return the answer in **any order**. **Example 1:** **Input:** n = 4, k = 2 **Output:** \[\[1,2\],\[1,3\],\[1,4\],\[2,3\],\[2,4\],\[3,4\]\] **Explanation:** There are 4 choose 2 = 6 total combin...
null
Backtracking
Medium
39,46
1,573
uh hey everybody this is larry this is me going over the bi-weekly contest story going over the bi-weekly contest story going over the bi-weekly contest story force q2 number of ways to split a string uh so for this one um i made a mistake with the mod i just forgot to mod and that cost me five minutes of penalty um bu...
Number of Ways to Split a String
find-two-non-overlapping-sub-arrays-each-with-target-sum
Given a binary string `s`, you can split `s` into 3 **non-empty** strings `s1`, `s2`, and `s3` where `s1 + s2 + s3 = s`. Return the number of ways `s` can be split such that the number of ones is the same in `s1`, `s2`, and `s3`. Since the answer may be too large, return it **modulo** `109 + 7`. **Example 1:** **Inp...
Let's create two arrays prefix and suffix where prefix[i] is the minimum length of sub-array ends before i and has sum = k, suffix[i] is the minimum length of sub-array starting at or after i and has sum = k. The answer we are searching for is min(prefix[i] + suffix[i]) for all values of i from 0 to n-1 where n == arr....
Array,Hash Table,Binary Search,Dynamic Programming,Sliding Window
Medium
null
1,026
hey guys welcome to a new video in today's video we're going to look at a lead code problem and the problem's name is maximum difference between node and ancestor so in this question we given the root of an binary tree we have to find the maximum value V for which there exist nodes A and B where V is the maximum differ...
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
96
today hell they are today's legal in challenge questions but unique binary search trees so we have a positive integer number n that stands for the number from 1 to n integer number sequence 1 to n that we want to store using a binary search tree and the question is basically asking us to account the number of structura...
Unique Binary Search Trees
unique-binary-search-trees
Given an integer `n`, return _the number of structurally unique **BST'**s (binary search trees) which has exactly_ `n` _nodes of unique values from_ `1` _to_ `n`. **Example 1:** **Input:** n = 3 **Output:** 5 **Example 2:** **Input:** n = 1 **Output:** 1 **Constraints:** * `1 <= n <= 19`
null
Math,Dynamic Programming,Tree,Binary Search Tree,Binary Tree
Medium
95
1,678
hello everyone and welcome to another short video on solving a lethal problem with apl today we will be tackling problem 1678 gold parser interpretation now what the problem statement says is that i'm given a string and the string consists of the alphabets just a single letter g open and closing parenthesis and then op...
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
837
hello hi guys good morning firstly oh God questioning the complexity of this question the understanding the HK says the things which are being involved you can see Mass probability DP sliding window edge cases like this question is going to be us yeah before further Ado let's start with this uh like I know the video is...
New 21 Game
most-common-word
Alice plays the following game, loosely based on the card game **"21 "**. Alice starts with `0` points and draws numbers while she has less than `k` points. During each draw, she gains an integer number of points randomly from the range `[1, maxPts]`, where `maxPts` is an integer. Each draw is independent and the outc...
null
Hash Table,String,Counting
Easy
null
1,569
hey what's up guys juan here so today let's take a look at the last problem in last week's weekly contest number 1569 number of ways to reorder array to get some to get same bst okay so your it's a hard problem you're given like an array of numbers that represents a permutation of integers from 1 to n and we're going t...
Number of Ways to Reorder Array to Get Same BST
max-dot-product-of-two-subsequences
Given an array `nums` that represents a permutation of integers from `1` to `n`. We are going to construct a binary search tree (BST) by inserting the elements of `nums` in order into an initially empty BST. Find the number of different ways to reorder `nums` so that the constructed BST is identical to that formed from...
Use dynamic programming, define DP[i][j] as the maximum dot product of two subsequences starting in the position i of nums1 and position j of nums2.
Array,Dynamic Programming
Hard
null
1,071
Ha Ga Namaskar welcome to the channel we are doing 90 days kasi proof this is lead code 75 question number two lead code 1071 great common divisor of the strings okay so let me look at the question what will I analyze I will analyze the question What to do in the question, what to do, then what is the solution approach...
Greatest Common Divisor of Strings
binary-prefix-divisible-by-5
For two strings `s` and `t`, we say "`t` divides `s` " if and only if `s = t + ... + t` (i.e., `t` is concatenated with itself one or more times). Given two strings `str1` and `str2`, return _the largest string_ `x` _such that_ `x` _divides both_ `str1` _and_ `str2`. **Example 1:** **Input:** str1 = "ABCABC ", str2...
If X is the first i digits of the array as a binary number, then 2X + A[i] is the first i+1 digits.
Array
Easy
null
57
the insert interval problem so given a set of non overlapping intervals you have to insert new interval and you may need to match if it's necessary okay so the problem statements intervals the given 1 3 6 9 and new interval is 2 5 okay for this problem the main thing we need to do it is you know up in the new interval ...
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
334
Hello friends, welcome to your channel, today is our day of 18th co challenge, so let's go straight to the screen, so here I am on the screen, today's queen's number is 3344 and jo queen. The name of the increasing triplet sub is so let's understand what is the queen. For this, we had already placed our white board pag...
Increasing Triplet Subsequence
increasing-triplet-subsequence
Given an integer array `nums`, return `true` _if there exists a triple of indices_ `(i, j, k)` _such that_ `i < j < k` _and_ `nums[i] < nums[j] < nums[k]`. If no such indices exists, return `false`. **Example 1:** **Input:** nums = \[1,2,3,4,5\] **Output:** true **Explanation:** Any triplet where i < j < k is valid. ...
null
Array,Greedy
Medium
300,2122,2280
463
hello welcome to my channel today we have leeco 463 island perimeter so you're you can see this is description right here so i assume you see it before uh seeing this video so in summary uh the idea of this question can be uh simplified in this form so now this will be the input of this 2d matrix so this is the grip so...
Island Perimeter
island-perimeter
You are given `row x col` `grid` representing a map where `grid[i][j] = 1` represents land and `grid[i][j] = 0` represents water. Grid cells are connected **horizontally/vertically** (not diagonally). The `grid` is completely surrounded by water, and there is exactly one island (i.e., one or more connected land cells)...
null
Array,Depth-First Search,Breadth-First Search,Matrix
Easy
695,733,1104
647
hey yo what's up my little coders let me show you in this tutorial how to solve the need for question 647 piling drumming substrings basically given the string we need to count how many polynomial substrings there are in this string and the thing is if you consider this input string for example there are six polynomic ...
Palindromic Substrings
palindromic-substrings
Given a string `s`, return _the number of **palindromic substrings** in it_. A string is a **palindrome** when it reads the same backward as forward. A **substring** is a contiguous sequence of characters within the string. **Example 1:** **Input:** s = "abc " **Output:** 3 **Explanation:** Three palindromic strin...
How can we reuse a previously computed palindrome to compute a larger palindrome? If “aba” is a palindrome, is “xabax” and palindrome? Similarly is “xabay” a palindrome? Complexity based hint: If we use brute-force and check whether for every start and end position a substring is a palindrome we have O(n^2) start - en...
String,Dynamic Programming
Medium
5,516
1,779
let's all lead code 1779 find nearest point that has same x or y coordinate so the question is that we'll be given several points okay like in this example each of the point will be an array of two integers the first one would be the x value x coordinate value the second would be the y-coordinate value along would be t...
Find Nearest Point That Has the Same X or Y Coordinate
hopper-company-queries-i
You are given two integers, `x` and `y`, which represent your current location on a Cartesian grid: `(x, y)`. You are also given an array `points` where each `points[i] = [ai, bi]` represents that a point exists at `(ai, bi)`. A point is **valid** if it shares the same x-coordinate or the same y-coordinate as your loca...
null
Database
Hard
262,1785,1795,2376
1,583
hey what is up guys i'm back with another elite code video today we're going to be doing problem 1583 count unhappy friends so we're given a list of preferences for and friends where n is always even and for each person i preference i contains a list of friends sorted in the order of preference in other words a friend ...
Count Unhappy Friends
paint-house-iii
You are given a list of `preferences` for `n` friends, where `n` is always **even**. For each person `i`, `preferences[i]` contains a list of friends **sorted** in the **order of preference**. In other words, a friend earlier in the list is more preferred than a friend later in the list. Friends in each list are denot...
Use Dynamic programming. Define dp[i][j][k] as the minimum cost where we have k neighborhoods in the first i houses and the i-th house is painted with the color j.
Array,Dynamic Programming
Hard
null
1,525
hi guys hope you're fine and doing well so today we will be discussing this problem from the lead code which is number of good ways to split a string so it is the 16th problem of the dynamic programming series so if you haven't watched the previous videos you can consider watching them since it will be really helpful f...
Number of Good Ways to Split a String
queries-on-a-permutation-with-key
You are given a string `s`. A split is called **good** if you can split `s` into two non-empty strings `sleft` and `sright` where their concatenation is equal to `s` (i.e., `sleft + sright = s`) and the number of distinct letters in `sleft` and `sright` is the same. Return _the number of **good splits** you can make ...
Create the permutation P=[1,2,...,m], it could be a list for example. For each i, find the position of queries[i] with a simple scan over P and then move this to the beginning.
Array,Binary Indexed Tree,Simulation
Medium
null
58
hey everyone welcome back and let's write some more neat code today so today let's go a little easy on ourselves and solve the problem length of last word if you're a beginner i would recommend solving this problem maybe you can try solving it by yourself and then compare your solution with mine later in the video we a...
Length of Last Word
length-of-last-word
Given a string `s` consisting of words and spaces, return _the length of the **last** word in the string._ A **word** is a maximal substring consisting of non-space characters only. **Example 1:** **Input:** s = "Hello World " **Output:** 5 **Explanation:** The last word is "World " with length 5. **Example 2:** ...
null
String
Easy
null
952
hello amigos welcome to cp edit in this video we are going to explain today's problem from the august lead coding challenge and it is called largest component size by common factor so what it says is we have a non-empty so what it says is we have a non-empty so what it says is we have a non-empty array consisting of un...
Largest Component Size by Common Factor
word-subsets
You are given an integer array of unique positive integers `nums`. Consider the following graph: * There are `nums.length` nodes, labeled `nums[0]` to `nums[nums.length - 1]`, * There is an undirected edge between `nums[i]` and `nums[j]` if `nums[i]` and `nums[j]` share a common factor greater than `1`. Return _t...
null
Array,Hash Table,String
Medium
null
980
Unique 53 is given and you are the ending point and -1 from the obstacle on which you cannot walk. -1 from the obstacle on which you cannot walk. -1 from the obstacle on which you cannot walk. Okay, so what you have to do is to reach from the starting point to the ending point. All the zeros and ones on which you can w...
Unique Paths III
find-the-shortest-superstring
You are given an `m x n` integer array `grid` where `grid[i][j]` could be: * `1` representing the starting square. There is exactly one starting square. * `2` representing the ending square. There is exactly one ending square. * `0` representing empty squares we can walk over. * `-1` representing obstacles tha...
null
Array,String,Dynamic Programming,Bit Manipulation,Bitmask
Hard
null
507
hi everyone welcome back for another video we are going to do analytical question the question is perfect number a perfect number is a positive integer that is equal to the sum of its positive divisors excluding the number itself a divisor of an integer x is an integer that can divide x evenly given a integer n return ...
Perfect Number
perfect-number
A [**perfect number**](https://en.wikipedia.org/wiki/Perfect_number) is a **positive integer** that is equal to the sum of its **positive divisors**, excluding the number itself. A **divisor** of an integer `x` is an integer that can divide `x` evenly. Given an integer `n`, return `true` _if_ `n` _is a perfect number,...
null
Math
Easy
728
1,514
hello guys welcome to deep codes and in today's video we will discuss liquid question 1514 that says path with maximum probability so guys although this question is of an easy medium level but it is important that you visualize that how the algorithm works in the back end so yeah guys stick till then and watch the comp...
Path with Maximum Probability
minimum-value-to-get-positive-step-by-step-sum
You are given an undirected weighted graph of `n` nodes (0-indexed), represented by an edge list where `edges[i] = [a, b]` is an undirected edge connecting the nodes `a` and `b` with a probability of success of traversing that edge `succProb[i]`. Given two nodes `start` and `end`, find the path with the maximum probab...
Find the minimum prefix sum.
Array,Prefix Sum
Easy
null
377
hey so welcome back and there's another daily Echo problem so today it's called culmination sum uh four I think that means four and so essentially what you're given is an array called nums and a particular Target and all that you want to do is find some combination of these numbers that add to that Target number and so...
Combination Sum IV
combination-sum-iv
Given an array of **distinct** integers `nums` and a target integer `target`, return _the number of possible combinations that add up to_ `target`. The test cases are generated so that the answer can fit in a **32-bit** integer. **Example 1:** **Input:** nums = \[1,2,3\], target = 4 **Output:** 7 **Explanation:** Th...
null
Array,Dynamic Programming
Medium
39
127
all right so this question is a word letter so a transformation sequence from the word beginning to the word ending using a dictionary word list and then this is a three different rule so you can only what you can only change one single letter per time and it has to be within the list of the word right and then the beg...
Word Ladder
word-ladder
A **transformation sequence** from word `beginWord` to word `endWord` using a dictionary `wordList` is a sequence of words `beginWord -> s1 -> s2 -> ... -> sk` such that: * Every adjacent pair of words differs by a single letter. * Every `si` for `1 <= i <= k` is in `wordList`. Note that `beginWord` does not need ...
null
Hash Table,String,Breadth-First Search
Hard
126,433
1,460
Hello Hi Everyone Welcome To My Channel And Solving Digit Code Problem 1460 Make You Are Sick Valve Working Hours Se Problem Tours In This App You Can Select According Subscribe To ZuluTrade Channel Like And Subscribe Example Tours Unlimited Number Of Subscribe 40 Pathari Survey 12345 124 To side me vikram one hai tu 1...
Make Two Arrays Equal by Reversing Subarrays
number-of-substrings-containing-all-three-characters
You are given two integer arrays of equal length `target` and `arr`. In one step, you can select any **non-empty subarray** of `arr` and reverse it. You are allowed to make any number of steps. Return `true` _if you can make_ `arr` _equal to_ `target` _or_ `false` _otherwise_. **Example 1:** **Input:** target = \[1,...
For each position we simply need to find the first occurrence of a/b/c on or after this position. So we can pre-compute three link-list of indices of each a, b, and c.
Hash Table,String,Sliding Window
Medium
2187
1,952
hello guys my name is Ursula and welcome back to my channel and today we will be solving a new record question that is three devices and we will be solving this question with the help of JavaScript so let's read out the question what the question is asking from us given integer uh and return true if n is exactly three ...
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,879
so lead code minimum sore sum of two arrays in this problem you're given two integer arrays and you need to minimize the source sum of those two arrays and the xor sum is just the sum of the xor of every element at each index so the xor of the first element in both arrays plus the xor of the second element in both arra...
Minimum XOR Sum of Two Arrays
maximum-score-from-removing-stones
You are given two integer arrays `nums1` and `nums2` of length `n`. The **XOR sum** of the two integer arrays is `(nums1[0] XOR nums2[0]) + (nums1[1] XOR nums2[1]) + ... + (nums1[n - 1] XOR nums2[n - 1])` (**0-indexed**). * For example, the **XOR sum** of `[1,2,3]` and `[3,2,1]` is equal to `(1 XOR 3) + (2 XOR 2) +...
It's optimal to always remove one stone from the biggest 2 piles Note that the limits are small enough for simulation
Math,Greedy,Heap (Priority Queue)
Medium
null
68
all right so let's talk about the texture specification so the discussion is supposed to be really hard to understand and it's supposed to be really article but all right so I'm going to ignore probably going to you know what happened in the uh in the description and just talk about how I did it so you have what you ha...
Text Justification
text-justification
Given an array of strings `words` and a width `maxWidth`, format the text such that each line has exactly `maxWidth` characters and is fully (left and right) justified. You should pack your words in a greedy approach; that is, pack as many words as you can in each line. Pad extra spaces `' '` when necessary so that ea...
null
Array,String,Simulation
Hard
1714,2260
204
Hello hello viewers welcome to my video not only cooling school counter and web account number prime numbers and the last one hour negative number and soldiers during their product weak mind ok main buffalo equal to six plus tried to find only numbers are in the future license image Hai That Numbers 1234 Five Subscribe...
Count Primes
count-primes
Given an integer `n`, return _the number of prime numbers that are strictly less than_ `n`. **Example 1:** **Input:** n = 10 **Output:** 4 **Explanation:** There are 4 prime numbers less than 10, they are 2, 3, 5, 7. **Example 2:** **Input:** n = 0 **Output:** 0 **Example 3:** **Input:** n = 1 **Output:** 0 **Co...
Let's start with a isPrime function. To determine if a number is prime, we need to check if it is not divisible by any number less than n. The runtime complexity of isPrime function would be O(n) and hence counting the total prime numbers up to n would be O(n2). Could we do better? As we know the number must not be div...
Array,Math,Enumeration,Number Theory
Medium
263,264,279
257
hey guys welcome to my video of technical view live coding see we are going to be talking about lead code problem 257 binary 3 paths so let's get to it given a binary return all brutally test and then let's take a look at the example first if we are given a tree like this one has two child two children two and three ha...
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
111
So the name of the question is Minimum Laptop Binary Tree. You will get this question in Late code. Question number 11, I will group this question in the description in gender. If you can go and solve it in Late code, then binary. You people will know that any note There can be maximum two children, left side and right...
Minimum Depth of Binary Tree
minimum-depth-of-binary-tree
Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. **Note:** A leaf is a node with no children. **Example 1:** **Input:** root = \[3,9,20,null,null,15,7\] **Output:** 2 **Example 2:** **Input:** root = \[2...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Easy
102,104
41
Hello hello brother is welcome to another winner Chinese all search today they want ur problem which cause for missing positive change in one should increase are now supported smallest missing positive integer yourself in the algorithm battery saver to st andrews contacts transport convenience and left side effects of ...
First Missing Positive
first-missing-positive
Given an unsorted integer array `nums`, return the smallest missing positive integer. You must implement an algorithm that runs in `O(n)` time and uses constant extra space. **Example 1:** **Input:** nums = \[1,2,0\] **Output:** 3 **Explanation:** The numbers in the range \[1,2\] are all in the array. **Example 2:*...
Think about how you would solve the problem in non-constant space. Can you apply that logic to the existing space? We don't care about duplicates or non-positive integers Remember that O(2n) = O(n)
Array,Hash Table
Hard
268,287,448,770
86
uh it's literally 12 a.m in the midnight a.m in the midnight a.m in the midnight so welcome to my channel and i'm here to do my hundred legal challenge and today we have lego 86 partition list as a medium question so might take a while to understand it so given ahead of the linked list and array x partition is such tha...
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
785
hello so today we are doing this problem called is graph bipartite from the lead code it's a medium problem and so let's get to it so the problem since we have an undirected graph and we want to return true if it if and only if it's be part bipartite and basically a graph is bipartite if we can split the set of nodes i...
Is Graph Bipartite?
basic-calculator-iii
There is an **undirected** graph with `n` nodes, where each node is numbered between `0` and `n - 1`. You are given a 2D array `graph`, where `graph[u]` is an array of nodes that node `u` is adjacent to. More formally, for each `v` in `graph[u]`, there is an undirected edge between node `u` and node `v`. The graph has ...
null
Math,String,Stack,Recursion
Hard
224,227,781,1736
349
hey everyone welcome back and let's write some more neat code today so today let's solve the problem intersection of two arrays we're given two integer arrays nums one and nums 2 and we want to find the intersection of them they don't really Define what exactly that is in this problem but basically it's elements that a...
Intersection of Two Arrays
intersection-of-two-arrays
Given two integer arrays `nums1` and `nums2`, return _an array of their intersection_. Each element in the result must be **unique** and you may return the result in **any order**. **Example 1:** **Input:** nums1 = \[1,2,2,1\], nums2 = \[2,2\] **Output:** \[2\] **Example 2:** **Input:** nums1 = \[4,9,5\], nums2 = \...
null
Array,Hash Table,Two Pointers,Binary Search,Sorting
Easy
350,1149,1392,2190,2282
44
this is the 44 flicker Challenge and it is called wild card matching given an input string s and a pattern P Implement wildcard pattern matching with support for question mark and asterisks where question mark matches a single character and asterisk matches any sequence of characters including the empty sequence the ma...
Wildcard Matching
wildcard-matching
Given an input string (`s`) and a pattern (`p`), implement wildcard pattern matching with support for `'?'` and `'*'` where: * `'?'` Matches any single character. * `'*'` Matches any sequence of characters (including the empty sequence). The matching should cover the **entire** input string (not partial). **Exam...
null
String,Dynamic Programming,Greedy,Recursion
Hard
10