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
310
hello everyone welcome back to my channel today i will introduce the analytical question minimal high trees and i will use typological to solve this problem from the description we can say we have a tree and it is a direct graph and each two node connected in one path so that means this graph without any circle connect...
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
252
and then you have to check if a person can attend a meeting so which means I uh in this case from 0 to 30 right so this is zero this is 30 and this is five this is 10 this is 15 this is 20. so you want to know if there is an interval that can I mean there's a person who can intercept with all of the interval right so b...
Meeting Rooms
meeting-rooms
Given an array of meeting time `intervals` where `intervals[i] = [starti, endi]`, determine if a person could attend all meetings. **Example 1:** **Input:** intervals = \[\[0,30\],\[5,10\],\[15,20\]\] **Output:** false **Example 2:** **Input:** intervals = \[\[7,10\],\[2,4\]\] **Output:** true **Constraints:** * ...
null
Array,Sorting
Easy
56,253
44
Hello Hi Science Students Questions, Monthly pension is available by liking Adityanath, If the details of this pack abs were white part complete, then the pattern has been made for graphic's reference, thank you, special program, Tarak Hain Mountain, National football team's practice session in its struggle character, ...
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
1,748
hi my name is david today we're going to do number 1748 sum of unique elements this is an easy level problem only code and we're going to solve it in javascript so you're given an integer array nums the unique elements of an array are the elements that appear exactly once in the red return the sum of all the unique ele...
Sum of Unique Elements
best-team-with-no-conflicts
You are given an integer array `nums`. The unique elements of an array are the elements that appear **exactly once** in the array. Return _the **sum** of all the unique elements of_ `nums`. **Example 1:** **Input:** nums = \[1,2,3,2\] **Output:** 4 **Explanation:** The unique elements are \[1,3\], and the sum is 4. ...
First, sort players by age and break ties by their score. You can now consider the players from left to right. If you choose to include a player, you must only choose players with at least that score later on.
Array,Dynamic Programming,Sorting
Medium
null
1,266
hello hi guys good morning welcome back to the new video this video we're see the problem minimum time visiting All Points although it's a easy problem and it is very intuitive also but it can be a way that you might get confused on how to approach these kind of problems which are kind of ad hoc and no algo or somethin...
Minimum Time Visiting All Points
minimum-time-visiting-all-points
On a 2D plane, there are `n` points with integer coordinates `points[i] = [xi, yi]`. Return _the **minimum time** in seconds to visit all the points in the order given by_ `points`. You can move according to these rules: * In `1` second, you can either: * move vertically by one unit, * move horizontally...
null
null
Easy
null
4
welcome to SF job slab we bring you our possible solution of interview portion including the most efficient one and today we will see how to find a median of two sorted arrays of size M and M so let us understand this portion with an example so let's assume if we have these areas where we have element values 6 9 15 and...
Median of Two Sorted Arrays
median-of-two-sorted-arrays
Given two sorted arrays `nums1` and `nums2` of size `m` and `n` respectively, return **the median** of the two sorted arrays. The overall run time complexity should be `O(log (m+n))`. **Example 1:** **Input:** nums1 = \[1,3\], nums2 = \[2\] **Output:** 2.00000 **Explanation:** merged array = \[1,2,3\] and median is ...
null
Array,Binary Search,Divide and Conquer
Hard
null
1,938
hey what's up guys this is chung here again so this time i'll lead code number 1938 maximum genetic difference query uh so this one is a pretty difficult one like to be honest it has some many a few small sub problems we need to solve first okay so we you're given like a rooted tree right consisting of unknowns number ...
Maximum Genetic Difference Query
minimum-operations-to-make-the-array-increasing
There is a rooted tree consisting of `n` nodes numbered `0` to `n - 1`. Each node's number denotes its **unique genetic value** (i.e. the genetic value of node `x` is `x`). The **genetic difference** between two genetic values is defined as the **bitwise-****XOR** of their values. You are given the integer array `paren...
nums[i+1] must be at least equal to nums[i] + 1. Think greedily. You don't have to increase nums[i+1] beyond nums[i]+1. Iterate on i and set nums[i] = max(nums[i-1]+1, nums[i]) .
Array,Greedy
Easy
2329
162
you guys it's just everything go in this video I'm going to take a look at 1 6 to find peak animun a peak annamund is a name and that is greater than its neighbors we're given an input array noms we're no adjacent numbers are equal so there must be a peak because we are asked that the minus 1 and the next number will b...
Find Peak Element
find-peak-element
A peak element is an element that is strictly greater than its neighbors. Given a **0-indexed** integer array `nums`, find a peak element, and return its index. If the array contains multiple peaks, return the index to **any of the peaks**. You may imagine that `nums[-1] = nums[n] = -∞`. In other words, an element is...
null
Array,Binary Search
Medium
882,2047,2273,2316
1,752
hey yo what's up my little coders let me show you in this tutorial how to solve the leadpro question number 1752 check if array is sorted and rotated let me just explain an example what we need to do basically imagine that this is our input array if we sort this input array this is what we will get so one two three fou...
Check if Array Is Sorted and Rotated
arithmetic-subarrays
Given an array `nums`, return `true` _if the array was originally sorted in non-decreasing order, then rotated **some** number of positions (including zero)_. Otherwise, return `false`. There may be **duplicates** in the original array. **Note:** An array `A` rotated by `x` positions results in an array `B` of the sa...
To check if a given sequence is arithmetic, just check that the difference between every two consecutive elements is the same. If and only if a set of numbers can make an arithmetic sequence, then its sorted version makes an arithmetic sequence. So to check a set of numbers, sort it, and check if that sequence is arith...
Array,Sorting
Medium
413,1626
1,344
hello and welcome today we're doing a question from week code called angle between hands of a clock it's a medium let's get started given two numbers our minutes returned the smaller angle in degrees formed between the hour and the minute hand example given our 12 minutes 30 we output 165 and here there could be two po...
Angle Between Hands of a Clock
maximum-equal-frequency
Given two numbers, `hour` and `minutes`, return _the smaller angle (in degrees) formed between the_ `hour` _and the_ `minute` _hand_. Answers within `10-5` of the actual value will be accepted as correct. **Example 1:** **Input:** hour = 12, minutes = 30 **Output:** 165 **Example 2:** **Input:** hour = 3, minutes ...
Keep track of the min and max frequencies. The number to be eliminated must have a frequency of 1, same as the others or the same +1.
Array,Hash Table
Hard
null
1,675
friends welcome to code Sutra in this video we'll be discussing about lead code problem number 1675 minimize the deviation in an array in this problem we are given an array for example this particular array and what is deviation it is the difference between the maximum element and the minimum element what is the deviat...
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
1,063
Ajay Ko's management coding on the site So today we have to do number of balance sub address this question 21 What to do then name will get a chance There will be some elements in it Reverse proposal 132 So what to do in one question Basically all the sub balance surveys have to be rested If there were four such tights...
Number of Valid Subarrays
best-sightseeing-pair
Given an integer array `nums`, return _the number of non-empty **subarrays** with the leftmost element of the subarray not larger than other elements in the subarray_. A **subarray** is a **contiguous** part of an array. **Example 1:** **Input:** nums = \[1,4,2,5,3\] **Output:** 11 **Explanation:** There are 11 vali...
Can you tell the best sightseeing spot in one pass (ie. as you iterate over the input?) What should we store or keep track of as we iterate to do this?
Array,Dynamic Programming
Medium
null
1,710
hey hi my name is today i'm trying to solve the july the new month juliet coach new challenge so the question is maximum units on a track and the question number is one seven one zero so the problem is came as a liquid easy so the problem is given there the vector of vector has been given which has a uh the given uh da...
Maximum Units on a Truck
find-servers-that-handled-most-number-of-requests
You are assigned to put some amount of boxes onto **one truck**. You are given a 2D array `boxTypes`, where `boxTypes[i] = [numberOfBoxesi, numberOfUnitsPerBoxi]`: * `numberOfBoxesi` is the number of boxes of type `i`. * `numberOfUnitsPerBoxi` is the number of units in each box of the type `i`. You are also given...
To speed up the next available server search, keep track of the available servers in a sorted structure such as an ordered set. To determine if a server is available, keep track of the end times for each task in a heap and add the server to the available set once the soonest task ending time is less than or equal to th...
Array,Greedy,Heap (Priority Queue),Ordered Set
Hard
null
126
today we will solve a problem called world ladder and this is the second version of this problem so feel free to check the first version also so here we have a number of words in a list and we have to reach from word one which will be called the starting word and then end word so we have to reach from here to here and ...
Word Ladder II
word-ladder-ii
A **transformation sequence** from word `beginWord` to word `endWord` using a dictionary `wordList` is a sequence of words `beginWord -> s1 -> s2 -> ... -> sk` such that: * Every adjacent pair of words differs by a single letter. * Every `si` for `1 <= i <= k` is in `wordList`. Note that `beginWord` does not need ...
null
Hash Table,String,Backtracking,Breadth-First Search
Hard
127,2276
284
hello everybody this is larry this is day 25 of the august record daily challenge hit the like button hit the subscribe button join me on discord let me know what you think about dave's farm i have some like allergy stuff yeah tree allergies what am i gonna do my choice problem is peaking iterator design an iterator th...
Peeking Iterator
peeking-iterator
Design an iterator that supports the `peek` operation on an existing iterator in addition to the `hasNext` and the `next` operations. Implement the `PeekingIterator` class: * `PeekingIterator(Iterator nums)` Initializes the object with the given integer iterator `iterator`. * `int next()` Returns the next element...
Think of "looking ahead". You want to cache the next element. Is one variable sufficient? Why or why not? Test your design with call order of peek() before next() vs next() before peek(). For a clean implementation, check out Google's guava library source code.
Array,Design,Iterator
Medium
173,251,281
1,095
hello everyone welcome to my you programming club today we will be solving another daily El Cod Challenge and the name of challenge is find in Mountain array so it is mentioned that it is a interactive problem uh you can recall an array you can recall that array is a mountain array if and only if the following conditio...
Find in Mountain Array
two-city-scheduling
_(This problem is an **interactive problem**.)_ You may recall that an array `arr` is a **mountain array** if and only if: * `arr.length >= 3` * There exists some `i` with `0 < i < arr.length - 1` such that: * `arr[0] < arr[1] < ... < arr[i - 1] < arr[i]` * `arr[i] > arr[i + 1] > ... > arr[arr.length ...
null
Array,Greedy,Sorting
Medium
null
1,237
hello and welcome today we are doing another liquid problem on binary search okay so this is the problem find the positive integer solution for a given equation let's see what is the problem statement it says that given a callable function if y function f which have parameter X and Y with a hidden formula and value set...
Find Positive Integer Solution for a Given Equation
reported-posts-ii
Given a callable function `f(x, y)` **with a hidden formula** and a value `z`, reverse engineer the formula and return _all positive integer pairs_ `x` _and_ `y` _where_ `f(x,y) == z`. You may return the pairs in any order. While the exact formula is hidden, the function is monotonically increasing, i.e.: * `f(x, y...
null
Database
Medium
null
387
Jhaal 500 Hi I love you doing well 100 grams people are going to start Elbow master sheet is ok and for this I will make a dedicated play list separately ok so this is a very good thing man this is a great practice algorithms and for interview purpose so Ashram, let's see how much we can solve and how much consistency ...
First Unique Character in a String
first-unique-character-in-a-string
Given a string `s`, _find the first non-repeating character in it and return its index_. If it does not exist, return `-1`. **Example 1:** **Input:** s = "leetcode" **Output:** 0 **Example 2:** **Input:** s = "loveleetcode" **Output:** 2 **Example 3:** **Input:** s = "aabb" **Output:** -1 **Constraints:** * `...
null
Hash Table,String,Queue,Counting
Easy
451
145
hey guys welcome back to the Advent and this is Nixon today we are going to solve a new problem from lead code it is the 145th problem binary tree post order traversal given the root of a binary tree return its post order traversal of its notes value let me explain this problem guys and before solving this problem we j...
Binary Tree Postorder Traversal
binary-tree-postorder-traversal
Given the `root` of a binary tree, return _the postorder traversal of its nodes' values_. **Example 1:** **Input:** root = \[1,null,2,3\] **Output:** \[3,2,1\] **Example 2:** **Input:** root = \[\] **Output:** \[\] **Example 3:** **Input:** root = \[1\] **Output:** \[1\] **Constraints:** * The number of the n...
null
Stack,Tree,Depth-First Search,Binary Tree
Easy
94,776
876
Hello everyone welcome, my channel of D link list is easy level question is ok 76 ok so let's see it is quite popular in my respect company is ok Amazon Microsoft Flipkart Johan me peacock is ok and many more we have not mentioned all of them for you to see So you go to my GitHub wrap, I have mentioned it in the descri...
Middle of the Linked List
hand-of-straights
Given the `head` of a singly linked list, return _the middle node of the linked list_. If there are two middle nodes, return **the second middle** node. **Example 1:** **Input:** head = \[1,2,3,4,5\] **Output:** \[3,4,5\] **Explanation:** The middle node of the list is node 3. **Example 2:** **Input:** head = \[1,...
null
Array,Hash Table,Greedy,Sorting
Medium
null
347
hi hello so today we'll talk about top key frequent element so given an integer ray nums an integer k we have to return k most frequent elements and the answer could be in any order so let's understand with an example so if we have in this example we have three one is repeated three times two repeated two time and thre...
Top K Frequent Elements
top-k-frequent-elements
Given an integer array `nums` and an integer `k`, return _the_ `k` _most frequent elements_. You may return the answer in **any order**. **Example 1:** **Input:** nums = \[1,1,1,2,2,3\], k = 2 **Output:** \[1,2\] **Example 2:** **Input:** nums = \[1\], k = 1 **Output:** \[1\] **Constraints:** * `1 <= nums.lengt...
null
Array,Hash Table,Divide and Conquer,Sorting,Heap (Priority Queue),Bucket Sort,Counting,Quickselect
Medium
192,215,451,659,692,1014,1919
297
Hello friends uh welcome to my channel let's have a look at problem 297. she realized and the serialized binary tree this problem or this video is a follow-up for problem follow-up for problem follow-up for problem 652 so here we practice both serialization and this serialization so in between we are going to use recur...
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
414
hey everyone welcome back and today we'll be doing another lead code four one four third maximum number and easy one given an integer array numbers return the district maximum number in this array if the third maximum does not exist return the maximum number so in this case you can see here like three to one the third ...
Third Maximum Number
third-maximum-number
Given an integer array `nums`, return _the **third distinct maximum** number in this array. If the third maximum does not exist, return the **maximum** number_. **Example 1:** **Input:** nums = \[3,2,1\] **Output:** 1 **Explanation:** The first distinct maximum is 3. The second distinct maximum is 2. The third distin...
null
Array,Sorting
Easy
215
76
so question 76 of leake code minimum window substring so given two strings s and t of lengths m and n respectively return the minimum window substring of s such that every character in t including duplicates is included in the window if there is no such substring return the empty string so the test cases will be genera...
Minimum Window Substring
minimum-window-substring
Given two strings `s` and `t` of lengths `m` and `n` respectively, return _the **minimum window**_ **_substring_** _of_ `s` _such that every character in_ `t` _(**including duplicates**) is included in the window_. If there is no such substring, return _the empty string_ `" "`. The testcases will be generated such tha...
Use two pointers to create a window of letters in S, which would have all the characters from T. Since you have to find the minimum window in S which has all the characters from T, you need to expand and contract the window using the two pointers and keep checking the window for all the characters. This approach is als...
Hash Table,String,Sliding Window
Hard
30,209,239,567,632,727
968
hello and welcome to this problem number 968 binary tree cameras so as you would have seen i have actually changed in the camera setup a bit instead of the left side my face you will see on the right side uh that's simply because i realized that the way lead code ide is set up a lot of the space is actually taken up by...
Binary Tree Cameras
beautiful-array
You are given the `root` of a binary tree. We install cameras on the tree nodes where each camera at a node can monitor its parent, itself, and its immediate children. Return _the minimum number of cameras needed to monitor all nodes of the tree_. **Example 1:** **Input:** root = \[0,0,null,0,0\] **Output:** 1 **Exp...
null
Array,Math,Divide and Conquer
Medium
null
1,451
hello yours welcome back to my channel I hope you are doing great if you haven't subscribed to my channel yet please go ahead and subscribe I have created bunch of playlists to cover various categories of the problem such as linking list trees graphs breadth-first search binary search breadth-first search binary search...
Rearrange Words in a Sentence
minimum-number-of-taps-to-open-to-water-a-garden
Given a sentence `text` (A _sentence_ is a string of space-separated words) in the following format: * First letter is in upper case. * Each word in `text` are separated by a single space. Your task is to rearrange the words in text such that all words are rearranged in an increasing order of their lengths. If tw...
Create intervals of the area covered by each tap, sort intervals by the left end. We need to cover the interval [0, n]. we can start with the first interval and out of all intervals that intersect with it we choose the one that covers the farthest point to the right. What if there is a gap between intervals that is not...
Array,Dynamic Programming,Greedy
Hard
null
1,071
hello everyone welcome to algo simplified let's solve today's lead code challenge that is greatest common divisor of strings in this problem we are given two strings and we have to find a string that is a largest string which can divide both the given strings which means on concatenation of the resultant string one or ...
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
316
Hello friends, welcome to your Day 46 of Lead Code Challenge, so let's go straight to the screen and start today's question. So here we are on our screen. Today's question number is 316 and question number. The name is Remove Duplicate Letter. Okay, this question is a very interesting question, meaning whatever you mig...
Remove Duplicate Letters
remove-duplicate-letters
Given a string `s`, remove duplicate letters so that every letter appears once and only once. You must make sure your result is **the smallest in lexicographical order** among all possible results. **Example 1:** **Input:** s = "bcabc " **Output:** "abc " **Example 2:** **Input:** s = "cbacdcbc " **Output:** "a...
Greedily try to add one missing character. How to check if adding some character will not cause problems ? Use bit-masks to check whether you will be able to complete the sub-sequence if you add the character at some index i.
String,Stack,Greedy,Monotonic Stack
Medium
2157
766
foreign with lonely Dash and today we're going over toplet's Matrix number 766 of elite code which says given an M by n Matrix return true if the Matrix is dopelets otherwise return false a matrix is toplets if every diagonal from top left to bottom right has the same elements I'm only hoping I'm saying this word right...
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
419
Hello Welcome Back Friends Today We Are Going to Solid Code Problem 498 A Lips in Awards Show's One Environment Report and Beach Sail Kiss Battleship Another Anti-Return Number of Kiss Battleship Another Anti-Return Number of Kiss Battleship Another Anti-Return Number of Battleships Folded Inside Battleships Can Only P...
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
5
Hello everyone welcome to my channel Quote Sorry with Mike So today we are going to do video number 72 of our dynamic programming playlist. Lead code number is five. It is a medium question but actually it is quite easy. If you look at it then the constraints have also been kept small. Okay and This is a very popular q...
Longest Palindromic Substring
longest-palindromic-substring
Given a string `s`, return _the longest_ _palindromic_ _substring_ in `s`. **Example 1:** **Input:** s = "babad " **Output:** "bab " **Explanation:** "aba " is also a valid answer. **Example 2:** **Input:** s = "cbbd " **Output:** "bb " **Constraints:** * `1 <= s.length <= 1000` * `s` consist of only dig...
How can we reuse a previously computed palindrome to compute a larger palindrome? If “aba” is a palindrome, is “xabax” a palindrome? Similarly is “xabay” a palindrome? Complexity based hint: If we use brute-force and check whether for every start and end position a substring is a palindrome we have O(n^2) start - end ...
String,Dynamic Programming
Medium
214,266,336,516,647
143
hello friends uh welcome to my channel let's have a look at problem 143 reorder list so here the list is actually a singly linked list so in this video we're going to share a solution based on linear traversal and reversal so first i'll read through the problem statement to digest the requirement and then we go over th...
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
42
hello guys welcome to algorithms made easy so today we are going to see the question trapping rainwater let's quickly go through the problem statement given n non-negative integers statement given n non-negative integers statement given n non-negative integers representing an elevation map where the width of each bar i...
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
309
uh so we have an array for which the ith element is the price of a given stock on day i so we have to design an algorithm to find a maximum profit you may complete as many transactions as you like and that is buy one and sell one share of the stock multiple times with the following restrictions you may not engage in mu...
Best Time to Buy and Sell Stock with Cooldown
best-time-to-buy-and-sell-stock-with-cooldown
You are given an array `prices` where `prices[i]` is the price of a given stock on the `ith` day. Find the maximum profit you can achieve. You may complete as many transactions as you like (i.e., buy one and sell one share of the stock multiple times) with the following restrictions: * After you sell your stock, yo...
null
Array,Dynamic Programming
Medium
121,122
234
[MUSIC] QUESTION KEY YOU SO LET'S START IT IS PERENBUM LINK LIST OK SO WHAT DES EN MARRIAGE MINS FIRST OF WHO IF WE SEE THIS NOT IF WE CONSIDER NUMBER DATE IS ONE YOU TU ONE SO IF WE START IT FROM D STARTING In and they bill come de number it note so what they need you do they have you start reading from meaning they h...
Palindrome Linked List
palindrome-linked-list
Given the `head` of a singly linked list, return `true` _if it is a_ _palindrome_ _or_ `false` _otherwise_. **Example 1:** **Input:** head = \[1,2,2,1\] **Output:** true **Example 2:** **Input:** head = \[1,2\] **Output:** false **Constraints:** * The number of nodes in the list is in the range `[1, 105]`. * ...
null
Linked List,Two Pointers,Stack,Recursion
Easy
9,125,206,2236
216
Jhal Hello Hi Guys Welcome to Cold Weather Today is Question is Combination No. 3 in this question be up to find all the possible combination of number dep guddu and number and given to 19 number from one to 9 can be used and its unique number boys And Give The Number 2 And Subscribe Combination Video give Number Dista...
Combination Sum III
combination-sum-iii
Find all valid combinations of `k` numbers that sum up to `n` such that the following conditions are true: * Only numbers `1` through `9` are used. * Each number is used **at most once**. Return _a list of all possible valid combinations_. The list must not contain the same combination twice, and the combinations...
null
Array,Backtracking
Medium
39
68
hello everyone welcome back here is my name and today we are tackling the infamous text justification problem number 68 uh on uh little daily challenge so it's a fantastic challenge especially for interview so first thing first understanding the problem we are essentially building a mini justify feature for a word proc...
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
342
so for today's question that is power of 4 we have been given an integer n that should return true if it is a power of 4 otherwise it should return false so basically uh n is the power of 4 that means uh for integer x such that n is equals to 4 part x like it should be a power of 4 so 4 16 into 4 something like that it...
Power of Four
power-of-four
Given an integer `n`, return _`true` if it is a power of four. Otherwise, return `false`_. An integer `n` is a power of four, if there exists an integer `x` such that `n == 4x`. **Example 1:** **Input:** n = 16 **Output:** true **Example 2:** **Input:** n = 5 **Output:** false **Example 3:** **Input:** n = 1 **O...
null
Math,Bit Manipulation,Recursion
Easy
231,326
1,641
Hello hello guys welcome back today we are going to solve dynamic programming account south wales prince problem statement that you have been in India, the length of the screen and kept you tied is in English subscribe which is made by us should be the previous one. Subscribe one two three 500 appointed subscribe now s...
Count Sorted Vowel Strings
countries-you-can-safely-invest-in
Given an integer `n`, return _the number of strings of length_ `n` _that consist only of vowels (_`a`_,_ `e`_,_ `i`_,_ `o`_,_ `u`_) and are **lexicographically sorted**._ A string `s` is **lexicographically sorted** if for all valid `i`, `s[i]` is the same as or comes before `s[i+1]` in the alphabet. **Example 1:** ...
null
Database
Medium
615
835
uh hey everybody this is larry this is me doing uh day six of the september lego daily challenge on september uh hit the like button the subscribe button i'm gonna do this live so join me on discord in image overlap i think i did this on a contest or something like that i think the big thing to notice is that n is equa...
Image Overlap
linked-list-components
You are given two images, `img1` and `img2`, represented as binary, square matrices of size `n x n`. A binary matrix has only `0`s and `1`s as values. We **translate** one image however we choose by sliding all the `1` bits left, right, up, and/or down any number of units. We then place it on top of the other image. W...
null
Hash Table,Linked List
Medium
2299
1,844
Hello hello one to baat hai gopal number 84 ki replace all widgets end with characters to pun interesting like this loud english letter this end subscribe and subscribe - 40000 example2 subscribe - 40000 example2 subscribe - 40000 example2 and this so like this is my second this that this is my It is an English letter ...
Replace All Digits with Characters
maximum-number-of-balls-in-a-box
You are given a **0-indexed** string `s` that has lowercase English letters in its **even** indices and digits in its **odd** indices. There is a function `shift(c, x)`, where `c` is a character and `x` is a digit, that returns the `xth` character after `c`. * For example, `shift('a', 5) = 'f'` and `shift('x', 0) =...
Note that both lowLimit and highLimit are of small constraints so you can iterate on all nubmer between them You can simulate the boxes by counting for each box the number of balls with digit sum equal to that box number
Hash Table,Math,Counting
Easy
null
600
hey what's up guys this is chung here so this time uh today's daily challenge problem right number 600 non-negative integers without 600 non-negative integers without 600 non-negative integers without consecutive ones uh so this one is pretty tricky one and okay so the description is very short so you're given like pos...
Non-negative Integers without Consecutive Ones
non-negative-integers-without-consecutive-ones
Given a positive integer `n`, return the number of the integers in the range `[0, n]` whose binary representations **do not** contain consecutive ones. **Example 1:** **Input:** n = 5 **Output:** 5 **Explanation:** Here are the non-negative integers <= 5 with their corresponding binary representations: 0 : 0 1 : 1 2 ...
null
Dynamic Programming
Hard
198,213,474
886
hello everyone in this video we're going to be looking at the solution to delete code problem possible by partition so in this problem were given a set of n people so we have n people and we want to split everyone into two groups of any size so there's any size now each person may dislike some other person so they shou...
Possible Bipartition
score-of-parentheses
We want to split a group of `n` people (labeled from `1` to `n`) into two groups of **any size**. Each person may dislike some other people, and they should not go into the same group. Given the integer `n` and the array `dislikes` where `dislikes[i] = [ai, bi]` indicates that the person labeled `ai` does not like the...
null
String,Stack
Medium
null
1,998
hey everybody this is larry this is me going with q4 of the weekly contest 257. yikes uh gcd sort of an array so yeah so basically this is a tricky problem hit the like button hit the subscribe button join me on discord let me know what you think about this problem especially if you'd like to talk about this and other ...
GCD Sort of an Array
suspicious-bank-accounts
You are given an integer array `nums`, and you can perform the following operation **any** number of times on `nums`: * Swap the positions of two elements `nums[i]` and `nums[j]` if `gcd(nums[i], nums[j]) > 1` where `gcd(nums[i], nums[j])` is the **greatest common divisor** of `nums[i]` and `nums[j]`. Return `true`...
null
Database
Medium
null
1,679
hey guys in this video I'm going to talk about a lead code problem the problem's name is Max number of K some pairs so in this question we given an integer ARR nums and also integer variable K in one operation we have to pick two numbers from the array whose sum is equal to K and remove them from the array and we have ...
Max Number of K-Sum Pairs
shortest-subarray-to-be-removed-to-make-array-sorted
You are given an integer array `nums` and an integer `k`. In one operation, you can pick two numbers from the array whose sum equals `k` and remove them from the array. Return _the maximum number of operations you can perform on the array_. **Example 1:** **Input:** nums = \[1,2,3,4\], k = 5 **Output:** 2 **Explana...
The key is to find the longest non-decreasing subarray starting with the first element or ending with the last element, respectively. After removing some subarray, the result is the concatenation of a sorted prefix and a sorted suffix, where the last element of the prefix is smaller than the first element of the suffix...
Array,Two Pointers,Binary Search,Stack,Monotonic Stack
Medium
null
914
hey everybody this is larry and this is now me doing the bonus question uh hit the like button hit the subscribe button join me on discord let me know what you think about you know today's bonus question i'm gonna do a hard today uh um okay fine let's actually just let the rng choose because i don't know if you're doin...
X of a Kind in a Deck of Cards
random-point-in-non-overlapping-rectangles
You are given an integer array `deck` where `deck[i]` represents the number written on the `ith` card. Partition the cards into **one or more groups** such that: * Each group has **exactly** `x` cards where `x > 1`, and * All the cards in one group have the same integer written on them. Return `true` _if such pa...
null
Math,Binary Search,Reservoir Sampling,Prefix Sum,Ordered Set,Randomized
Medium
912,915
191
hello everyone so in this video let us talk about one more problem from lead code the problem name is number of one bits so this problem is from the top interview question series i've been working on from lead code so if you haven't checked it out i have the link of that delays in the description of this video so go ch...
Number of 1 Bits
number-of-1-bits
Write a function that takes the binary representation of an unsigned integer and returns the number of '1' bits it has (also known as the [Hamming weight](http://en.wikipedia.org/wiki/Hamming_weight)). **Note:** * Note that in some languages, such as Java, there is no unsigned integer type. In this case, the input ...
null
Bit Manipulation
Easy
190,231,338,401,461,693,767
965
hey guys welcome back to my channel and i'm back again with another really interesting coding interview question video this time guys we are going to solve question number 965 univalued binary tree before i start with the video guys just want to ask you that if you have not yet subscribed to my channel then please do s...
Univalued Binary Tree
unique-email-addresses
A binary tree is **uni-valued** if every node in the tree has the same value. Given the `root` of a binary tree, return `true` _if the given tree is **uni-valued**, or_ `false` _otherwise._ **Example 1:** **Input:** root = \[1,1,1,1,1,null,1\] **Output:** true **Example 2:** **Input:** root = \[2,2,2,5,2\] **Outpu...
null
Array,Hash Table,String
Easy
null
134
guys babybear4812 coming at you one more time today with another oldie but a goodie it's the gas station problem number one three four uh this question is currently as of uh fall 2020 being asked by amazon google microsoft facebook uber apple bloomberg so a lot of the big guns have picked it up it's an old one but it's...
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
130
Loot Hello Everyone Welcome To My Channel Today 17.3 Problem Is Remedy Issa Gaon 17.3 Problem Is Remedy Issa Gaon 17.3 Problem Is Remedy Issa Gaon Intuitive Who Don't Tanning Correction Kar Actor Who Did All Reasons Why All Goals In To-Do Example Which Acts After Running In To-Do Example Which Acts After Running In To-...
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
342
this is power of 4 lead code challenge 342. giving an integer n we have to return true if N is a power of 4 otherwise we have to return false an integer N is a power of 4 if there exists an integer X such that 4 to the power of X is equal to n an example is here we can have 4 to the power of 2 this is 16 so we can retu...
Power of Four
power-of-four
Given an integer `n`, return _`true` if it is a power of four. Otherwise, return `false`_. An integer `n` is a power of four, if there exists an integer `x` such that `n == 4x`. **Example 1:** **Input:** n = 16 **Output:** true **Example 2:** **Input:** n = 5 **Output:** false **Example 3:** **Input:** n = 1 **O...
null
Math,Bit Manipulation,Recursion
Easy
231,326
129
hello guys this is expert Wanda and today we are going to see the little question that we have today is 129 and this question is uh 129 some root 2 Leaf notes and leaf numbers so you are given a root of binary tree and that containing uh this is from 0 to 9 only okay we have digits and that is 1 0 to 9. each route to l...
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
316
hello everyone welcome to myu programming Club today we will be solving another daily lead code challenge and the challenge name is we move duplicates in letters so you are given a string s and you have to remove duplicate letters so that every letter appear exactly one and on once and only once so for example in this ...
Remove Duplicate Letters
remove-duplicate-letters
Given a string `s`, remove duplicate letters so that every letter appears once and only once. You must make sure your result is **the smallest in lexicographical order** among all possible results. **Example 1:** **Input:** s = "bcabc " **Output:** "abc " **Example 2:** **Input:** s = "cbacdcbc " **Output:** "a...
Greedily try to add one missing character. How to check if adding some character will not cause problems ? Use bit-masks to check whether you will be able to complete the sub-sequence if you add the character at some index i.
String,Stack,Greedy,Monotonic Stack
Medium
2157
452
That Hey Guys Welcome Channel White Udayveer A Problem Call Minimum Number Four Equals To Forget Problem That Comes In Various From Interview Video Problem 28 Without Status Minimum Number Of Meeting Rooms Spider-Man Uber Number Of Meeting Rooms Spider-Man Uber Number Of Meeting Rooms Spider-Man Uber Of Nations For Its...
Minimum Number of Arrows to Burst Balloons
minimum-number-of-arrows-to-burst-balloons
There are some spherical balloons taped onto a flat wall that represents the XY-plane. The balloons are represented as a 2D integer array `points` where `points[i] = [xstart, xend]` denotes a balloon whose **horizontal diameter** stretches between `xstart` and `xend`. You do not know the exact y-coordinates of the ball...
null
Array,Greedy,Sorting
Medium
253,435
382
Hello friends today I'm going to solve liquid problem number 382 linked list random node so in this problem we need to implement the solution class has two um functions the first function is solution linked node head and the next function is get random function so basically this is a Constructor function and this is a ...
Linked List Random Node
linked-list-random-node
Given a singly linked list, return a random node's value from the linked list. Each node must have the **same probability** of being chosen. Implement the `Solution` class: * `Solution(ListNode head)` Initializes the object with the head of the singly-linked list `head`. * `int getRandom()` Chooses a node randoml...
null
Linked List,Math,Reservoir Sampling,Randomized
Medium
398
518
hey hello there today's recording challenge question is coin change - it's challenge question is coin change - it's challenge question is coin change - it's a dynamic programming question so let's talk about the structure we have a few different type of coins that we can use to sum up a to a certain amount each type of...
Coin Change II
coin-change-2
You are given an integer array `coins` representing coins of different denominations and an integer `amount` representing a total amount of money. Return _the number of combinations that make up that amount_. If that amount of money cannot be made up by any combination of the coins, return `0`. You may assume that yo...
null
Array,Dynamic Programming
Medium
1393
973
hello and welcome today we'll be doing a question from weeks ago called K closest points to origin is a medium let's get started so we have a list of points on the plane find the K closest points to the origin 0 here the distance between two points on a plane is a Euclidean distance so that's just x squared plus y squa...
K Closest Points to Origin
stamping-the-sequence
Given an array of `points` where `points[i] = [xi, yi]` represents a point on the **X-Y** plane and an integer `k`, return the `k` closest points to the origin `(0, 0)`. The distance between two points on the **X-Y** plane is the Euclidean distance (i.e., `√(x1 - x2)2 + (y1 - y2)2`). You may return the answer in **an...
null
String,Stack,Greedy,Queue
Hard
null
424
hey everyone welcome back and let's write some more neat code today so today we're going to solve longest repeating character replacement and so this is another problem from that blind 75 list so we are going to be one step closer to completing the entire list the link will be in the description to this spreadsheet if ...
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
74
hi everyone today i'm going to be solving the lead code question search a 2d matrix so the problem is telling you to write an efficient algorithm that searches for a value target in the m by n integer matrix and you're sold and you're told that it's already sorted so the elements are sorted from left to right and the f...
Search a 2D Matrix
search-a-2d-matrix
You are given an `m x n` integer matrix `matrix` with the following two properties: * Each row is sorted in non-decreasing order. * The first integer of each row is greater than the last integer of the previous row. Given an integer `target`, return `true` _if_ `target` _is in_ `matrix` _or_ `false` _otherwise_. ...
null
Array,Binary Search,Matrix
Medium
240
1,171
Hello everyone welcome to my channel with mike so today you are going to do video number nine of linked list ok the name of the question is remove zero sum consecutive notes from linked list it is a medium level question but bill will be very easy if we understand it ok From this, lead role number one seven one is fine...
Remove Zero Sum Consecutive Nodes from Linked List
shortest-path-in-binary-matrix
Given the `head` of a linked list, we repeatedly delete consecutive sequences of nodes that sum to `0` until there are no such sequences. After doing so, return the head of the final linked list. You may return any such answer. (Note that in the examples below, all sequences are serializations of `ListNode` objects.)...
Do a breadth first search to find the shortest path.
Array,Breadth-First Search,Matrix
Medium
null
1,611
hey what's up guys this is sean here so today let's take a look at uh last problem of last week's weekly contest number one thousand 1611 minimum one bit operations to make integers zero okay so you know this is like a quite interesting problem you know okay given like an integer and you must transform it into zero usi...
Minimum One Bit Operations to Make Integers Zero
making-file-names-unique
Given an integer `n`, you must transform it into `0` using the following operations any number of times: * Change the rightmost (`0th`) bit in the binary representation of `n`. * Change the `ith` bit in the binary representation of `n` if the `(i-1)th` bit is set to `1` and the `(i-2)th` through `0th` bits are set...
Keep a map of each name and the smallest valid integer that can be appended as a suffix to it. If the name is not present in the map, you can use it without adding any suffixes. If the name is present in the map, append the smallest proper suffix, and add the new name to the map.
Array,Hash Table,String
Medium
null
1,254
hi everybody today we're going to solve a graph question from lee code number 1254 number of closed islands this question is very similar to the number of islands questioned but with one additional requirement so the question says given a 2d grid consisting of zeros representing lands and once representing water an isl...
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,046
Effect of Come in City Will Discuss Your Problems and a Good Practice Problem Number S-10 600 800 How to Problem Previous Number S-10 600 800 How to Problem Previous Number S-10 600 800 How to Problem Previous Two Pure Problem Statement Saying You This Collection and Stones is a Stone When Positive Integer Constant Sub...
Last Stone Weight
max-consecutive-ones-iii
You are given an array of integers `stones` where `stones[i]` is the weight of the `ith` stone. We are playing a game with the stones. On each turn, we choose the **heaviest two stones** and smash them together. Suppose the heaviest two stones have weights `x` and `y` with `x <= y`. The result of this smash is: * I...
One thing's for sure, we will only flip a zero if it extends an existing window of 1s. Otherwise, there's no point in doing it, right? Think Sliding Window! Since we know this problem can be solved using the sliding window construct, we might as well focus in that direction for hints. Basically, in a given window, we c...
Array,Binary Search,Sliding Window,Prefix Sum
Medium
340,424,485,487,2134
403
So Frog Jump So this is Lead Quote's 403 challenge so come on guys let's see what the problem is A frog crossing a river The river is divided into some number of units and at each unit there may not exist a stone The frog can jump on a stone but it must not jump into the water. It means that suppose we have given a riv...
Frog Jump
frog-jump
A frog is crossing a river. The river is divided into some number of units, and at each unit, there may or may not exist a stone. The frog can jump on a stone, but it must not jump into the water. Given a list of `stones`' positions (in units) in sorted **ascending order**, determine if the frog can cross the river by...
null
Array,Dynamic Programming
Hard
1952,2262
48
everyone welcome back to my channel so today we will solve one medium level question so till now we are solving easy level questions today we'll go with one medium question it's called rotate image let's understand the problem statement and try to solve it so it's very interesting question and let's see how uh it proce...
Rotate Image
rotate-image
You are given an `n x n` 2D `matrix` representing an image, rotate the image by **90** degrees (clockwise). You have to rotate the image [**in-place**](https://en.wikipedia.org/wiki/In-place_algorithm), which means you have to modify the input 2D matrix directly. **DO NOT** allocate another 2D matrix and do the rotati...
null
Array,Math,Matrix
Medium
2015
322
Hello hello guys welcome back to take devotion in this video you will see the question problem which is the way reaction of the bond website problem and destroyed number-22 latest see the problem statement number-22 latest see the problem statement number-22 latest see the problem statement in this problem of different...
Coin Change
coin-change
You are given an integer array `coins` representing coins of different denominations and an integer `amount` representing a total amount of money. Return _the fewest number of coins that you need to make up that amount_. If that amount of money cannot be made up by any combination of the coins, return `-1`. You may a...
null
Array,Dynamic Programming,Breadth-First Search
Medium
1025,1393,2345
412
uh hey everybody this is larry this is day 26 of the august eco daily challenge uh hit the like button hit the subscribe button join me on discord and let me know what you think about today's problem fizzbuzz uh given one two and three and five is frizz and buzz this is silly uh okay um if you're watching this i don't ...
Fizz Buzz
fizz-buzz
Given an integer `n`, return _a string array_ `answer` _(**1-indexed**) where_: * `answer[i] == "FizzBuzz "` if `i` is divisible by `3` and `5`. * `answer[i] == "Fizz "` if `i` is divisible by `3`. * `answer[i] == "Buzz "` if `i` is divisible by `5`. * `answer[i] == i` (as a string) if none of the above condit...
null
Math,String,Simulation
Easy
1316
73
what's going on guys it's your boy Chuck here we have another leak code problem I actually solved it already and I got it right surprisingly on the first try I figured my solution was to some degree unique so I wanted to go over it right now I'm very new to the leak code scene I've solved 84 problems to date so I'm sti...
Set Matrix Zeroes
set-matrix-zeroes
Given an `m x n` integer matrix `matrix`, if an element is `0`, set its entire row and column to `0`'s. You must do it [in place](https://en.wikipedia.org/wiki/In-place_algorithm). **Example 1:** **Input:** matrix = \[\[1,1,1\],\[1,0,1\],\[1,1,1\]\] **Output:** \[\[1,0,1\],\[0,0,0\],\[1,0,1\]\] **Example 2:** **In...
If any cell of the matrix has a zero we can record its row and column number using additional memory. But if you don't want to use extra memory then you can manipulate the array instead. i.e. simulating exactly what the question says. Setting cell values to zero on the fly while iterating might lead to discrepancies. ...
Array,Hash Table,Matrix
Medium
289,2244,2259,2314
398
hey guys how's everything going this is Jay sir who is not good at algorithms in this video I'm going to take a look at 3 9 8 a random picking next we're given an array of integers with possible duplicates mm-hmm it is not sorted duplicates mm-hmm it is not sorted duplicates mm-hmm it is not sorted random leap up with ...
Random Pick Index
random-pick-index
Given an integer array `nums` with possible **duplicates**, randomly output the index of a given `target` number. You can assume that the given target number must exist in the array. Implement the `Solution` class: * `Solution(int[] nums)` Initializes the object with the array `nums`. * `int pick(int target)` Pic...
null
Hash Table,Math,Reservoir Sampling,Randomized
Medium
382,894,912
201
all right let's talk about today's laconian challenge question so it's a it was end of number range or bitwise end of range of numbers we have a wrench end to end it's positive and so it's a bit large we've got the end that's a slightly larger than and we need to return the bitwise and of all the numbers in this range ...
Bitwise AND of Numbers Range
bitwise-and-of-numbers-range
Given two integers `left` and `right` that represent the range `[left, right]`, return _the bitwise AND of all numbers in this range, inclusive_. **Example 1:** **Input:** left = 5, right = 7 **Output:** 4 **Example 2:** **Input:** left = 0, right = 0 **Output:** 0 **Example 3:** **Input:** left = 1, right = 2147...
null
Bit Manipulation
Medium
null
1,222
hey what's up guys Nick white here I detect encoding stuff on twitch and YouTube check the description for all my information just explaining the code that goes into these algorithms data structures problem for people that don't understand them or just explaining the problems in general please like and subscribe to the...
Queens That Can Attack the King
remove-covered-intervals
On a **0-indexed** `8 x 8` chessboard, there can be multiple black queens ad one white king. You are given a 2D integer array `queens` where `queens[i] = [xQueeni, yQueeni]` represents the position of the `ith` black queen on the chessboard. You are also given an integer array `king` of length `2` where `king = [xKing...
How to check if an interval is covered by another? Compare each interval to all others and check if it is covered by any interval.
Array,Sorting
Medium
null
416
Hey everyone Spencer, I hope people are well, today I will solve the problem Partition Equals Upset, everything is fine, this question must be scary to see, on top of that you are thinking, DP question is, I don't know how it will happen, I will please tell you very lovingly that you Till now, whenever you watch my vid...
Partition Equal Subset Sum
partition-equal-subset-sum
Given an integer array `nums`, return `true` _if you can partition the array into two subsets such that the sum of the elements in both subsets is equal or_ `false` _otherwise_. **Example 1:** **Input:** nums = \[1,5,11,5\] **Output:** true **Explanation:** The array can be partitioned as \[1, 5, 5\] and \[11\]. **E...
null
Array,Dynamic Programming
Medium
698,2108,2135,2162
979
so today my problem is distribute points in a binary tree uh each turn of that binary tree will have a certain number associated with this and that number denotes how much coin that particular node has so my job is to return the number of moves that is required to make every node have exactly one coin and it is given t...
Distribute Coins in Binary Tree
di-string-match
You are given the `root` of a binary tree with `n` nodes where each `node` in the tree has `node.val` coins. There are `n` coins in total throughout the whole tree. In one move, we may choose two adjacent nodes and move one coin from one node to another. A move may be from parent to child, or from child to parent. Re...
null
Array,Math,Two Pointers,String,Greedy
Easy
null
275
Had happened Agri Badi Today's Question Advanced 221 Adhere To The Preview Ifre Have Exactly S Number Date Hai Vellu Christian And Equal To The Element Lu Ko A Super Example Another College Student Will Have Two Digits Number which number is 1251 element in total number to two hua tha som water will have no desire his ...
H-Index II
h-index-ii
Given an array of integers `citations` where `citations[i]` is the number of citations a researcher received for their `ith` paper and `citations` is sorted in **ascending order**, return _the researcher's h-index_. According to the [definition of h-index on Wikipedia](https://en.wikipedia.org/wiki/H-index): The h-ind...
Expected runtime complexity is in O(log n) and the input is sorted.
Array,Binary Search
Medium
274
374
so hey everyone today i am going to discuss the second question of the easy category under this dsa bootcamp so here the uh the question is guess number higher or lower the question says that we are playing a guess game the game is as follows i pick a number from one to end you have to guess which number i picked so it...
Guess Number Higher or Lower
guess-number-higher-or-lower
We are playing the Guess Game. The game is as follows: I pick a number from `1` to `n`. You have to guess which number I picked. Every time you guess wrong, I will tell you whether the number I picked is higher or lower than your guess. You call a pre-defined API `int guess(int num)`, which returns three possible re...
null
Binary Search,Interactive
Easy
278,375,658
1,481
hey everybody this is Larry this is day 16 of the Leo day challenge hit the like button hit the Subscribe Buton join me on Discord let me know what you uh what you think about this cont oh this man I am uh I mean you know I've said this like about a few thousand times now or at least a thousand times I guess CU my stre...
Least Number of Unique Integers after K Removals
students-with-invalid-departments
Given an array of integers `arr` and an integer `k`. Find the _least number of unique integers_ after removing **exactly** `k` elements**.** **Example 1:** **Input:** arr = \[5,5,4\], k = 1 **Output:** 1 **Explanation**: Remove the single 4, only 5 is left. **Example 2:** **Input:** arr = \[4,3,1,1,3,3,2\], k = 3 *...
null
Database
Easy
null
377
this is a classic dynamic programming problem where we're given a set of distinct integers and we want to find the total number of different ways that we can use the set of integers to add up to our Target number so in example one you can see that with the set of one two and three there's seven different ways that we c...
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
1,578
Hi gas welcome and welcome back to my channel so today our problem is minimum time you make the rope colorful so in this problem statement what have we given here live score and balloons are arranged here ek ro pe ok hai colors of balloons ek aapka Casting colors have been given, okay it has colors in it, the rectangle...
Minimum Time to Make Rope Colorful
apples-oranges
Alice has `n` balloons arranged on a rope. You are given a **0-indexed** string `colors` where `colors[i]` is the color of the `ith` balloon. Alice wants the rope to be **colorful**. She does not want **two consecutive balloons** to be of the same color, so she asks Bob for help. Bob can remove some balloons from the ...
null
Database
Medium
null
1,643
hey what's up guys this is chung here so let's take a look at this week's weekly contest problem number 1643 case smallest instructions so this problem you know it's a hard problem but it's kind of tricky because this one is more like a math problem rather than a regular like or either like a dp or like other problems ...
Kth Smallest Instructions
number-of-nodes-in-the-sub-tree-with-the-same-label
Bob is standing at cell `(0, 0)`, and he wants to reach `destination`: `(row, column)`. He can only travel **right** and **down**. You are going to help Bob by providing **instructions** for him to reach `destination`. The **instructions** are represented as a string, where each character is either: * `'H'`, meanin...
Start traversing the tree and each node should return a vector to its parent node. The vector should be of length 26 and have the count of all the labels in the sub-tree of this node.
Hash Table,Tree,Depth-First Search,Breadth-First Search,Counting
Medium
null
6
hey guys welcome to another leak code tutorial video in this video we're going to be covering leak code number six zigzag conversion so this is a medium leak code um and as always we're going to be going through the entire process from start to finish so we're going to be reading the question breaking it down um actual...
Zigzag Conversion
zigzag-conversion
The string `"PAYPALISHIRING "` is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N A P L S I I G Y I R And then read line by line: `"PAHNAPLSIIGYIR "` Write the code that will take a string and make this co...
null
String
Medium
null
1,979
Hello hello everyone so in this video write updates problem number 90 definitely comment device of problems and worst when invented the number zero number in nashik aaj tak latest comment device of two numbers in flu positive integer david number 100 index problem statement input device maximum and Minimum element shou...
Find Greatest Common Divisor of Array
maximum-number-of-people-that-can-be-caught-in-tag
Given an integer array `nums`, return _the **greatest common divisor** of the smallest number and largest number in_ `nums`. The **greatest common divisor** of two numbers is the largest positive integer that evenly divides both numbers. **Example 1:** **Input:** nums = \[2,5,6,9,10\] **Output:** 2 **Explanation:** ...
Try to use as much of the range of a person who is "it" as possible. Find the leftmost person who is "it" that has not caught anyone yet, and the leftmost person who is not "it" that has not been caught yet. If the person who is not "it" can be caught, pair them together and repeat the process. If the person who is not...
Array,Greedy
Medium
2191
1,954
hey everybody this is larry this is me going with q3 of the weekly contest 252 minimum garden perimeter to collect enough apples uh hit the like button hit the subscribe button join me on discord especially if you like these contests people go over the contest right after the contest so if y'all are looking for somebod...
Minimum Garden Perimeter to Collect Enough Apples
replace-all-digits-with-characters
In a garden represented as an infinite 2D grid, there is an apple tree planted at **every** integer coordinate. The apple tree planted at an integer coordinate `(i, j)` has `|i| + |j|` apples growing on it. You will buy an axis-aligned **square plot** of land that is centered at `(0, 0)`. Given an integer `neededAppl...
We just need to replace every even positioned character with the character s[i] positions ahead of the character preceding it Get the position of the preceeding character in alphabet then advance it s[i] positions and get the character at that position
String
Easy
878
118
what's up guys in this video we'll take a look at pascal's triangle problem difficulty level is easy so we're given number of rows and for that many rows we need to generate parcels triangle so obvious question what is pascal's triangle right let's go to the wikipedia let's see what pascal's triangle is so if we just l...
Pascal's Triangle
pascals-triangle
Given an integer `numRows`, return the first numRows of **Pascal's triangle**. In **Pascal's triangle**, each number is the sum of the two numbers directly above it as shown: **Example 1:** **Input:** numRows = 5 **Output:** \[\[1\],\[1,1\],\[1,2,1\],\[1,3,3,1\],\[1,4,6,4,1\]\] **Example 2:** **Input:** numRows = ...
null
Array,Dynamic Programming
Easy
119
54
all right what is up nerds programmers coders whatever you guys want to refer to yourself as today I'm going over spiral matrix I spent like a long time on this one yesterday I don't I just got stuck in the conundrums of it's actually not as hard as I made it out to be and just I don't know maybe I'm just an idiot but ...
Spiral Matrix
spiral-matrix
Given an `m x n` `matrix`, return _all elements of the_ `matrix` _in spiral order_. **Example 1:** **Input:** matrix = \[\[1,2,3\],\[4,5,6\],\[7,8,9\]\] **Output:** \[1,2,3,6,9,8,7,4,5\] **Example 2:** **Input:** matrix = \[\[1,2,3,4\],\[5,6,7,8\],\[9,10,11,12\]\] **Output:** \[1,2,3,4,8,12,11,10,9,5,6,7\] **Const...
Well for some problems, the best way really is to come up with some algorithms for simulation. Basically, you need to simulate what the problem asks us to do. We go boundary by boundary and move inwards. That is the essential operation. First row, last column, last row, first column and then we move inwards by 1 and th...
Array,Matrix,Simulation
Medium
59,921
2
sometimes when you come across a problem it feels super simple right but just because of the way it is written and described it becomes super confusing one such example is add two numbers on lead code it is a quite popular problem and ask in a lot of coding interviews and when you read it feels pretty straightforward y...
Add Two Numbers
add-two-numbers
You are given two **non-empty** linked lists representing two non-negative integers. The digits are stored in **reverse order**, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list. You may assume the two numbers do not contain any leading zero, except the number 0 ...
null
Linked List,Math,Recursion
Medium
43,67,371,415,445,1031,1774
253
hey what's up guys john here again so today as promised uh let's take a look at this like uh meeting room problem number 253 uh meeting rooms number two so you know on lead code there are like a series of different meeting room problems or you can call it interval problems right basically you're always given like a lis...
Meeting Rooms II
meeting-rooms-ii
Given an array of meeting time intervals `intervals` where `intervals[i] = [starti, endi]`, return _the minimum number of conference rooms required_. **Example 1:** **Input:** intervals = \[\[0,30\],\[5,10\],\[15,20\]\] **Output:** 2 **Example 2:** **Input:** intervals = \[\[7,10\],\[2,4\]\] **Output:** 1 **Constr...
Think about how we would approach this problem in a very simplistic way. We will allocate rooms to meetings that occur earlier in the day v/s the ones that occur later on, right? If you've figured out that we have to sort the meetings by their start time, the next thing to think about is how do we do the allocation? Th...
Array,Two Pointers,Greedy,Sorting,Heap (Priority Queue)
Medium
56,252,452,1184
387
hey and welcome today we will solve personal repeating character interview question which mostly asked by Bloomberg as less other companies like so we will explore a hashmap solution so without further Ado let's Dive In first example here as you can see there are few characters that repeated only once like l t c o and ...
First Unique Character in a String
first-unique-character-in-a-string
Given a string `s`, _find the first non-repeating character in it and return its index_. If it does not exist, return `-1`. **Example 1:** **Input:** s = "leetcode" **Output:** 0 **Example 2:** **Input:** s = "loveleetcode" **Output:** 2 **Example 3:** **Input:** s = "aabb" **Output:** -1 **Constraints:** * `...
null
Hash Table,String,Queue,Counting
Easy
451
70
hey guys welcome back to the channel in our previous video we solved this problem lead code 70 climbing stairs which we solved using the top down approach using a memorized recursive function okay but now let's start using the bottom up approach right here and just so we know we developed this out in our previous examp...
Climbing Stairs
climbing-stairs
You are climbing a staircase. It takes `n` steps to reach the top. Each time you can either climb `1` or `2` steps. In how many distinct ways can you climb to the top? **Example 1:** **Input:** n = 2 **Output:** 2 **Explanation:** There are two ways to climb to the top. 1. 1 step + 1 step 2. 2 steps **Example 2:** ...
To reach nth step, what could have been your previous steps? (Think about the step sizes)
Math,Dynamic Programming,Memoization
Easy
747,1013,1236
1,697
hello guys welcome to deep codes and in today's video we will discuss liquid question 1697 that says checking existence of edge length limited paths so guys this question is a very unique question and also interesting one so uh by going through this equation and writing the code you will learn a different use case of D...
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
1,732
hey guys welcome to the channel in today's video we're going to look at a lead code problem and the problem's name is find the highest altitude in this question we given a gain array which represents the net gain in altitude because there is a biker starts from a point0 with altitude equal to 0 so there are n + 1 point...
Find the Highest Altitude
minimum-one-bit-operations-to-make-integers-zero
There is a biker going on a road trip. The road trip consists of `n + 1` points at different altitudes. The biker starts his trip on point `0` with altitude equal `0`. You are given an integer array `gain` of length `n` where `gain[i]` is the **net gain in altitude** between points `i`​​​​​​ and `i + 1` for all (`0 <=...
The fastest way to convert n to zero is to remove all set bits starting from the leftmost one. Try some simple examples to learn the rule of how many steps are needed to remove one set bit. consider n=2^k case first, then solve for all n.
Dynamic Programming,Bit Manipulation,Memoization
Hard
2119
395
good evening millennials today we look at another lead code medium problem asked in the final rounds of some big interviews such as by dance and amazon so let's read the problem discuss various approaches and try to call the shortest code possible so it's the 3395th problem in the lead code website called longer substr...
Longest Substring with At Least K Repeating Characters
longest-substring-with-at-least-k-repeating-characters
Given a string `s` and an integer `k`, return _the length of the longest substring of_ `s` _such that the frequency of each character in this substring is greater than or equal to_ `k`. **Example 1:** **Input:** s = "aaabb ", k = 3 **Output:** 3 **Explanation:** The longest substring is "aaa ", as 'a' is repeated 3...
null
Hash Table,String,Divide and Conquer,Sliding Window
Medium
2140,2209
1,046
so hey guys welcome back to my channel and after a long this I had started and uh I am trying to continue this series because I bought the new penate because there were many difficulties to write the programs and means uh to explain through the pp so I bought the pen tablet so I will uh try uh to continue this series p...
Last Stone Weight
max-consecutive-ones-iii
You are given an array of integers `stones` where `stones[i]` is the weight of the `ith` stone. We are playing a game with the stones. On each turn, we choose the **heaviest two stones** and smash them together. Suppose the heaviest two stones have weights `x` and `y` with `x <= y`. The result of this smash is: * I...
One thing's for sure, we will only flip a zero if it extends an existing window of 1s. Otherwise, there's no point in doing it, right? Think Sliding Window! Since we know this problem can be solved using the sliding window construct, we might as well focus in that direction for hints. Basically, in a given window, we c...
Array,Binary Search,Sliding Window,Prefix Sum
Medium
340,424,485,487,2134
421
hi all welcome to learn code repeat so today we'll be looking at the day 16 problem of the september challenge so the problem is we have to find maximum xor of two numbers in an inter array so let's look into the problem statement so this is the problem statement which is given a non-empty array of numbers is given a n...
Maximum XOR of Two Numbers in an Array
maximum-xor-of-two-numbers-in-an-array
Given an integer array `nums`, return _the maximum result of_ `nums[i] XOR nums[j]`, where `0 <= i <= j < n`. **Example 1:** **Input:** nums = \[3,10,5,25,2,8\] **Output:** 28 **Explanation:** The maximum result is 5 XOR 25 = 28. **Example 2:** **Input:** nums = \[14,70,53,83,49,91,36,80,92,51,66,70\] **Output:** 1...
null
Array,Hash Table,Bit Manipulation,Trie
Medium
1826
1,944
hey everybody this is larry this will be going with q4 of the buy weekly contest 57 number of ruins for people in the queue so this one is a little bit tricky so um yeah so hit the like button hit the subscribe and join me on discord especially if you come here right after the contest uh don't the discord people are ve...
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
52
Hello Friends Today I Will Discuss The Problem Latest Thing She Has Been Walking Officer Important Problem Skin Allotment Reviews And Its Very Standard Tractor Key Problem Subject And College Sandwich This Problem List Ko Play List Ko *Wed And Subscribe Problem Placid For *Wed And Subscribe Problem Placid For *Wed And ...
N-Queens II
n-queens-ii
The **n-queens** puzzle is the problem of placing `n` queens on an `n x n` chessboard such that no two queens attack each other. Given an integer `n`, return _the number of distinct solutions to the **n-queens puzzle**_. **Example 1:** **Input:** n = 4 **Output:** 2 **Explanation:** There are two distinct solutions ...
null
Backtracking
Hard
51
129
hello guys um I want to solve with you lead code problem number 129 some route to leave numbers now I think this problem is a very good problem for someone who is maybe starting out with the binary trees or trees in general because it's very straightforward it's basically all about um tree traversal how do we Traverse ...
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
449
hey everybody this is larry this is day 9 of the october eco dairy challenge i hit the like button to subscribe and join me on discord uh my setup is a little bit different today let me know how that comes out uh we'll see okay let's go serialize and de-civilize bst for serialize and de-civilize bst for serialize and d...
Serialize and Deserialize BST
serialize-and-deserialize-bst
Serialization is 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 **binary search t...
null
String,Tree,Depth-First Search,Breadth-First Search,Design,Binary Search Tree,Binary Tree
Medium
297,652,765
231
hey everybody welcome back to another leak code problem 2 3 1 power of 2 this is an easy one given an integer n return true if it is a power of 2 otherwise it return false an integer n is a power of 2 if there exists an integer such that n is equal to 2 raised to power x n is equal to 2 raised to the power x yes so wha...
Power of Two
power-of-two
Given an integer `n`, return _`true` if it is a power of two. Otherwise, return `false`_. An integer `n` is a power of two, if there exists an integer `x` such that `n == 2x`. **Example 1:** **Input:** n = 1 **Output:** true **Explanation:** 20 = 1 **Example 2:** **Input:** n = 16 **Output:** true **Explanation:**...
null
Math,Bit Manipulation,Recursion
Easy
191,326,342
238
Hello friends, welcome to the channel, you are doing 90 days software engineering prep with me, this is lead code 75, question number seven, lead code 238, product of array, accept yourself, see what is the question, an array has been given to you, return a new array. What do you have to return at each spot? What do yo...
Product of Array Except Self
product-of-array-except-self
Given an integer array `nums`, return _an array_ `answer` _such that_ `answer[i]` _is equal to the product of all the elements of_ `nums` _except_ `nums[i]`. The product of any prefix or suffix of `nums` is **guaranteed** to fit in a **32-bit** integer. You must write an algorithm that runs in `O(n)` time and without...
null
Array,Prefix Sum
Medium
42,152,265,2267
473
hi guys welcome to tech geek so today we are back with a really good challenge problem that's match62 square that's elite for medium 473 question and mostly asked and great companies like fang and not just this many product based companies go up with questions like this and basically this question that you will see it'...
Matchsticks to Square
matchsticks-to-square
You are given an integer array `matchsticks` where `matchsticks[i]` is the length of the `ith` matchstick. You want to use **all the matchsticks** to make one square. You **should not break** any stick, but you can link them up, and each matchstick must be used **exactly one time**. Return `true` if you can make this ...
Treat the matchsticks as an array. Can we split the array into 4 equal halves? Every matchstick can belong to either of the 4 sides. We don't know which one. Maybe try out all options! For every matchstick, we have to try out each of the 4 options i.e. which side it can belong to. We can make use of recursion for this....
Array,Dynamic Programming,Backtracking,Bit Manipulation,Bitmask
Medium
null