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
216
Raj Welcome back to my channel Laga luck making person delivery question video such mistakes messenger this suggestion or gold solve question number 2016 combination consent off beat increase note subscribe The Channel Please subscribe and related videos problem got well respect yes but Like this you have not appeared ...
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
1,820
hello everyone let's take a look at the code 1820 maximum number of accepted invitations and it's a lot question let's take a look at this problem first the problem is there are m employees and young angers in class attending an upcoming party and we are given a multiply an integer matrix grid where grid ij is either z...
Maximum Number of Accepted Invitations
number-of-ways-to-reconstruct-a-tree
There are `m` boys and `n` girls in a class attending an upcoming party. You are given an `m x n` integer matrix `grid`, where `grid[i][j]` equals `0` or `1`. If `grid[i][j] == 1`, then that means the `ith` boy can invite the `jth` girl to the party. A boy can invite at most **one girl**, and a girl can accept at most...
Think inductively. The first step is to get the root. Obviously, the root should be in pairs with all the nodes. If there isn't exactly one such node, then there are 0 ways. The number of pairs involving a node must be less than or equal to that number of its parent. Actually, if it's equal, then there is not exactly 1...
Tree,Graph,Topological Sort
Hard
2306
505
hey what's up guys uh this is strong here again so let's take a look at lead code 505 the maze number two uh i believe you guys must have already seen the maze number one right so this one is pretty similar but actually it's not that similar the description is the same but you know the output is different so this time ...
The Maze II
the-maze-ii
There is a ball in a `maze` with empty spaces (represented as `0`) and walls (represented as `1`). The ball can go through the empty spaces by rolling **up, down, left or right**, but it won't stop rolling until hitting a wall. When the ball stops, it could choose the next direction. Given the `m x n` `maze`, the ball...
null
Depth-First Search,Breadth-First Search,Graph,Heap (Priority Queue),Shortest Path
Medium
490,499
127
what's up everyone today we're going to go over word letter first we'll look at the input and the output then we'll look at the diagram to understand the approach now for the code i'll be linking it down below in the description and finally we'll go over the complexities the input is going to be two words and a list of...
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
54
hey what's up guys I like white here I do tech and coding stuff on twitch and YouTube I do all the lead code and a current solutions playlist for both of them so check this out I just do all the problems so this one's called spiral matrix I wonder if any of you guys have heard of it before it's a medium problem trying ...
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
153
so welcome back to a new video and today we're going to do question 153 find minimum and rotates 300 Ras so pose an array of length n it's just sorted in ascending order is rotated between one and N times for example the right nums of one through seven might become this so we can see that these two arrays are the same ...
Find Minimum in Rotated Sorted Array
find-minimum-in-rotated-sorted-array
Suppose an array of length `n` sorted in ascending order is **rotated** between `1` and `n` times. For example, the array `nums = [0,1,2,4,5,6,7]` might become: * `[4,5,6,7,0,1,2]` if it was rotated `4` times. * `[0,1,2,4,5,6,7]` if it was rotated `7` times. Notice that **rotating** an array `[a[0], a[1], a[2], ....
Array was originally in ascending order. Now that the array is rotated, there would be a point in the array where there is a small deflection from the increasing sequence. eg. The array would be something like [4, 5, 6, 7, 0, 1, 2]. You can divide the search space into two and see which direction to go. Can you think ...
Array,Binary Search
Medium
33,154
337
hey everyone welcome back and let's write some more neat code today so today let's solve house robber three i know i solved house robber one before i skipped house robber two for now i might come back to it at some point but i really like house robber three so i'm gonna solve it today so we are given so we're given a b...
House Robber III
house-robber-iii
The thief has found himself a new place for his thievery again. There is only one entrance to this area, called `root`. Besides the `root`, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will automatically contact the police if ...
null
Dynamic Programming,Tree,Depth-First Search,Binary Tree
Medium
198,213
35
Hello friends welcome back to the PM sof Solutions in this session basically we are going to solve lead code problem number 35 search insert position so let's move to the dashboard and let's try to understand the problem statement basically the statement says that given a sorted array of distinct integers and a Target ...
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
76
Hello friends, welcome to the new video, question number 76 is a late code minimum window something hot level question, which category will the question be in, then it is written here that Vegetable 2.1 String and Vegetable 2.1 String and Vegetable 2.1 String and Sliding Window question is this question, you people wil...
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
1,094
Hello Hi Everyone Welcome To My Channel It's All The Problem Car Pulling So You Are Driving Option 28 Capacity MP Seats In Delhi Available For Passengers Dual Only Drives It Is It Can Not Turn Around And Drive Back So Give Only Strips Where Tips And Icon Are In Things Starting locations from first number of centers and...
Car Pooling
matrix-cells-in-distance-order
There is a car with `capacity` empty seats. The vehicle only drives east (i.e., it cannot turn around and drive west). You are given the integer `capacity` and an array `trips` where `trips[i] = [numPassengersi, fromi, toi]` indicates that the `ith` trip has `numPassengersi` passengers and the locations to pick them u...
null
Array,Math,Geometry,Sorting,Matrix
Easy
2304
1,582
hello hi guys good morning subji I hope that you guys are doing good this special positions in a binary Matrix now although it's an easy problem and I was thinking not to take this problem but the concept basically the followup which we're going to see is exactly what we saw in this hard question a few months back maxi...
Special Positions in a Binary Matrix
design-browser-history
Given an `m x n` binary matrix `mat`, return _the number of special positions in_ `mat`_._ A position `(i, j)` is called **special** if `mat[i][j] == 1` and all other elements in row `i` and column `j` are `0` (rows and columns are **0-indexed**). **Example 1:** **Input:** mat = \[\[1,0,0\],\[0,0,1\],\[1,0,0\]\] **O...
Use two stack one for back history and one for forward history and simulate the functions. Can you do faster by using different data structure ?
Array,Linked List,Stack,Design,Doubly-Linked List,Data Stream
Medium
null
784
foreign letter case permutation and it's uh simple you can say simple backtracking problem you're given a string s and we have to transform every letter individually to be lowercase or uppercase to create another string we return a list of possible strings we could create and of all possible streams that we can create ...
Letter Case Permutation
insert-into-a-binary-search-tree
Given a string `s`, you can transform every letter individually to be lowercase or uppercase to create another string. Return _a list of all possible strings we could create_. Return the output in **any order**. **Example 1:** **Input:** s = "a1b2 " **Output:** \[ "a1b2 ", "a1B2 ", "A1b2 ", "A1B2 "\] **Example 2:*...
null
Tree,Binary Search Tree,Binary Tree
Medium
783
172
welcome to the coding interview problem factorial drilling zeros you are given an integer n return the number of trillion zeroed in n factorial the constraint to this problem is that you have to solve this problem in logarithmic time complexity how we can solve this problem first let me ask you a question in what situa...
Factorial Trailing Zeroes
factorial-trailing-zeroes
Given an integer `n`, return _the number of trailing zeroes in_ `n!`. Note that `n! = n * (n - 1) * (n - 2) * ... * 3 * 2 * 1`. **Example 1:** **Input:** n = 3 **Output:** 0 **Explanation:** 3! = 6, no trailing zero. **Example 2:** **Input:** n = 5 **Output:** 1 **Explanation:** 5! = 120, one trailing zero. **Exa...
null
Math
Medium
233,809,2222
1,588
Hello Hi Guys So Today Will Be Going To Discuss This Problem Far From Its Good Bye Weekly Contents Problem Name Sum Of All Subs Problem Kuch Nahin Hai Means And Us Me Jitan Bhi Na Nikal Like Hum Subscribe To Us 143 Like Share And Subscribe If you can, then that balance is spent all morning 1234 12345 like subscribe Vid...
Sum of All Odd Length Subarrays
sum-of-all-odd-length-subarrays
Given an array of positive integers `arr`, return _the sum of all possible **odd-length subarrays** of_ `arr`. A **subarray** is a contiguous subsequence of the array. **Example 1:** **Input:** arr = \[1,4,2,5,3\] **Output:** 58 **Explanation:** The odd-length subarrays of arr and their sums are: \[1\] = 1 \[4\] = 4...
null
null
Easy
null
95
hey guys let's take a look at number 95 unique binary search tree so trees - unique binary search tree so trees - unique binary search tree so trees - we're given an integer please generate all structurally unique bsts well actually this is a follow-up of problem actually this is a follow-up of problem actually this is...
Unique Binary Search Trees II
unique-binary-search-trees-ii
Given an integer `n`, return _all the structurally unique **BST'**s (binary search trees), which has exactly_ `n` _nodes of unique values from_ `1` _to_ `n`. Return the answer in **any order**. **Example 1:** **Input:** n = 3 **Output:** \[\[1,null,2,null,3\],\[1,null,3,2\],\[2,1,3\],\[3,1,null,null,2\],\[3,2,null,1\...
null
Dynamic Programming,Backtracking,Tree,Binary Search Tree,Binary Tree
Medium
96,241
977
Hello guys welcome change sid question of cotton in this question Thursday must subscribe a video subscribe problem subscribe to Shri Ram Complexity of this College of Law and World Peace Complexity 2017 Rajdhani Express Middle School Kids submit button Vinod given link problem subscribe Video then subscribe to subscri...
Squares of a Sorted Array
distinct-subsequences-ii
Given an integer array `nums` sorted in **non-decreasing** order, return _an array of **the squares of each number** sorted in non-decreasing order_. **Example 1:** **Input:** nums = \[-4,-1,0,3,10\] **Output:** \[0,1,9,16,100\] **Explanation:** After squaring, the array becomes \[16,1,0,9,100\]. After sorting, it be...
null
String,Dynamic Programming
Hard
2115
89
hello so today we are doing this problem called gray code as practice for the video explanation of a gray code that I put up just before this it would be very useful to watch that one first and then watch this one after it and so this problem is a direct application of that and so it just says that definition of the gr...
Gray Code
gray-code
An **n-bit gray code sequence** is a sequence of `2n` integers where: * Every integer is in the **inclusive** range `[0, 2n - 1]`, * The first integer is `0`, * An integer appears **no more than once** in the sequence, * The binary representation of every pair of **adjacent** integers differs by **exactly one ...
null
Math,Backtracking,Bit Manipulation
Medium
717
60
today we will see one fun problem it's called permutation sequence so we know that if we have n digits we can indistinct digits we can arrange them in n factorial ways so this in fact comes from that only so if we have three digits let's say blue denotes one red is two and green is three so we can arrange them in three...
Permutation Sequence
permutation-sequence
The set `[1, 2, 3, ..., n]` contains a total of `n!` unique permutations. By listing and labeling all of the permutations in order, we get the following sequence for `n = 3`: 1. `"123 "` 2. `"132 "` 3. `"213 "` 4. `"231 "` 5. `"312 "` 6. `"321 "` Given `n` and `k`, return the `kth` permutation sequence. **Exa...
null
Math,Recursion
Hard
31,46
261
hey guys it's offie1 here and today we're going to be solving graph Valley tree in this problem we're given n number of nodes that are labeled from 0 to n minus one so we're always going to be starting from node 0 and I think that's important to know and we're also giving a list of undirected edges and they want us to ...
Graph Valid Tree
graph-valid-tree
You have a graph of `n` nodes labeled from `0` to `n - 1`. You are given an integer n and a list of `edges` where `edges[i] = [ai, bi]` indicates that there is an undirected edge between nodes `ai` and `bi` in the graph. Return `true` _if the edges of the given graph make up a valid tree, and_ `false` _otherwise_. **...
Given n = 5 and edges = [[0, 1], [1, 2], [3, 4]], what should your return? Is this case a valid tree? According to the definition of tree on Wikipedia: “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.”
Depth-First Search,Breadth-First Search,Union Find,Graph
Medium
207,323,871
791
um hello so today we are going to do this problem which is part of Le code da challenge custom sort string so basically we get two strings we get order and we get string s and all characters in order are unique um and they were sorted in a custom order and what we want is to sort s in the same order as the string order...
Custom Sort String
split-bst
You are given two strings order and s. All the characters of `order` are **unique** and were sorted in some custom order previously. Permute the characters of `s` so that they match the order that `order` was sorted. More specifically, if a character `x` occurs before a character `y` in `order`, then `x` should occur ...
Use recursion. If root.val <= V, you split root.right into two halves, then join it's left half back on root.right.
Tree,Binary Search Tree,Recursion,Binary Tree
Medium
450
498
Loot Time Se Absolutely Challenge Squashed Traversal Difficult Question Remedy Christmas Who Made Clear Hai 100 Subscribe Now To Receive New Updates Element Amazing Click Subscribe Button And Click Subscribe Button On This Side That Sudhir Gautam Se Is Ayub Returned To Meet Again Have And Using Department Research Now ...
Diagonal Traverse
diagonal-traverse
Given an `m x n` matrix `mat`, return _an array of all the elements of the array in a diagonal order_. **Example 1:** **Input:** mat = \[\[1,2,3\],\[4,5,6\],\[7,8,9\]\] **Output:** \[1,2,4,7,5,3,6,8,9\] **Example 2:** **Input:** mat = \[\[1,2\],\[3,4\]\] **Output:** \[1,2,3,4\] **Constraints:** * `m == mat.leng...
null
Array,Matrix,Simulation
Medium
2197
1,769
hello everybody today we will focus on solving the lead code problem 1769 minimum number of operations to move all balls to each box and you can read the question from here but i try to explain that question with the illustration i made some drawing here we are given binary string the length of the string give us the n...
Minimum Number of Operations to Move All Balls to Each Box
get-maximum-in-generated-array
You have `n` boxes. You are given a binary string `boxes` of length `n`, where `boxes[i]` is `'0'` if the `ith` box is **empty**, and `'1'` if it contains **one** ball. In one operation, you can move **one** ball from a box to an adjacent box. Box `i` is adjacent to box `j` if `abs(i - j) == 1`. Note that after doing ...
Try generating the array. Make sure not to fall in the base case of 0.
Array,Dynamic Programming,Simulation
Easy
null
1,318
I'm back with another problem from lead curve the number thirteen eighteen minimum flips to make or B equal to C so we are given with three numbers a and B a B and C so the problem is a are B equal to C so that is what we need to carry out and we need to identify how many bits that we need to change so essentially let'...
Minimum Flips to Make a OR b Equal to c
tournament-winners
Given 3 positives numbers `a`, `b` and `c`. Return the minimum flips required in some bits of `a` and `b` to make ( `a` OR `b` == `c` ). (bitwise OR operation). Flip operation consists of change **any** single bit 1 to 0 or change the bit 0 to 1 in their binary representation. **Example 1:** **Input:** a = 2, b = 6...
null
Database
Hard
null
133
hi friends welcome to today's video on our graph series I am chimney a software engineer at Microsoft Dublin Ireland today we'll be solving another medium question from leadco titled clone graph I'll start by reading the question pointing out exactly what the question requires from us I would then explain my proposed s...
Clone Graph
clone-graph
Given a reference of a node in a **[connected](https://en.wikipedia.org/wiki/Connectivity_(graph_theory)#Connected_graph)** undirected graph. Return a [**deep copy**](https://en.wikipedia.org/wiki/Object_copying#Deep_copy) (clone) of the graph. Each node in the graph contains a value (`int`) and a list (`List[Node]`)...
null
Hash Table,Depth-First Search,Breadth-First Search,Graph
Medium
138,1624,1634
390
cool 29 League in amination game there is a list of sordid integers from 1 to n starting from left to right we moved the first number and every other number until you reach the end after this we please repeat the previous step again but this time from right to left we move the rightmost number and every other number fr...
Elimination Game
elimination-game
You have a list `arr` of all integers in the range `[1, n]` sorted in a strictly increasing order. Apply the following algorithm on `arr`: * Starting from left to right, remove the first number and every other number afterward until you reach the end of the list. * Repeat the previous step again, but this time fro...
null
Math
Medium
null
1,802
hello guys welcome back to my YouTube channel and this is day 9 of June delete code Challenge and our today's question is a maximum value at a given index and a bounded array so let me explain you the problem statement first uh so uh you are given three positive enter integers and index and maximum uh you want to const...
Maximum Value at a Given Index in a Bounded Array
number-of-students-unable-to-eat-lunch
You are given three positive integers: `n`, `index`, and `maxSum`. You want to construct an array `nums` (**0-indexed**) that satisfies the following conditions: * `nums.length == n` * `nums[i]` is a **positive** integer where `0 <= i < n`. * `abs(nums[i] - nums[i+1]) <= 1` where `0 <= i < n-1`. * The sum of a...
Simulate the given in the statement Calculate those who will eat instead of those who will not.
Array,Stack,Queue,Simulation
Easy
2195
1,578
Hello hello everyone welcome to my channel its all cheat code problem minimum relation cost to is repeating letters for giving his fears and worries of increased cost of you its cost auditing also character of india has written a minimum of relations dare not do it letter next Two Years I Noticed That You Will Delivery...
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,290
Hello Hi Everyone Welcome To My Channel Today Jab Bigg Boss The November Recording Challenge And Problems Convert Binary Number In English To Interest In This Problem Governor Bane Representation Of Number Wise Notes Of December 19 201 Subscribe Representation Of Decimal Number Of This And 1000 Number Into Decimal Subs...
Convert Binary Number in a Linked List to Integer
make-array-strictly-increasing
Given `head` which is a reference node to a singly-linked list. The value of each node in the linked list is either `0` or `1`. The linked list holds the binary representation of a number. Return the _decimal value_ of the number in the linked list. The **most significant bit** is at the head of the linked list. **E...
Use dynamic programming. The state would be the index in arr1 and the index of the previous element in arr2 after sorting it and removing duplicates.
Array,Binary Search,Dynamic Programming
Hard
null
274
Hello Guys Welcome Back To Decades And This Video Will See The Question Tax Problem Wishes From List Code 11:00 Of Problem Wishes From List Code 11:00 Of Problem Wishes From List Code 11:00 Of The Great Challenge So Let's Know Problem Statement In This Problem Veer Website This Negative Energy Resources To Function To ...
H-Index
h-index
Given an array of integers `citations` where `citations[i]` is the number of citations a researcher received for their `ith` paper, return _the researcher's h-index_. According to the [definition of h-index on Wikipedia](https://en.wikipedia.org/wiki/H-index): The h-index is defined as the maximum value of `h` such th...
An easy approach is to sort the array first. What are the possible values of h-index? A faster approach is to use extra space.
Array,Sorting,Counting Sort
Medium
275
1,981
hey everybody this is larry this is me going with q2 of the weekly contest 255 minimize the difference between target and chosen elements hit the like button hit the subscribe button join me on discord especially if you came here right after the contest because then we can talk about this thing and people do talk about...
Minimize the Difference Between Target and Chosen Elements
maximum-transaction-each-day
You are given an `m x n` integer matrix `mat` and an integer `target`. Choose one integer from **each row** in the matrix such that the **absolute difference** between `target` and the **sum** of the chosen elements is **minimized**. Return _the **minimum absolute difference**_. The **absolute difference** between t...
null
Database
Medium
null
230
You guys don't know about Loot or about your suji so friend this is the platform which repairs you old track if you are a working professional or you are a student here but what do you mean these days there is a lot of There are so many hot websites in one movie that you are afraid of losing a job. The cheese seller sa...
Kth Smallest Element in a BST
kth-smallest-element-in-a-bst
Given the `root` of a binary search tree, and an integer `k`, return _the_ `kth` _smallest value (**1-indexed**) of all the values of the nodes in the tree_. **Example 1:** **Input:** root = \[3,1,4,null,2\], k = 1 **Output:** 1 **Example 2:** **Input:** root = \[5,3,6,2,4,null,null,1\], k = 3 **Output:** 3 **Cons...
Try to utilize the property of a BST. Try in-order traversal. (Credits to @chan13) What if you could modify the BST node's structure? The optimal runtime complexity is O(height of BST).
Tree,Depth-First Search,Binary Search Tree,Binary Tree
Medium
94,671
1,095
hello everyone welcome to this LOD daily where we are going to go through find in Mountain array which is a problem where you receive as input an array of integer and a Target you're supposed to find the first occurrence of the Target in the mountain array so uh in this problem we have a couple of conent the first is t...
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
922
hello welcome to the channel i'm here to do my 100 legal challenge today we have lit code 922 sort away by parity 2 so given an array a of non-negative 2 so given an array a of non-negative 2 so given an array a of non-negative integers half of them are odd and the half of them are even sort the array so that where the...
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,359
Loot to control valid point delivery obscene means you are appointed then it means 230 delivery will be tied to-do list like disgusting 2.23 2.23 2.23 question on drum logic under is yes to very simple subscribe ko tum and this song MP3 subscribe my channel subscribe no If done then you can subscribe this is your minus...
Count All Valid Pickup and Delivery Options
circular-permutation-in-binary-representation
Given `n` orders, each order consist in pickup and delivery services. Count all valid pickup/delivery possible sequences such that delivery(i) is always after of pickup(i). Since the answer may be too large, return it modulo 10^9 + 7. **Example 1:** **Input:** n = 1 **Output:** 1 **Explanation:** Unique order (P1, ...
Use gray code to generate a n-bit sequence. Rotate the sequence such that its first element is start.
Math,Backtracking,Bit Manipulation
Medium
null
1,043
hey everyone today we'll be solving lead code 1043 partition array for maximum sum it's a very important question and has been ask in Amazon Adobe and Facebook let's have a look on the problem statement in this problem we are given an integer array a r partition the array into sub arrays of length at most K okay after ...
Partition Array for Maximum Sum
grid-illumination
Given an integer array `arr`, partition the array into (contiguous) subarrays of length **at most** `k`. After partitioning, each subarray has their values changed to become the maximum value of that subarray. Return _the largest sum of the given array after partitioning. Test cases are generated so that the answer fi...
null
Array,Hash Table
Hard
51
78
hello welcome to my channel and today we have leeco 78 subsets so given an integer array numbers of unique elements return all possible subsets and the solution set must not contain duplicate subset so we turn the solution in any order so now example one two three we have all the combination uh in this case style is ze...
Subsets
subsets
Given an integer array `nums` of **unique** elements, return _all possible_ _subsets_ _(the power set)_. The solution set **must not** contain duplicate subsets. Return the solution in **any order**. **Example 1:** **Input:** nums = \[1,2,3\] **Output:** \[\[\],\[1\],\[2\],\[1,2\],\[3\],\[1,3\],\[2,3\],\[1,2,3\]\] ...
null
Array,Backtracking,Bit Manipulation
Medium
90,320,800,2109,2170
1,845
hello everyone and welcome to yet another daily challenge from lead code so this challenge is set reservation manager it says to design a system that manages the reservation state of N seats that are numbered from 1 to n implement the seat manager class a seat manager Constructor seat manager initializes a seat manager...
Seat Reservation Manager
largest-submatrix-with-rearrangements
Design a system that manages the reservation state of `n` seats that are numbered from `1` to `n`. Implement the `SeatManager` class: * `SeatManager(int n)` Initializes a `SeatManager` object that will manage `n` seats numbered from `1` to `n`. All seats are initially available. * `int reserve()` Fetches the **sm...
For each column, find the number of consecutive ones ending at each position. For each row, sort the cumulative ones in non-increasing order and "fit" the largest submatrix.
Array,Greedy,Sorting,Matrix
Medium
695
472
hey guys in this video i'm going to walk through is the code number 472 concatenated words so we are given an array of strings uh words without duplicates and we need to return all the concatenate verb in the given list of words so a concatenated word is defined as a string that is comprised entirely at least of two sh...
Concatenated Words
concatenated-words
Given an array of strings `words` (**without duplicates**), return _all the **concatenated words** in the given list of_ `words`. A **concatenated word** is defined as a string that is comprised entirely of at least two shorter words (not necesssarily distinct) in the given array. **Example 1:** **Input:** words = \...
null
Array,String,Dynamic Programming,Depth-First Search,Trie
Hard
140
7
okay we should what's up guys Nick here we're doing some moral eco problems too if you don't know I do live coding and tech stuff on twitch and YouTube so check that out in the description we're doing number seven reverse integer we're gonna be doing the Java implementation and I'm gonna explain it to you so give it a ...
Reverse Integer
reverse-integer
Given a signed 32-bit integer `x`, return `x` _with its digits reversed_. If reversing `x` causes the value to go outside the signed 32-bit integer range `[-231, 231 - 1]`, then return `0`. **Assume the environment does not allow you to store 64-bit integers (signed or unsigned).** **Example 1:** **Input:** x = 123 ...
null
Math
Medium
8,190,2238
952
cool 9:52 largest component size by cool 9:52 largest component size by cool 9:52 largest component size by common factor come in a non empty array of unique positive integers a consider the following graph to a length nodes and nodes labeled is observed to a sub n minus 1 there is an edge from a sub I and a sub J if a...
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
199
welcome to february's lego challenge today's problem is binary tree right side view given a binary tree imagine yourself standing on the right side of it return the values of the nodes you can see ordered from the top to the bottom so here with this example we can see the answer should be 1 3 4 because these nodes are ...
Binary Tree Right Side View
binary-tree-right-side-view
Given the `root` of a binary tree, imagine yourself standing on the **right side** of it, return _the values of the nodes you can see ordered from top to bottom_. **Example 1:** **Input:** root = \[1,2,3,null,5,null,4\] **Output:** \[1,3,4\] **Example 2:** **Input:** root = \[1,null,3\] **Output:** \[1,3\] **Examp...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Medium
116,545
1,854
all right so this question is maximum population so you're giving a 2d array logs and then you want to okay logs I is going be representing birth and death and then uh you want to make uh make sure what is the maximum population for the current year it has to be a year right so um here we go so um for example one you k...
Maximum Population Year
maximum-population-year
You are given a 2D integer array `logs` where each `logs[i] = [birthi, deathi]` indicates the birth and death years of the `ith` person. The **population** of some year `x` is the number of people alive during that year. The `ith` person is counted in year `x`'s population if `x` is in the **inclusive** range `[birthi...
null
null
Easy
null
846
hey what's up guys knee right here I do technically stuff on twitch and YouTube solving all the way code hankering problems explaining the code cuz people don't understand the algorithms that's fine this is hand of straights 846 medium problem please like and subscribe so the channel grows thank you it helps more than ...
Hand of Straights
hand-of-straights
Alice has some number of cards and she wants to rearrange the cards into groups so that each group is of size `groupSize`, and consists of `groupSize` consecutive cards. Given an integer array `hand` where `hand[i]` is the value written on the `ith` card and an integer `groupSize`, return `true` if she can rearrange t...
null
null
Medium
null
237
hello friends welcome back to my channel hope you are doing great if you haven't subscribed to my channel yet please go ahead and subscribe I have created bunch of playlists to cover various categories of problems such as dynamic programming breadth-first search dynamic programming breadth-first search dynamic programm...
Delete Node in a Linked List
delete-node-in-a-linked-list
There is a singly-linked list `head` and we want to delete a node `node` in it. You are given the node to be deleted `node`. You will **not be given access** to the first node of `head`. All the values of the linked list are **unique**, and it is guaranteed that the given node `node` is not the last node in the linke...
null
Linked List
Easy
203
1,047
welcome back everyone we're going to be solving leak code 1047 remove all adjacent duplicates in a string so we're given a string s consisting of lowercase English letters a duplicate removal consists of choosing two adjacent and equal letters and removing them we repeatedly make a duplicate removals on S until we no l...
Remove All Adjacent Duplicates In String
maximize-sum-of-array-after-k-negations
You are given a string `s` consisting of lowercase English letters. A **duplicate removal** consists of choosing two **adjacent** and **equal** letters and removing them. We repeatedly make **duplicate removals** on `s` until we no longer can. Return _the final string after all such duplicate removals have been made_...
null
Array,Greedy,Sorting
Easy
2204
1,650
hey guys so in this video we're gonna discuss Lee code 1650 find it find the lowest common ancestors of a binary tree so in this problem we're going to be given the two nodes in a binary tree p and Q and the return their lowest common ancestor so for example in this these three now this three and we have two nodes five...
Lowest Common Ancestor of a Binary Tree III
find-root-of-n-ary-tree
Given two nodes of a binary tree `p` and `q`, return _their lowest common ancestor (LCA)_. Each node will have a reference to its parent node. The definition for `Node` is below: class Node { public int val; public Node left; public Node right; public Node parent; } According to the **[definition of ...
Node with indegree 0 is the root
Hash Table,Bit Manipulation,Tree,Depth-First Search
Medium
1655
131
Hello Hi Everyone Welcome To My Channel It's All The Problem Calendars Party Sanjeevani Stringers Patient Added Every Service Revolver Partitions On Part In ROM And Written All Possible Param Partitioning Of Its Parents Can Visit For Same From The Backward And Forward To Example1 Wear Dresses Problem And Eid Party 100 ...
Palindrome Partitioning
palindrome-partitioning
Given a string `s`, partition `s` such that every substring of the partition is a **palindrome**. Return _all possible palindrome partitioning of_ `s`. **Example 1:** **Input:** s = "aab" **Output:** \[\["a","a","b"\],\["aa","b"\]\] **Example 2:** **Input:** s = "a" **Output:** \[\["a"\]\] **Constraints:** * `1...
null
String,Dynamic Programming,Backtracking
Medium
132,1871
841
hey what's up guys it's Nick white here I do tech and coding stuff on twitch and YouTube and I do all the Lea code problems and I got a ton of them up on my YouTube so if you want these explained or if you have other problems you're struggling with just go check those out probably got it in there by now so this one's c...
Keys and Rooms
shortest-distance-to-a-character
There are `n` rooms labeled from `0` to `n - 1` and all the rooms are locked except for room `0`. Your goal is to visit all the rooms. However, you cannot enter a locked room without having its key. When you visit a room, you may find a set of **distinct keys** in it. Each key has a number on it, denoting which room i...
null
Array,Two Pointers,String
Easy
null
119
hi guys I Amit in this video we shall see another problem on Le pascals triangle part two so given an integer row index written the row index row of the pascals triangle so in the Pascal triangle each number is a sum of two numbers directly above it so they have given zero indexed row here and we have to write the retu...
Pascal's Triangle II
pascals-triangle-ii
Given an integer `rowIndex`, return the `rowIndexth` (**0-indexed**) row of the **Pascal's triangle**. In **Pascal's triangle**, each number is the sum of the two numbers directly above it as shown: **Example 1:** **Input:** rowIndex = 3 **Output:** \[1,3,3,1\] **Example 2:** **Input:** rowIndex = 0 **Output:** \[...
null
Array,Dynamic Programming
Easy
118,2324
1,961
Hello Everyone Welcome To Tips So N Subscribe Like and Subscribe Must Subscribe Problem Statement Festival Two in One Drop of Things That is the Giver Subscribe and Subscribe The First World Positive Life Your Knowledge Bank Words Start Length 100 Office Part Subscribe Example Sua This Example Watering Give Impetus Sub...
Check If String Is a Prefix of Array
maximum-ice-cream-bars
Given a string `s` and an array of strings `words`, determine whether `s` is a **prefix string** of `words`. A string `s` is a **prefix string** of `words` if `s` can be made by concatenating the first `k` strings in `words` for some **positive** `k` no larger than `words.length`. Return `true` _if_ `s` _is a **prefi...
It is always optimal to buy the least expensive ice cream bar first. Sort the prices so that the cheapest ice cream bar comes first.
Array,Greedy,Sorting
Medium
null
30
guys let's take a look at number 30 substrate with concatenation this all words so we're given a strain like this and a list of words are all in the same name in the same meant okay so find all study indices of substrate in s that is a continuation of each word in a words exactly at once and then without any intervene ...
Substring with Concatenation of All Words
substring-with-concatenation-of-all-words
You are given a string `s` and an array of strings `words`. All the strings of `words` are of **the same length**. A **concatenated substring** in `s` is a substring that contains all the strings of any permutation of `words` concatenated. * For example, if `words = [ "ab ", "cd ", "ef "]`, then `"abcdef "`, `"abef...
null
Hash Table,String,Sliding Window
Hard
76
807
what's up guys Nick white here doing some more leak code might as well right now please join the discourse for me on patreon if you can really appreciate that spend a lot of time on these and yeah let's get into it max increase to keep city skyline medium level difficulty some dislikes will give it a like you're given ...
Max Increase to Keep City Skyline
custom-sort-string
There is a city composed of `n x n` blocks, where each block contains a single building shaped like a vertical square prism. You are given a **0-indexed** `n x n` integer matrix `grid` where `grid[r][c]` represents the **height** of the building located in the block at row `r` and column `c`. A city's **skyline** is t...
null
Hash Table,String,Sorting
Medium
null
1,996
hello friends uh welcome to my channel let's have a look at problem 1996 the number of weak characters in the game so in this video we're going to share a solution based on monotonic stack so first i'll read through the statement of the problem to digest the requirements of the problem then we will look at the simple a...
The Number of Weak Characters in the Game
number-of-ways-to-rearrange-sticks-with-k-sticks-visible
You are playing a game that contains multiple characters, and each of the characters has **two** main properties: **attack** and **defense**. You are given a 2D integer array `properties` where `properties[i] = [attacki, defensei]` represents the properties of the `ith` character in the game. A character is said to be...
Is there a way to build the solution from a base case? How many ways are there if we fix the position of one stick?
Math,Dynamic Programming,Combinatorics
Hard
null
92
Hey guys welcome to take to live nivedita and in this video we are going to solve reverse least to swiss problem statement me wheat ke hai par aapko ek single ne kiska hai na de rakha hai and 2ND year de rakha hai left and right where What is your left in this daily west to right and what do you have to do in between l...
Reverse Linked List II
reverse-linked-list-ii
Given the `head` of a singly linked list and two integers `left` and `right` where `left <= right`, reverse the nodes of the list from position `left` to position `right`, and return _the reversed list_. **Example 1:** **Input:** head = \[1,2,3,4,5\], left = 2, right = 4 **Output:** \[1,4,3,2,5\] **Example 2:** **I...
null
Linked List
Medium
206
216
foreign we have to find all value combination of K numbers that sum up to n such the following conditions are true we can only choose numbers one two nine and each number is used at most one so we don't have repeating numbers and we can only choose from one uh to nine we have to that's basically our set of candidates w...
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
191
hey everyone today we'll be doing another lead code 191 number of one bits this is an easy problem and we have already done a problem much harder than this so which was reverse the bits and this is um number of one bits we have to tell how many one bits are there in a 32 bits I think this is a 32 bits they didn't speci...
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
91
hello and welcome to another video in this video we're going to be working on decode ways and in the problem you are given a message containing letters from A to Z that can be coded into numbers using the following mapping where you just convert a letter to its um number and so if you have something like a JF you can c...
Decode Ways
decode-ways
A message containing letters from `A-Z` can be **encoded** into numbers using the following mapping: 'A' -> "1 " 'B' -> "2 " ... 'Z' -> "26 " To **decode** an encoded message, all the digits must be grouped then mapped back into letters using the reverse of the mapping above (there may be multiple ways). For examp...
null
String,Dynamic Programming
Medium
639,2091
451
my name is himanshu today bihar going tu solve frequency of characters d problem description of character in d string return sorted string if there are multiple answers return anevan dem need tu count frequency of character in d string and give c need tu return education d first example Small Veer Tu So Small Only Maxi...
Sort Characters By Frequency
sort-characters-by-frequency
Given a string `s`, sort it in **decreasing order** based on the **frequency** of the characters. The **frequency** of a character is the number of times it appears in the string. Return _the sorted string_. If there are multiple answers, return _any of them_. **Example 1:** **Input:** s = "tree " **Output:** "eer...
null
Hash Table,String,Sorting,Heap (Priority Queue),Bucket Sort,Counting
Medium
347,387,1741
284
hey folks welcome back to another video today we'll be looking at question 284 making iterators the way we'll be approaching this problem is by using a cube so let's jump right in um let's initialize not initialize just like declare a cue right outside and the reason why we are doing that is because we want to be able ...
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,679
Hello Everyone Welcome To Date 16th January 14 Injured S Questions Maximum Number Of Care Of Examples Unit Youtube Channel To Tarzan Into Account The Maximum Number Of Peru Time And Not Utilize 12345 Subscribe Do n't Believe Way Don't Forget To Subscribe To During The Technique Now It's Election 2014 A Solemn Just Take...
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
96
let's solve leak code 96 unique binary search trees so we're given an integer n in this example we're given the integer 3 and we want to know how many unique binary search trees can we make from these integers so this sounds like a pretty simple problem right so let's think about the most simple case what if we were gi...
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
51
Hello friends in this video we will try to solve a problem which is quite a standard problem and once we read the problem statement it is a puzzle problem of placing a cross ends bow and gets stuck given entry and return distance. Solution to the n puzzle you return the answer in any order e solution cont distinct boar...
N-Queens
n-queens
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 _all distinct solutions to the **n-queens puzzle**_. You may return the answer in **any order**. Each solution contains a distinct board configuration of the n-...
null
Array,Backtracking
Hard
52,1043
208
lead code problem 208 Implement try a prefix tree so this problem wants us to implement a prefix tree which is a data structure used to store strings right and the reason why we have to use a try instead of a traditional data structure is because we have to account for autocomplete and spell checker right so there is t...
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
269
hey guys how's everything going this is Jay sir who is not good at algorithms I'm making these videos to prepare my job interviewing June which is actually one month later from Facebook so yeah let's start today is about 2 6 9 alien dictionary there's a new alien language which uses the Latin alphabet however the order...
Alien Dictionary
alien-dictionary
There is a new alien language that uses the English alphabet. However, the order among the letters is unknown to you. You are given a list of strings `words` from the alien language's dictionary, where the strings in `words` are **sorted lexicographically** by the rules of this new language. Return _a string of the u...
null
Array,String,Depth-First Search,Breadth-First Search,Graph,Topological Sort
Hard
210
16
hello everyone and welcome back to another video so today we're going to be solving the leakout question threesome closest all right so this question is very similar to the threesome question itself so i did make a video about it some time ago so do check it out if you don't know how to solve the threesome question but...
3Sum Closest
3sum-closest
Given an integer array `nums` of length `n` and an integer `target`, find three integers in `nums` such that the sum is closest to `target`. Return _the sum of the three integers_. You may assume that each input would have exactly one solution. **Example 1:** **Input:** nums = \[-1,2,1,-4\], target = 1 **Output:** ...
null
Array,Two Pointers,Sorting
Medium
15,259
787
hello everyone this is sham Saar and I welcome you again in the new video of our YouTube channel so this is the lead code medium problem which was asked on 23rd of February so this is cheapest flights within K stops here there are n cities connected by some number of flights and we have given an array flights where fli...
Cheapest Flights Within K Stops
sliding-puzzle
There are `n` cities connected by some number of flights. You are given an array `flights` where `flights[i] = [fromi, toi, pricei]` indicates that there is a flight from city `fromi` to city `toi` with cost `pricei`. You are also given three integers `src`, `dst`, and `k`, return _**the cheapest price** from_ `src` _...
Perform a breadth-first-search, where the nodes are the puzzle boards and edges are if two puzzle boards can be transformed into one another with one move.
Array,Breadth-First Search,Matrix
Hard
null
1,842
hey everybody this is Larry this is March 5th here in uh leod land and also New York why do I say so awkwardly uh but yeah I'm today I'm this video I'm going to do a PR I haven't done before so let's RNG it let's go oh we have a hard one today so let's take a look hopefully it's not too bad because I have to meet up wi...
Next Palindrome Using Same Digits
number-of-calls-between-two-persons
You are given a numeric string `num`, representing a very large **palindrome**. Return _the **smallest palindrome larger than**_ `num` _that can be created by rearranging its digits. If no such palindrome exists, return an empty string_ `" "`. A **palindrome** is a number that reads the same backward as forward. **E...
null
Database
Medium
null
493
cool 493 we were spares given away numbers requires of junior and important skill peer advised SNJ a number sub I is greater than two times time subject okay you need to return the number of important we were as Paris in a given away okay that's maybe that's easy to say at least the other one had like five pages of ins...
Reverse Pairs
reverse-pairs
Given an integer array `nums`, return _the number of **reverse pairs** in the array_. A **reverse pair** is a pair `(i, j)` where: * `0 <= i < j < nums.length` and * `nums[i] > 2 * nums[j]`. **Example 1:** **Input:** nums = \[1,3,2,3,1\] **Output:** 2 **Explanation:** The reverse pairs are: (1, 4) --> nums\[1\]...
null
Array,Binary Search,Divide and Conquer,Binary Indexed Tree,Segment Tree,Merge Sort,Ordered Set
Hard
315,327
425
hey what's up guys this is chung here so uh so today uh let's take a look at today's daily challenge uh number 425 word squares i think it's a cool problem here so you're given like a set of words without duplicates find all word squares you can build from them okay and the sequence of words form a valid word square if...
Word Squares
word-squares
Given an array of **unique** strings `words`, return _all the_ **[word squares](https://en.wikipedia.org/wiki/Word_square)** _you can build from_ `words`. The same word from `words` can be used **multiple times**. You can return the answer in **any order**. A sequence of strings forms a valid **word square** if the `k...
null
Array,String,Backtracking,Trie
Hard
422
1,859
Salam alikum so in this leth C question I'll be discussing uh 1859 sorting sentence simply stated all we have is this drink as a parameter that's provided and what we need to do is order it or sort it based on the ending of the integers the end of each if we break this down into an array and take the last character wit...
Sorting the Sentence
change-minimum-characters-to-satisfy-one-of-three-conditions
A **sentence** is a list of words that are separated by a single space with no leading or trailing spaces. Each word consists of lowercase and uppercase English letters. A sentence can be **shuffled** by appending the **1-indexed word position** to each word then rearranging the words in the sentence. * For example...
Iterate on each letter in the alphabet, and check the smallest number of operations needed to make it one of the following: the largest letter in a and smaller than the smallest one in b, vice versa, or let a and b consist only of this letter. For the first 2 conditions, take care that you can only change characters to...
Hash Table,String,Counting,Prefix Sum
Medium
null
374
so 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 pick every time you guess wrong I will tell you whether the number you picked is higher or lower than your case so we have a pretty different function integrals of num which returns three possible result...
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,338
hi everyone once again welcome to the channel today in this video we are going to solve a let code problem reduce array size to the half so given an array you can choose a set of integers and remove all the occurrence of this integers in the array and we have to return the minimum size of that set so that at least half...
Reduce Array Size to The Half
queries-quality-and-percentage
You are given an integer array `arr`. You can choose a set of integers and remove all the occurrences of these integers in the array. Return _the minimum size of the set so that **at least** half of the integers of the array are removed_. **Example 1:** **Input:** arr = \[3,3,3,3,5,5,5,2,2,7\] **Output:** 2 **Explan...
null
Database
Easy
1773
835
So gas welcome back to my channel thank you and today I have given you this lead code challenge image overlapping and what you can do in this image is you can shift the lineage of this image up or down left or right, what can you do with this If you can shift it to the right, what will happen? What can you do, if you c...
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,913
hi my name is david today we're going to do number 1913 maximum product difference between two pairs only code and we'll be solving this in javascript so we have a function here that takes in an array of numbers and it wants to return a number and that number is the maximum output you can get by getting the difference ...
Maximum Product Difference Between Two Pairs
make-the-xor-of-all-segments-equal-to-zero
The **product difference** between two pairs `(a, b)` and `(c, d)` is defined as `(a * b) - (c * d)`. * For example, the product difference between `(5, 6)` and `(2, 7)` is `(5 * 6) - (2 * 7) = 16`. Given an integer array `nums`, choose four **distinct** indices `w`, `x`, `y`, and `z` such that the **product differ...
Let's note that for the XOR of all segments with size K to be equal to zeros, nums[i] has to be equal to nums[i+k] Basically, we need to make the first K elements have XOR = 0 and then modify them.
Array,Dynamic Programming,Bit Manipulation
Hard
null
1,275
Hello Everyone Welcome To Date 28th September Light On Android Question This Point Thursday Subscribe This Point Winner On Text To Give One To Say Zinc Valid Code Dial Subscribe To That With Its Total Here Mix Group And Mixer Mood For Exhibition More Returns Gift Veer Withdrawal And Subscribe To That However In This Vi...
Find Winner on a Tic Tac Toe Game
validate-binary-tree-nodes
**Tic-tac-toe** is played by two players `A` and `B` on a `3 x 3` grid. The rules of Tic-Tac-Toe are: * Players take turns placing characters into empty squares `' '`. * The first player `A` always places `'X'` characters, while the second player `B` always places `'O'` characters. * `'X'` and `'O'` characters a...
Find the parent of each node. A valid tree must have nodes with only one parent and exactly one node with no parent.
Tree,Depth-First Search,Breadth-First Search,Union Find,Graph,Binary Tree
Medium
null
378
hello all welcome to code hub uh today let us solve the lead codes daily challenge and the problem is kth smallest element in a sorted matrix given a n cross n matrix where each of the rows and columns is sorted in ascending order return the kth smallest element in the matrix so note that it is the kth smallest element...
Kth Smallest Element in a Sorted Matrix
kth-smallest-element-in-a-sorted-matrix
Given an `n x n` `matrix` where each of the rows and columns is sorted in ascending order, return _the_ `kth` _smallest element in the matrix_. Note that it is the `kth` smallest element **in the sorted order**, not the `kth` **distinct** element. You must find a solution with a memory complexity better than `O(n2)`....
null
Array,Binary Search,Sorting,Heap (Priority Queue),Matrix
Medium
373,668,719,802
1,646
Hello everyone welcome to day vihar into victory of pimple east questions where is the question is that maximum in generated there are a great veer vidya valley of flowers falling into a variety of subscribe Video then subscribe to the Page if you liked The Video then speak Entry frame with updated for love special nam...
Get Maximum in Generated Array
kth-missing-positive-number
You are given an integer `n`. A **0-indexed** integer array `nums` of length `n + 1` is generated in the following way: * `nums[0] = 0` * `nums[1] = 1` * `nums[2 * i] = nums[i]` when `2 <= 2 * i <= n` * `nums[2 * i + 1] = nums[i] + nums[i + 1]` when `2 <= 2 * i + 1 <= n` Return _the **maximum** integer in the...
Keep track of how many positive numbers are missing as you scan the array.
Array,Binary Search
Easy
2305
636
hello and welcome back to the cracking Thing YouTube channel today we're going to be solving lead code problem 636 exclusive time of functions before we do you guys know the drill like and leave a comment on the video it helps so much with the YouTube algorithm all right let's read the question prompt on a single threa...
Exclusive Time of Functions
exclusive-time-of-functions
On a **single-threaded** CPU, we execute a program containing `n` functions. Each function has a unique ID between `0` and `n-1`. Function calls are **stored in a [call stack](https://en.wikipedia.org/wiki/Call_stack)**: when a function call starts, its ID is pushed onto the stack, and when a function call ends, its I...
null
Array,Stack
Medium
null
243
hello everyone in this video i'll be talking about lead code question number 243 shortest word distance so given an array of strings words dict and two different strings that already exist in the array word one and word two return the shortest distance between these two words in the list so we are given a list of words...
Shortest Word Distance
shortest-word-distance
Given an array of strings `wordsDict` and two different strings that already exist in the array `word1` and `word2`, return _the shortest distance between these two words in the list_. **Example 1:** **Input:** wordsDict = \[ "practice ", "makes ", "perfect ", "coding ", "makes "\], word1 = "coding ", word2 = "...
null
Array,String
Easy
244,245,2320
81
hello everyone welcome back here's van damson and today we are diving deep into a fascinating problem from a liquid daily challenge search in a rotated sorted array too so if you are interested in how we can apply binary search in a rotate it all right possible with duplicates uh you are in the right place and don't fo...
Search in Rotated Sorted Array II
search-in-rotated-sorted-array-ii
There is an integer array `nums` sorted in non-decreasing order (not necessarily with **distinct** values). Before being passed to your function, `nums` is **rotated** at an unknown pivot index `k` (`0 <= k < nums.length`) such that the resulting array is `[nums[k], nums[k+1], ..., nums[n-1], nums[0], nums[1], ..., nu...
null
Array,Binary Search
Medium
33
91
hey so welcome back in this another daily code problem so today it's called decode ways and let's take a peek at it so essentially it's a dynamic programming problem that's like a medium level one and all that you want to do is you're given a string here and you want to translate it into like letters from A to Z and wh...
Decode Ways
decode-ways
A message containing letters from `A-Z` can be **encoded** into numbers using the following mapping: 'A' -> "1 " 'B' -> "2 " ... 'Z' -> "26 " To **decode** an encoded message, all the digits must be grouped then mapped back into letters using the reverse of the mapping above (there may be multiple ways). For examp...
null
String,Dynamic Programming
Medium
639,2091
7
yo Chuck what the Chuck is up YouTube in this video I'm gonna go over Lee code 7 reverse integer so as you may imagine we're just going to take a number and reverse it this is going to be a little bit trickier if the number is negative but we can just do a simple test for that and it's not too bad the constraint we hav...
Reverse Integer
reverse-integer
Given a signed 32-bit integer `x`, return `x` _with its digits reversed_. If reversing `x` causes the value to go outside the signed 32-bit integer range `[-231, 231 - 1]`, then return `0`. **Assume the environment does not allow you to store 64-bit integers (signed or unsigned).** **Example 1:** **Input:** x = 123 ...
null
Math
Medium
8,190,2238
1,095
so hello everyone myself Aditi and uh today I'll be solving the very first lead code daily challenge problem on YouTube and the question is find in Mountain array the question belongs to 12th of October 2023 and uh the question says that an array is a mountain array if and only if the length of the array is greater tha...
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
480
hey what's up guys this is john here so today uh let's take a look at this number 480 sliding window medium heart problem okay so you know median is the middle value in an other integer list if the size of the list is even then there's no middle value basically um if the number of the wind of the size is odd it's the o...
Sliding Window Median
sliding-window-median
The **median** is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two middle values. * For examples, if `arr = [2,3,4]`, the median is `3`. * For examples, if `arr = [1,2,3,4]`, the median is `(2 + 3) / 2 = 2.5`. You are give...
The simplest of solutions comes from the basic idea of finding the median given a set of numbers. We know that by definition, a median is the center element (or an average of the two center elements). Given an unsorted list of numbers, how do we find the median element? If you know the answer to this question, can we e...
Array,Hash Table,Sliding Window,Heap (Priority Queue)
Hard
295
92
hello and welcome to today's daily lead code challenge today we'll be solving question 92. uh first I'll go through the through my thought process as I come up with the solution later I will compare my solution to the solution of others to see where I can improve my algorithm uh etc uh with that let's begin the questio...
Reverse Linked List II
reverse-linked-list-ii
Given the `head` of a singly linked list and two integers `left` and `right` where `left <= right`, reverse the nodes of the list from position `left` to position `right`, and return _the reversed list_. **Example 1:** **Input:** head = \[1,2,3,4,5\], left = 2, right = 4 **Output:** \[1,4,3,2,5\] **Example 2:** **I...
null
Linked List
Medium
206
1,832
Jhaal Jai Hind This Video Will Be Solved In Question Number 10 Researcher Ki Phir Sentences Pan Garam Aur Not Relate Serious Question Research Question Subscribe Sentence Paper of English Alphabet Appears at Least One Example Sentence Quick Brown Fox Jumps Over the Lazy Dog Subscribe To-Do Subscribe to List English Sen...
Check if the Sentence Is Pangram
minimum-operations-to-make-a-subsequence
A **pangram** is a sentence where every letter of the English alphabet appears at least once. Given a string `sentence` containing only lowercase English letters, return `true` _if_ `sentence` _is a **pangram**, or_ `false` _otherwise._ **Example 1:** **Input:** sentence = "thequickbrownfoxjumpsoverthelazydog " **O...
The problem can be reduced to computing Longest Common Subsequence between both arrays. Since one of the arrays has distinct elements, we can consider that these elements describe an arrangement of numbers, and we can replace each element in the other array with the index it appeared at in the first array. Then the pro...
Array,Hash Table,Binary Search,Greedy
Hard
null
65
hey everybody this is larry this is day 15 of the may league code daily challenge hit the like button to subscribe and join me on discord let me know what you think uh middle of the month we'll see how that goes and today's problem is rather number so i usually start this live uh and today a little bit slower because i...
Valid Number
valid-number
A **valid number** can be split up into these components (in order): 1. A **decimal number** or an **integer**. 2. (Optional) An `'e'` or `'E'`, followed by an **integer**. A **decimal number** can be split up into these components (in order): 1. (Optional) A sign character (either `'+'` or `'-'`). 2. One of the...
null
String
Hard
8
1,704
Hello Everyone Welcome Dresses Date - Prince House Of Life And Values Date - Prince House Of Life And Values Date - Prince House Of Life And Values Se How Can To Strings Also Like Zur Se Withdrawal Sim Number Of That Bigg Boss Independent Office To This Question Subscribe Notification More Subscribe Itni Problem Guide ...
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
107
Marilyn welcome back to another video from the winter forest today nice continue our little challenge today's nickel question is codon finally tree they were all the travels second let's look at a question so you will be given a banana tree and the day you put output expect Apple day it is in route important Apple labo...
Binary Tree Level Order Traversal II
binary-tree-level-order-traversal-ii
Given the `root` of a binary tree, return _the bottom-up level order traversal of its nodes' values_. (i.e., from left to right, level by level from leaf to root). **Example 1:** **Input:** root = \[3,9,20,null,null,15,7\] **Output:** \[\[15,7\],\[9,20\],\[3\]\] **Example 2:** **Input:** root = \[1\] **Output:** \[...
null
Tree,Breadth-First Search,Binary Tree
Medium
102,637
1,312
hello friends so today in this video we're gonna discuss another problem from lead code which is a hard problem so the problem name is minimum insertion steps to make a string palindrome so the problem is very simple is just states that you're given a string s and you have to tell how many different characters you have...
Minimum Insertion Steps to Make a String Palindrome
count-artifacts-that-can-be-extracted
Given a string `s`. In one step you can insert any character at any index of the string. Return _the minimum number of steps_ to make `s` palindrome. A **Palindrome String** is one that reads the same backward as well as forward. **Example 1:** **Input:** s = "zzazz " **Output:** 0 **Explanation:** The string "zz...
Check if each coordinate of each artifact has been excavated. How can we do this quickly without iterating over the dig array every time? Consider marking all excavated cells in a 2D boolean array.
Array,Hash Table,Simulation
Medium
221
48
hello everyone welcome to learn about flow in this video we will discuss about another liquid problem that is a rotate image this is a medium level problem and we'll understand how exactly the question should be approach and how we should find a solution to this kind of question so before moving on if you haven't subsc...
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
1,025
hello everyone so in this video let us talk about a easy problem from lead code the problem name is divisor game so let's start the problem goes like this that Alice and Bob takes turn to play a game and Alice start the game first now what the actual game is that initially there's a number n on a chalkboard on each pla...
Divisor Game
minimum-cost-for-tickets
Alice and Bob take turns playing a game, with Alice starting first. Initially, there is a number `n` on the chalkboard. On each player's turn, that player makes a move consisting of: * Choosing any `x` with `0 < x < n` and `n % x == 0`. * Replacing the number `n` on the chalkboard with `n - x`. Also, if a player...
null
Array,Dynamic Programming
Medium
322
207
hey guys it's all five one here and today we're going to be solving course schedule in this problem we're given a variable called num courses and all this tells us is the number of courses we have to take we're also given an array of prerequisites so the way the prerequisites array works is they give us a pair A and B ...
Course Schedule
course-schedule
There are a total of `numCourses` courses you have to take, labeled from `0` to `numCourses - 1`. You are given an array `prerequisites` where `prerequisites[i] = [ai, bi]` indicates that you **must** take course `bi` first if you want to take course `ai`. * For example, the pair `[0, 1]`, indicates that to take cou...
This problem is equivalent to finding if a cycle exists in a directed graph. If a cycle exists, no topological ordering exists and therefore it will be impossible to take all courses. Topological Sort via DFS - A great video tutorial (21 minutes) on Coursera explaining the basic concepts of Topological Sort. Topologica...
Depth-First Search,Breadth-First Search,Graph,Topological Sort
Medium
210,261,310,630
328
hi today I will talk about problem 328 from leak code old even linked lists given a singly linked list group old notes together followed by even notes we are talking about the node number here and not the note value it then proceeds and gives you an input 1 2 3 4 5 and null and the output would be 1 3 5 which is groupe...
Odd Even Linked List
odd-even-linked-list
Given the `head` of a singly linked list, group all the nodes with odd indices together followed by the nodes with even indices, and return _the reordered list_. The **first** node is considered **odd**, and the **second** node is **even**, and so on. Note that the relative order inside both the even and odd groups s...
null
Linked List
Medium
725
217
hello everyone and welcome back to another video so i'm going to try to solve all of the questions in the data structures playlist or kind of module over here so starting off with the first question which is contains duplicates so let's take a look at that question okay so in this question we're going to be given an in...
Contains Duplicate
contains-duplicate
Given an integer array `nums`, return `true` if any value appears **at least twice** in the array, and return `false` if every element is distinct. **Example 1:** **Input:** nums = \[1,2,3,1\] **Output:** true **Example 2:** **Input:** nums = \[1,2,3,4\] **Output:** false **Example 3:** **Input:** nums = \[1,1,1,...
null
Array,Hash Table,Sorting
Easy
219,220
1,909
hey everybody this is larry this is me going over q1 of the biweekly contest 55. we move one element to make the race strictly increasing so this one is a little bit tricky um but you have to look at constraints so hit the like button hit the construct uh hit the constraints hit the like button hit the subscribe button...
Remove One Element to Make the Array Strictly Increasing
buildings-with-an-ocean-view
Given a **0-indexed** integer array `nums`, return `true` _if it can be made **strictly increasing** after removing **exactly one** element, or_ `false` _otherwise. If the array is already strictly increasing, return_ `true`. The array `nums` is **strictly increasing** if `nums[i - 1] < nums[i]` for each index `(1 <= ...
You can traverse the buildings from the nearest to the ocean to the furthest. Keep with you the maximum to the right while traversing to determine if you can see the ocean or not.
Array,Stack,Monotonic Stack
Medium
1305
971
hey guys it's es wave and today we're gonna be doing we code 971 flip binary tree to magic preorder traversal so the problem is given a binary tree with n nodes each node has a different value from 1 to n a node in this binary tree can be flipped by swapping the left child and the right child of that node consider the ...
Flip Binary Tree To Match Preorder Traversal
shortest-bridge
You are given the `root` of a binary tree with `n` nodes, where each node is uniquely assigned a value from `1` to `n`. You are also given a sequence of `n` values `voyage`, which is the **desired** [**pre-order traversal**](https://en.wikipedia.org/wiki/Tree_traversal#Pre-order) of the binary tree. Any node in the bi...
null
Array,Depth-First Search,Breadth-First Search,Matrix
Medium
null
108
hello everyone today we'll be working on leak code 108 convert sorted or write a binary search tree so we are given an integer array called nums and the elements are sorted in ascending order and our goal is to convert this array into a height balanced binary search tree so to better understand what they mean by hype b...
Convert Sorted Array to Binary Search Tree
convert-sorted-array-to-binary-search-tree
Given an integer array `nums` where the elements are sorted in **ascending order**, convert _it to a_ **_height-balanced_** _binary search tree_. **Example 1:** **Input:** nums = \[-10,-3,0,5,9\] **Output:** \[0,-3,9,-10,null,5\] **Explanation:** \[0,-10,5,null,-3,null,9\] is also accepted: **Example 2:** **Input...
null
Array,Divide and Conquer,Tree,Binary Search Tree,Binary Tree
Easy
109
1,704
be solving problem 1704 determine if string halves are alike the problem statement is you are given a string s of even length split this string into two halves of equal length 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 in it doesn't matter if it is ...
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
209
uh these questions is minimum size subaruism so you are given an integer positive integers and I'm sorry and a positive integer Target and return a minimum length of the sub array whose sum is actually greater than or equal to a Target and if there is no such sub array then you have to return zero so let's draw so um I...
Minimum Size Subarray Sum
minimum-size-subarray-sum
Given an array of positive integers `nums` and a positive integer `target`, return _the **minimal length** of a_ _subarray_ _whose sum is greater than or equal to_ `target`. If there is no such subarray, return `0` instead. **Example 1:** **Input:** target = 7, nums = \[2,3,1,2,4,3\] **Output:** 2 **Explanation:** Th...
null
Array,Binary Search,Sliding Window,Prefix Sum
Medium
76,325,718,1776,2211,2329