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
823
Loot cordiality everyone welcome back to Indians and today's promise day for increase with factors surya ki one with android jada jara click on hair and makeup binary number used for any number of no value shoot me to the value of children for example 12431 adherence to Enter daba li a stand still has come but e two a ...
Binary Trees With Factors
split-array-with-same-average
Given an array of unique integers, `arr`, where each integer `arr[i]` is strictly greater than `1`. We make a binary tree using these integers, and each number may be used for any number of times. Each non-leaf node's value should be equal to the product of the values of its children. Return _the number of binary tre...
null
Array,Math,Dynamic Programming,Bit Manipulation,Bitmask
Hard
2162
50
Hello Everybody Welcome To My Channel Today Is The Day 16mb Problems For Common And They Have To Implement A Power Function Between Calculates Access To Power And Select Every Programming Language Must Have Its Function Subscribe Our In This Problem Don't Know The Function To Basic Element Function Is Implemented Inter...
Pow(x, n)
powx-n
Implement [pow(x, n)](http://www.cplusplus.com/reference/valarray/pow/), which calculates `x` raised to the power `n` (i.e., `xn`). **Example 1:** **Input:** x = 2.00000, n = 10 **Output:** 1024.00000 **Example 2:** **Input:** x = 2.10000, n = 3 **Output:** 9.26100 **Example 3:** **Input:** x = 2.00000, n = -2 **...
null
Math,Recursion
Medium
69,372
1,703
That I Will Today Chief Minister Problem Number 03 Minimum Madison Square Karke Positive A Slap Understand and Problems Statements Ninth Price of Processes of Sexual Frustrations in Wave Subscribe Must Subscribe to the Channel So Let's Understand and Problems Statements on Problems Sandwich Here and Comes Which Content...
Minimum Adjacent Swaps for K Consecutive Ones
put-boxes-into-the-warehouse-i
You are given an integer array, `nums`, and an integer `k`. `nums` comprises of only `0`'s and `1`'s. In one move, you can choose two **adjacent** indices and swap their values. Return _the **minimum** number of moves required so that_ `nums` _has_ `k` _**consecutive**_ `1`_'s_. **Example 1:** **Input:** nums = \[1,...
Sort the boxes in ascending order, try to process the box with the smallest height first.
Array,Greedy,Sorting
Medium
1719
4
hello everyone welcome back to sudokoda this is Ravina I'm making this video since I have been getting a lot of requests uh for this one uh so that's why I decided to create this one and solve this one before the new year hits uh you can also request uh if you want a particular problem to be solved by me you can let th...
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,391
there's about 1 000 problems that I already did this is check if there's a valid path in a grid so you are given an M by n grid each cell of the grid represents a street interesting the streets of the grid can be as follows one means that a street connects the left cell and the right cell two means the string connects ...
Check if There is a Valid Path in a Grid
counting-elements
You are given an `m x n` `grid`. Each cell of `grid` represents a street. The street of `grid[i][j]` can be: * `1` which means a street connecting the left cell and the right cell. * `2` which means a street connecting the upper cell and the lower cell. * `3` which means a street connecting the left cell and the...
Use hashset to store all elements. Loop again to count all valid elements.
Array,Hash Table
Easy
null
1,020
Welcome you the stylish coder, hope you all are doing well. We will prepare a binary matrix in which zero will be representing our C cell and one will be representing our land cell and we can move inside this matrix in four directions. In mains, we can go left, we can go right, we can move in all four directions and wh...
Number of Enclaves
longest-turbulent-subarray
You are given an `m x n` binary matrix `grid`, where `0` represents a sea cell and `1` represents a land cell. A **move** consists of walking from one land cell to another adjacent (**4-directionally**) land cell or walking off the boundary of the `grid`. Return _the number of land cells in_ `grid` _for which we cann...
null
Array,Dynamic Programming,Sliding Window
Medium
53
1,785
hello everyone hope you are doing well and today we'll be solving a question that came in today's contest in the morning and the question is minimum elements to form a given sum in this question you are given an array of integers and you need to add elements uh to your in to your input so that the total sum becomes equ...
Minimum Elements to Add to Form a Given Sum
hopper-company-queries-ii
You are given an integer array `nums` and two integers `limit` and `goal`. The array `nums` has an interesting property that `abs(nums[i]) <= limit`. Return _the minimum number of elements you need to add to make the sum of the array equal to_ `goal`. The array must maintain its property that `abs(nums[i]) <= limit`. ...
null
Database
Hard
262,1779,1795,2376
105
so in this video we are going to create the binary tree if already given the pre-order and in order to reversal so pre-order and in order to reversal so pre-order and in order to reversal so before we start jumping into the actual problem and solving let me give the basic idea what is the pre-order in basic idea what i...
Construct Binary Tree from Preorder and Inorder Traversal
construct-binary-tree-from-preorder-and-inorder-traversal
Given two integer arrays `preorder` and `inorder` where `preorder` is the preorder traversal of a binary tree and `inorder` is the inorder traversal of the same tree, construct and return _the binary tree_. **Example 1:** **Input:** preorder = \[3,9,20,15,7\], inorder = \[9,3,15,20,7\] **Output:** \[3,9,20,null,null,...
null
Array,Hash Table,Divide and Conquer,Tree,Binary Tree
Medium
106
336
hey everybody this is larry this is day 13 of june so it is the 13th day of the june nico daily challenge hit the like button hit the subscribe button join me on discord so we can discuss this problem or other problems whatever you like the contest if you like during the contest anyway today's problem is palindrome pee...
Palindrome Pairs
palindrome-pairs
You are given a **0-indexed** array of **unique** strings `words`. A **palindrome pair** is a pair of integers `(i, j)` such that: * `0 <= i, j < words.length`, * `i != j`, and * `words[i] + words[j]` (the concatenation of the two strings) is a palindrome. Return _an array of all the **palindrome pairs** of_ `...
null
Array,Hash Table,String,Trie
Hard
5,214,2237
1,903
Hello everyone welcome to my channel code sorry with mike so today we are going to do question number five of our lead code easy playlist okay such questions are phone interviews and good practice problems and this question is marked amazon2 easy largest odd number in string Ok so I think so see I am not sure but I thi...
Largest Odd Number in String
design-most-recently-used-queue
You are given a string `num`, representing a large integer. Return _the **largest-valued odd** integer (as a string) that is a **non-empty substring** of_ `num`_, or an empty string_ `" "` _if no odd integer exists_. A **substring** is a contiguous sequence of characters within a string. **Example 1:** **Input:** nu...
You can store the data in an array and apply each fetch by moving the ith element to the end of the array (i.e, O(n) per operation). A better way is to use the square root decomposition technique. You can build chunks of size sqrt(n). For each fetch operation, You can search for the chunk which has the ith element and ...
Array,Hash Table,Stack,Design,Binary Indexed Tree,Ordered Set
Medium
146
1,610
um hey guys let's do this maximum number of visible points together um it's a hard questions um and it's often asked by google some related topic is array mass geometry sliding window and sorting so let's look at these questions together so we're given three variable points angle and the location um so point it's a arr...
Maximum Number of Visible Points
xor-operation-in-an-array
You are given an array `points`, an integer `angle`, and your `location`, where `location = [posx, posy]` and `points[i] = [xi, yi]` both denote **integral coordinates** on the X-Y plane. Initially, you are facing directly east from your position. You **cannot move** from your position, but you can **rotate**. In othe...
Simulate the process, create an array nums and return the Bitwise XOR of all elements of it.
Math,Bit Manipulation
Easy
null
1,945
hey everybody this is larry this is me going with you one of the weekly contest 251 sum of the digits of string after convert so this is actually a simulation problem where you just basically do what the problem tells you um i don't really have any insight here except for them just be careful slow down make sure you ge...
Sum of Digits of String After Convert
finding-the-users-active-minutes
You are given a string `s` consisting of lowercase English letters, and an integer `k`. First, **convert** `s` into an integer by replacing each letter with its position in the alphabet (i.e., replace `'a'` with `1`, `'b'` with `2`, ..., `'z'` with `26`). Then, **transform** the integer by replacing it with the **sum ...
Try to find the number of different minutes when action happened for each user. For each user increase the value of the answer array index which matches the UAM for this user.
Array,Hash Table
Medium
null
1,928
hello and welcome um we have today another question I'll be called 1928 minimum cost to reach destination and time now this question has been recently asked by Facebook so I hope you guys you know couldn't enjoy um what happened so I'm going to read the question is there is a country of n cities numbered from 0 to n mi...
Minimum Cost to Reach Destination in Time
number-of-orders-in-the-backlog
There is a country of `n` cities numbered from `0` to `n - 1` where **all the cities are connected** by bi-directional roads. The roads are represented as a 2D integer array `edges` where `edges[i] = [xi, yi, timei]` denotes a road between cities `xi` and `yi` that takes `timei` minutes to travel. There may be multiple...
Store the backlog buy and sell orders in two heaps, the buy orders in a max heap by price and the sell orders in a min heap by price. Store the orders in batches and update the fields according to new incoming orders. Each batch should only take 1 "slot" in the heap.
Array,Heap (Priority Queue),Simulation
Medium
null
393
hello everyone welcome to learn overflow in this video we'll discuss another little problem that is the utf-8 little problem that is the utf-8 little problem that is the utf-8 validation so this is a medium level question and we'll understand how this question can be solved and uh we need to understand a lot on this qu...
UTF-8 Validation
utf-8-validation
Given an integer array `data` representing the data, return whether it is a valid **UTF-8** encoding (i.e. it translates to a sequence of valid UTF-8 encoded characters). A character in **UTF8** can be from **1 to 4 bytes** long, subjected to the following rules: 1. For a **1-byte** character, the first bit is a `0`...
All you have to do is follow the rules. For a given integer, obtain its binary representation in the string form and work with the rules given in the problem. An integer can either represent the start of a UTF-8 character, or a part of an existing UTF-8 character. There are two separate rules for these two scenarios in...
Array,Bit Manipulation
Medium
null
1,876
hi everyone um so my name is Deepa and today I'm back with another problem and this is from lead code um it's called substantial size 3 with distant characters and it's a string based um problem so um let's get started um so a string is good if there are no repetitive characters given a string s we need to return the n...
Substrings of Size Three with Distinct Characters
map-of-highest-peak
A string is **good** if there are no repeated characters. Given a string `s`​​​​​, return _the number of **good substrings** of length **three** in_ `s`​​​​​​. Note that if there are multiple occurrences of the same substring, every occurrence should be counted. A **substring** is a contiguous sequence of characters...
Set each water cell to be 0. The height of each cell is limited by its closest water cell. Perform a multi-source BFS with all the water cells as sources.
Array,Breadth-First Search,Matrix
Medium
null
424
hey what's up guys today we're looking at longest repeating character replacement so uh pretty much you're given a string s and you can only replace up to k characters um to be any other character and you want to figure out the longest substring that can consists of just one character so here in the example we have k e...
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
198
Hebron Welcome to the Standard Problem House Property Problem First Year Exam Result Will Have to Take One 3809 Exam Result 130 and Devi Soni One Line Man to Dehradun Two Element to Take Care of Capital First Election Hanged Re Baby Store Maximum Money and Opposition Sunao OK Done The First Two Balance Will Create and ...
House Robber
house-robber
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security systems connected and **it will automatically contact the police if two adjacent houses were broken into...
null
Array,Dynamic Programming
Medium
152,213,256,276,337,600,656,740,2262
1,457
Hello everyone welcome to my channel code sorry with mike so today going to do video number 38 of binary trick playlist take number 1457 not at all medium let's make it in a very easy way ok and let's see what the question is trying to say Given a binary tree where node values ​​are digits from two to nine ok see the v...
Pseudo-Palindromic Paths in a Binary Tree
minimum-difficulty-of-a-job-schedule
Given a binary tree where node values are digits from 1 to 9. A path in the binary tree is said to be **pseudo-palindromic** if at least one permutation of the node values in the path is a palindrome. _Return the number of **pseudo-palindromic** paths going from the root node to leaf nodes._ **Example 1:** **Input:*...
Use DP. Try to cut the array into d non-empty sub-arrays. Try all possible cuts for the array. Use dp[i][j] where DP states are i the index of the last cut and j the number of remaining cuts. Complexity is O(n * n * d).
Array,Dynamic Programming
Hard
null
210
Hello hello brother hour gold today weather in to solve this problem for date procession cotanger planets 2210 shift me difference create the given will be important and number kotha number port se show and third number of verses in teachers subscribe to the Video then subscribe to the Channel and subscribe the Video t...
Course Schedule II
course-schedule-ii
There are a total of `numCourses` courses you have to take, labeled from `0` to `numCourses - 1`. You are given an array `prerequisites` where `prerequisites[i] = [ai, bi]` indicates that you **must** take course `bi` first if you want to take course `ai`. * For example, the pair `[0, 1]`, indicates that to take cou...
This problem is equivalent to finding the topological order in a directed graph. If a cycle exists, no topological ordering exists and therefore it will be impossible to take all courses. Topological Sort via DFS - A great video tutorial (21 minutes) on Coursera explaining the basic concepts of Topological Sort. Topolo...
Depth-First Search,Breadth-First Search,Graph,Topological Sort
Medium
207,269,310,444,630,1101,2220
908
Lincoln 908 smallest range one given an array of integers for each integer a sub i we may choose any X with the X between negative K and at X 2 a sub I after this process we have some away B we turn the smallest possible difference between the maximum value B and the minimum value P ok I feel like I went to Paul more n...
Smallest Range I
middle-of-the-linked-list
You are given an integer array `nums` and an integer `k`. In one operation, you can choose any index `i` where `0 <= i < nums.length` and change `nums[i]` to `nums[i] + x` where `x` is an integer from the range `[-k, k]`. You can apply this operation **at most once** for each index `i`. The **score** of `nums` is the...
null
Linked List,Two Pointers
Easy
2216,2236
338
Hello everyone, the operation is going to be done, the list account number is 338, the problem is counting but what is the problem that we have to see a value, we have seen an interior and, okay, and what we have to do is to make an agri, which will have a side, how many empress means from zero to the end. If we start ...
Counting Bits
counting-bits
Given an integer `n`, return _an array_ `ans` _of length_ `n + 1` _such that for each_ `i` (`0 <= i <= n`)_,_ `ans[i]` _is the **number of**_ `1`_**'s** in the binary representation of_ `i`. **Example 1:** **Input:** n = 2 **Output:** \[0,1,1\] **Explanation:** 0 --> 0 1 --> 1 2 --> 10 **Example 2:** **Input:** n =...
You should make use of what you have produced already. Divide the numbers in ranges like [2-3], [4-7], [8-15] and so on. And try to generate new range from previous. Or does the odd/even status of the number help you in calculating the number of 1s?
Dynamic Programming,Bit Manipulation
Easy
191
1,931
hey what's up guys this is chung here again so this time lead called number 1931 painting a grid with three different colors okay so given like two integers m and n right consider an m times n grade where each cell is individually is initially white and you can paint each cell with these three colors either red green o...
Painting a Grid With Three Different Colors
shortest-path-in-a-hidden-grid
You are given two integers `m` and `n`. Consider an `m x n` grid where each cell is initially white. You can paint each cell **red**, **green**, or **blue**. All cells **must** be painted. Return _the number of ways to color the grid with **no two adjacent cells having the same color**_. Since the answer can be very l...
The grid is at a maximum 500 x 500, so it is clever to assume that the robot's initial cell is grid[501][501] Run a DFS from the robot's position to make sure that you can reach the target, otherwise you should return -1. Now that you are sure you can reach the target, run BFS to find the shortest path.
Depth-First Search,Breadth-First Search,Graph,Interactive
Medium
865,1959
7
hello and welcome back today I will be going over the reverse integer problem on lead code the problem asks us to write an algorithm that can reverse an integer and then return the Reversed value whenever you reverse a number you're taking the last digit of your original number and making it the first digit of your new...
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
464
464 can i win in the hundred game two players take turns adding to a running total any integer from one to ten the first the player who first causes the running total to reach or exceed 100 wins what if we change a game so that the players cannot reuse the integers for example two players might take turns drawing from ...
Can I Win
can-i-win
In the "100 game " two players take turns adding, to a running total, any integer from `1` to `10`. The player who first causes the running total to **reach or exceed** 100 wins. What if we change the game so that players **cannot** re-use integers? For example, two players might take turns drawing from a common pool...
null
Math,Dynamic Programming,Bit Manipulation,Memoization,Game Theory,Bitmask
Medium
294,375,486
59
Hello friends, welcome to the new video, question number five is Loot Code Spiral Matrix Part Two medium level question, its question is absolutely similar to Spiral Matrix Part-1, the absolutely similar to Spiral Matrix Part-1, the absolutely similar to Spiral Matrix Part-1, the code is also 95% same, if you are code ...
Spiral Matrix II
spiral-matrix-ii
Given a positive integer `n`, generate an `n x n` `matrix` filled with elements from `1` to `n2` in spiral order. **Example 1:** **Input:** n = 3 **Output:** \[\[1,2,3\],\[8,9,4\],\[7,6,5\]\] **Example 2:** **Input:** n = 1 **Output:** \[\[1\]\] **Constraints:** * `1 <= n <= 20`
null
Array,Matrix,Simulation
Medium
54,921
300
he everyone today we are going to solve the r question longest increasing subsequence okay so let me explain with this example 56 3 10 four so my idea is coming from dynamic programming and we keep uh each element itself with ascending order so let's say result variable and this is a empty list so basically we iterate ...
Longest Increasing Subsequence
longest-increasing-subsequence
Given an integer array `nums`, return _the length of the longest **strictly increasing**_ _**subsequence**_. **Example 1:** **Input:** nums = \[10,9,2,5,3,7,101,18\] **Output:** 4 **Explanation:** The longest increasing subsequence is \[2,3,7,101\], therefore the length is 4. **Example 2:** **Input:** nums = \[0,1,...
null
Array,Binary Search,Dynamic Programming
Medium
334,354,646,673,712,1766,2096,2234
266
given a string as returned true if a permutation of the string could form a palindrome so this is the string that is given to us and we should see if we can form a palindrome from any permutation of this string so what is a permutation is like uh how i can move around the letters that are given to me in this string and...
Palindrome Permutation
palindrome-permutation
Given a string `s`, return `true` _if a permutation of the string could form a_ _**palindrome**_ _and_ `false` _otherwise_. **Example 1:** **Input:** s = "code " **Output:** false **Example 2:** **Input:** s = "aab " **Output:** true **Example 3:** **Input:** s = "carerac " **Output:** true **Constraints:** ...
Consider the palindromes of odd vs even length. What difference do you notice? Count the frequency of each character. If each character occurs even number of times, then it must be a palindrome. How about character which occurs odd number of times?
Hash Table,String,Bit Manipulation
Easy
5,242,267,409
1,466
hey guys welcome back to the core Matt today's problem is reorder routes it's one of the weekly code elite core coding challenge problem before we proceed if you are new to the Channel please to subscribe we solves a lot of competitive problems let's start with the problems so problem says is there are n cities number ...
Reorder Routes to Make All Paths Lead to the City Zero
jump-game-v
There are `n` cities numbered from `0` to `n - 1` and `n - 1` roads such that there is only one way to travel between two different cities (this network form a tree). Last year, The ministry of transport decided to orient the roads in one direction because they are too narrow. Roads are represented by `connections` wh...
Use dynamic programming. dp[i] is max jumps you can do starting from index i. Answer is max(dp[i]). dp[i] = 1 + max (dp[j]) where j is all indices you can reach from i.
Array,Dynamic Programming,Sorting
Hard
2001
1,662
hi my name is david today we're going to do number one six two check if two strings arrays are equivalent so basically we get input over array word one and this is the values in it and there's word two and these are the values in it and when you concatenate these values together inside of it the first array is abc and ...
Check If Two String Arrays are Equivalent
minimum-numbers-of-function-calls-to-make-target-array
Given two string arrays `word1` and `word2`, return `true` _if the two arrays **represent** the same string, and_ `false` _otherwise._ A string is **represented** by an array if the array elements concatenated **in order** forms the string. **Example 1:** **Input:** word1 = \[ "ab ", "c "\], word2 = \[ "a ", "bc "...
Work backwards: try to go from nums to arr. You should try to divide by 2 as much as possible, but you can only divide by 2 if everything is even.
Array,Greedy
Medium
null
240
Search these 2d matrix. In this problem we have been given a 2d matrix. Your tour matrix is ​​provisioned and Your tour matrix is ​​provisioned and Your tour matrix is ​​provisioned and in the column wise matrix you will be asked to search a target element like we are asked to search five. If that element is present in...
Search a 2D Matrix II
search-a-2d-matrix-ii
Write an efficient algorithm that searches for a value `target` in an `m x n` integer matrix `matrix`. This matrix has the following properties: * Integers in each row are sorted in ascending from left to right. * Integers in each column are sorted in ascending from top to bottom. **Example 1:** **Input:** matri...
null
Array,Binary Search,Divide and Conquer,Matrix
Medium
74
315
Hello friends today I will discuss your problems from reading and on for all want to thank you Radhe Nobleman Response on the comedy Vikas Walking in the snow tune of modifications of 214 site which produced when the problem set on the playlist and not enter semis Of Solving Problems Dig At The Best Problems Will Win T...
Count of Smaller Numbers After Self
count-of-smaller-numbers-after-self
Given an integer array `nums`, return _an integer array_ `counts` _where_ `counts[i]` _is the number of smaller elements to the right of_ `nums[i]`. **Example 1:** **Input:** nums = \[5,2,6,1\] **Output:** \[2,1,1,0\] **Explanation:** To the right of 5 there are **2** smaller elements (2 and 1). To the right of 2 the...
null
Array,Binary Search,Divide and Conquer,Binary Indexed Tree,Segment Tree,Merge Sort,Ordered Set
Hard
327,406,493,1482,2280
309
hey there and welcome back to another Lee code prom So today we're going to do a popular problem it's going to be the best time to buy and sell stock with cooldown so this is a continuation of the easy problem which is just best time to buy and sell stock but now the thing we're given is we can complete as many transac...
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
1,043
hey everyone welcome back and let's write some more neat code today so today let's solve the problem partition array for maximum sum we're given an integer array it's guaranteed that all values in this array are going to be greater than or equal to zero and we want to split this array into subarrays so consider the arr...
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
890
Hai Hello Guys Welcome To Bana De Video Ne Sikhde Problem Final Play List Of Which Of The Following Is The What Is The Different From The Nation First India First Different From Next To Simple Question Subscribe Now To That Aaj Same To You Can observe the this what is the pattern beautiful pattern character is differen...
Find and Replace Pattern
lemonade-change
Given a list of strings `words` and a string `pattern`, return _a list of_ `words[i]` _that match_ `pattern`. You may return the answer in **any order**. A word matches the pattern if there exists a permutation of letters `p` so that after replacing every letter `x` in the pattern with `p(x)`, we get the desired word....
null
Array,Greedy
Easy
null
20
Hey friends welcome back tu and d video and in this video we will see valid parentheses so this is easy level problem in which it is saying that we will get a string and some string will contain only brackets and these will contain three types of brackets first parentheses And these curly brackets and square brackets a...
Valid Parentheses
valid-parentheses
Given a string `s` containing just the characters `'('`, `')'`, `'{'`, `'}'`, `'['` and `']'`, determine if the input string is valid. An input string is valid if: 1. Open brackets must be closed by the same type of brackets. 2. Open brackets must be closed in the correct order. 3. Every close bracket has a corres...
An interesting property about a valid parenthesis expression is that a sub-expression of a valid expression should also be a valid expression. (Not every sub-expression) e.g. { { } [ ] [ [ [ ] ] ] } is VALID expression [ [ [ ] ] ] is VALID sub-expression { } [ ] is VALID sub-express...
String,Stack
Easy
22,32,301,1045,2221
1,784
Have you welcome back tu another video and in this video we will do this program which is an easy level question so read this first so life is a binary string s without leading zeros return tu so a binary string will be given to us so mind is resting So now this is the same thing, there will be only zeros and ones on t...
Check if Binary String Has at Most One Segment of Ones
minimum-initial-energy-to-finish-tasks
Given a binary string `s` **​​​​​without leading zeros**, return `true`​​​ _if_ `s` _contains **at most one contiguous segment of ones**_. Otherwise, return `false`. **Example 1:** **Input:** s = "1001 " **Output:** false **Explanation:** The ones do not form a contiguous segment. **Example 2:** **Input:** s = "1...
We can easily figure that the f(x) : does x solve this array is monotonic so binary Search is doable Figure a sorting pattern
Array,Greedy,Sorting
Hard
null
451
today we will solve lead code problem number 451 and it's uh sorting the characters of a string by frequency of occurrence in that string and this has been asked quite a few times in interviews of google microsoft and uber and even linkedin so let's see how we will approach this problem so let's say you are given this ...
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
1,513
hello viewers welcome to a coding interface channel hope you are doing great if you haven't subscribed to my channel yet please go ahead and subscribe I have created bunch of playlists to cover various categories of problems such as BFS DFS dynamic programming stacks queues link lists and so on please check them out I ...
Number of Substrings With Only 1s
find-all-good-strings
Given a binary string `s`, return _the number of substrings with all characters_ `1`_'s_. Since the answer may be too large, return it modulo `109 + 7`. **Example 1:** **Input:** s = "0110111 " **Output:** 9 **Explanation:** There are 9 substring in total with only 1's characters. "1 " -> 5 times. "11 " -> 3 times...
Use DP with 4 states (pos: Int, posEvil: Int, equalToS1: Bool, equalToS2: Bool) which compute the number of valid strings of size "pos" where the maximum common suffix with string "evil" has size "posEvil". When "equalToS1" is "true", the current valid string is equal to "S1" otherwise it is greater. In a similar way w...
String,Dynamic Programming,String Matching
Hard
null
1,046
The first question of Today 15 is what is given in the last, like here we have stones, so this is the weight of the stones, it is telling the weight of 274181, so what is being said in this is that the game is being played in this, like in this first two We will find out the weight of the highest stone, like in this, w...
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
1,579
hello this is cpedit and in this video we'll be solving the remove max number of edges to keep graph fully traversable problem this problem appeared in weekly contest 205 of lead code so let's get started so in this problem we are given a graph which has three types of edges so red type of edges can be traversed by onl...
Remove Max Number of Edges to Keep Graph Fully Traversable
active-users
Alice and Bob have an undirected graph of `n` nodes and three types of edges: * Type 1: Can be traversed by Alice only. * Type 2: Can be traversed by Bob only. * Type 3: Can be traversed by both Alice and Bob. Given an array `edges` where `edges[i] = [typei, ui, vi]` represents a bidirectional edge of type `typ...
null
Database
Medium
null
146
hey friends today let's do leave code number 146 LRU cache and this problem is to design and implement a data structure for least recently used cache and we will provide two operations get and put if the key doesn't exist when you get then we return negative one and if we keep putting key value pairs in the cache and i...
LRU Cache
lru-cache
Design a data structure that follows the constraints of a **[Least Recently Used (LRU) cache](https://en.wikipedia.org/wiki/Cache_replacement_policies#LRU)**. Implement the `LRUCache` class: * `LRUCache(int capacity)` Initialize the LRU cache with **positive** size `capacity`. * `int get(int key)` Return the valu...
null
Hash Table,Linked List,Design,Doubly-Linked List
Medium
460,588,604,1903
1,248
Is everyone new problem on sliding window approach was this count number of nice now I started the problem why called sliding window because we are doing problems of sliding window in this entire play list you are yet to identify I hope there will be more and If you haven't come then please do it for wet cases. If you ...
Count Number of Nice Subarrays
binary-tree-coloring-game
Given an array of integers `nums` and an integer `k`. A continuous subarray is called **nice** if there are `k` odd numbers on it. Return _the number of **nice** sub-arrays_. **Example 1:** **Input:** nums = \[1,1,2,1,1\], k = 3 **Output:** 2 **Explanation:** The only sub-arrays with 3 odd numbers are \[1,1,2,1\] an...
The best move y must be immediately adjacent to x, since it locks out that subtree. Can you count each of (up to) 3 different subtrees neighboring x?
Tree,Depth-First Search,Binary Tree
Medium
null
51
hello and welcome to another Elite code solution video this is problem number 51 end Queens the end Queens puzzle is the problem of placing n Queens on an end byend chess board such that no two queens can attack each other given an integer n return all distinct solutions to the N Queen's puzzle you may return the answe...
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
282
hey guys how you doing this is Jay sir who's not good algorithms today I'm going to take a look at two a two expression ad operators we're given a string that contains only digits and the target value returned all possibilities add binary operators plus minus and multiply between the digits so they could evaluate to th...
Expression Add Operators
expression-add-operators
Given a string `num` that contains only digits and an integer `target`, return _**all possibilities** to insert the binary operators_ `'+'`_,_ `'-'`_, and/or_ `'*'` _between the digits of_ `num` _so that the resultant expression evaluates to the_ `target` _value_. Note that operands in the returned expressions **shoul...
Note that a number can contain multiple digits. Since the question asks us to find all of the valid expressions, we need a way to iterate over all of them. (Hint: Recursion!) We can keep track of the expression string and evaluate it at the very end. But that would take a lot of time. Can we keep track of the expressio...
Math,String,Backtracking
Hard
150,224,227,241,494
396
all right am i live in life believe so hello all right so this is going to be pretty short but i just very quickly want to come back to this question because i noticed something um we were just like okay so i coded out a slightly different solution and it's not really that much different probably not at all but we did ...
Rotate Function
rotate-function
You are given an integer array `nums` of length `n`. Assume `arrk` to be an array obtained by rotating `nums` by `k` positions clock-wise. We define the **rotation function** `F` on `nums` as follow: * `F(k) = 0 * arrk[0] + 1 * arrk[1] + ... + (n - 1) * arrk[n - 1].` Return _the maximum value of_ `F(0), F(1), ...,...
null
Array,Math,Dynamic Programming
Medium
null
306
today we're gonna be working on lead quote question number three zero six uh additive number uh an additive number of the string whose digits uh can form an additive sequence a valid additive sequence should contain at least three numbers except for the first two numbers and each subsequent number in the sequence must ...
Additive Number
additive-number
An **additive number** is a string whose digits can form an **additive sequence**. A valid **additive sequence** should contain **at least** three numbers. Except for the first two numbers, each subsequent number in the sequence must be the sum of the preceding two. Given a string containing only digits, return `true...
null
String,Backtracking
Medium
872
1,171
all right so hello and welcome on to the next question we'll keep going take a few seconds to make sure the audio is working this is going to be all right so hello and welcome on to the next out the chat already this is going to be remove Zero Sum consecutive actually I don't know what the whole question is um remove Z...
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
11
Hello everybody welcome back today we're taking a look at the leite code problem number 11 container with most water so this problem's actually pretty straightforward we're given an array of Heights or height declared right here and using this array of heights we're expected to find the largest area that we can form wi...
Container With Most Water
container-with-most-water
You are given an integer array `height` of length `n`. There are `n` vertical lines drawn such that the two endpoints of the `ith` line are `(i, 0)` and `(i, height[i])`. Find two lines that together with the x-axis form a container, such that the container contains the most water. Return _the maximum amount of water...
The aim is to maximize the area formed between the vertical lines. The area of any container is calculated using the shorter line as length and the distance between the lines as the width of the rectangle. Area = length of shorter vertical line * distance between lines We can definitely get the maximum width ...
Array,Two Pointers,Greedy
Medium
42
638
okay six three eight chopping offers in the coat store there are some kinds of items to sell each item has a price however there are some special alloys and a special offer consists of one or more different kind of items of a sales price you're given each item supplies a set of special offers and the number we need to ...
Shopping Offers
shopping-offers
In LeetCode Store, there are `n` items to sell. Each item has a price. However, there are some special offers, and a special offer consists of one or more different kinds of items with a sale price. You are given an integer array `price` where `price[i]` is the price of the `ith` item, and an integer array `needs` whe...
null
Array,Dynamic Programming,Backtracking,Bit Manipulation,Memoization,Bitmask
Medium
null
1,897
okay so hello so today we'll be solving lead C question 1897 uh that is a redistributable characters to make all strings equal and in this we'll be given a string or array of strings words uh and in one operation we can pick up two dist indexes that is I G where words I is a non-limited I G where words I is a non-limit...
Redistribute Characters to Make All Strings Equal
maximize-palindrome-length-from-subsequences
You are given an array of strings `words` (**0-indexed**). In one operation, pick two **distinct** indices `i` and `j`, where `words[i]` is a non-empty string, and move **any** character from `words[i]` to **any** position in `words[j]`. Return `true` _if you can make **every** string in_ `words` _**equal** using **a...
Let's ignore the non-empty subsequence constraint. We can concatenate the two strings and find the largest palindromic subsequence with dynamic programming. Iterate through every pair of characters word1[i] and word2[j], and see if some palindrome begins with word1[i] and ends with word2[j]. This ensures that the subse...
String,Dynamic Programming
Hard
516
127
hello so today you are doing this with called problem medium problem 127 world ladder and the problem says that given two words begin word and end word and the dictionary of word lists we want to find the length of the shortest transformation sequence between the beginning begin word and the end word this could have a ...
Word Ladder
word-ladder
A **transformation sequence** from word `beginWord` to word `endWord` using a dictionary `wordList` is a sequence of words `beginWord -> s1 -> s2 -> ... -> sk` such that: * Every adjacent pair of words differs by a single letter. * Every `si` for `1 <= i <= k` is in `wordList`. Note that `beginWord` does not need ...
null
Hash Table,String,Breadth-First Search
Hard
126,433
1,044
hello everyone I am Eric today I want to talk about the Eco Challenge can't win 16 long kill duplicates substring in this problem we want to find the longest duplicate substring of a given input for example for this is Benina and we have some two cakes too in such as a because we have three ie here eight they mean a ei...
Longest Duplicate Substring
find-common-characters
Given a string `s`, consider all _duplicated substrings_: (contiguous) substrings of s that occur 2 or more times. The occurrences may overlap. Return **any** duplicated substring that has the longest possible length. If `s` does not have a duplicated substring, the answer is `" "`. **Example 1:** **Input:** s = "ba...
null
Array,Hash Table,String
Easy
350
1,733
hey guys what's up this is steve today let's go through legal problem 1733 minimum number of people to teach and this is a pretty interesting problem a lot of people dislike it i think this is the problem that happened during one of the contests lately uh you see like five times more than five times some people dislike...
Minimum Number of People to Teach
maximum-number-of-visible-points
On a social network consisting of `m` users and some friendships between users, two users can communicate with each other if they know a common language. You are given an integer `n`, an array `languages`, and an array `friendships` where: * There are `n` languages numbered `1` through `n`, * `languages[i]` is th...
Sort the points by polar angle with the original position. Now only a consecutive collection of points would be visible from any coordinate. We can use two pointers to keep track of visible points for each start point For handling the cyclic condition, it’d be helpful to append the point list to itself after sorting.
Array,Math,Geometry,Sliding Window,Sorting
Hard
null
64
hey guys what's up everyone so in this video we'll discuss about the part 2 for minimum path song so in case here in was the part 1 you can just go in the description section I'll just link it down over there so initially it wasn't planning on introducing a second part for this question but actually this is a very intr...
Minimum Path Sum
minimum-path-sum
Given a `m x n` `grid` filled with non-negative numbers, find a path from top left to bottom right, which minimizes the sum of all numbers along its path. **Note:** You can only move either down or right at any point in time. **Example 1:** **Input:** grid = \[\[1,3,1\],\[1,5,1\],\[4,2,1\]\] **Output:** 7 **Explanat...
null
Array,Dynamic Programming,Matrix
Medium
62,174,741,2067,2192
461
hey guys welcome back to another video and today we're going to be solving the lead code question Hamming distance so as usual first we're going to go over the logic behind the question and then we're going to write Python code to solve it okay so the Hamming distance between two integers is a number of positions at wh...
Hamming Distance
hamming-distance
The [Hamming distance](https://en.wikipedia.org/wiki/Hamming_distance) between two integers is the number of positions at which the corresponding bits are different. Given two integers `x` and `y`, return _the **Hamming distance** between them_. **Example 1:** **Input:** x = 1, y = 4 **Output:** 2 **Explanation:** 1...
null
Bit Manipulation
Easy
191,477
1,624
what's up everyone welcome back to lead coding in this video we will be solving the problem largest substring between two equal characters so the name of the problem itself is sufficient to describe the problem we are given a string s and we have to return the largest size of the substring which is present between two ...
Largest Substring Between Two Equal Characters
clone-binary-tree-with-random-pointer
Given a string `s`, return _the length of the longest substring between two equal characters, excluding the two characters._ If there is no such substring return `-1`. A **substring** is a contiguous sequence of characters within a string. **Example 1:** **Input:** s = "aa " **Output:** 0 **Explanation:** The optim...
Traverse the tree, keep a hashtable with you and create a nodecopy for each node in the tree. Start traversing the original tree again and connect the left, right and random pointers in the cloned tree the same way as the original tree with the help of the hashtable.
Hash Table,Tree,Depth-First Search,Breadth-First Search,Binary Tree
Medium
133,138,1634
744
hey everybody this is Larry this is day nine of the legal daily challenge hit the like button hit the Subscribe button join my Discord let me know what you think about today's prom I hope everyone's doing well I'm still in tashcan here in Uzbekistan um yeah let's look at this problem let's get it started um tired today...
Find Smallest Letter Greater Than Target
network-delay-time
You are given an array of characters `letters` that is sorted in **non-decreasing order**, and a character `target`. There are **at least two different** characters in `letters`. Return _the smallest character in_ `letters` _that is lexicographically greater than_ `target`. If such a character does not exist, return t...
We visit each node at some time, and if that time is better than the fastest time we've reached this node, we travel along outgoing edges in sorted order. Alternatively, we could use Dijkstra's algorithm.
Depth-First Search,Breadth-First Search,Graph,Heap (Priority Queue),Shortest Path
Medium
2151,2171
953
welcome to april's legal challenge today's problem is verifying an alien dictionary in an alien language surprisingly they also use english lowercase letters but possibly in a different order the order of the alphabet is some permutation of lowercase letters so here it is we have all the characters from a to z but it's...
Verifying an Alien Dictionary
reverse-only-letters
In an alien language, surprisingly, they also use English lowercase letters, but possibly in a different `order`. The `order` of the alphabet is some permutation of lowercase letters. Given a sequence of `words` written in the alien language, and the `order` of the alphabet, return `true` if and only if the given `wor...
This problem is exactly like reversing a normal string except that there are certain characters that we have to simply skip. That should be easy enough to do if you know how to reverse a string using the two-pointer approach.
Two Pointers,String
Easy
null
121
all right this lead code question is called best time to buy and sell stock it says say you have an array for which the eighth element is the price of a given stock on day I if you were only permitted to complete at most one transaction that is buy one and sell one share of the stock design an algorithm to find the max...
Best Time to Buy and Sell Stock
best-time-to-buy-and-sell-stock
You are given an array `prices` where `prices[i]` is the price of a given stock on the `ith` day. You want to maximize your profit by choosing a **single day** to buy one stock and choosing a **different day in the future** to sell that stock. Return _the maximum profit you can achieve from this transaction_. If you ...
null
Array,Dynamic Programming
Easy
53,122,123,188,309,2138,2144
318
hello guys welcome to another video in the series of coding today we are going to do the problem it's called maximum product of word length so you're given a string array words you have to return the maximum value of length of word of i into length of word of j where are two words do not share common letters and if no ...
Maximum Product of Word Lengths
maximum-product-of-word-lengths
Given a string array `words`, return _the maximum value of_ `length(word[i]) * length(word[j])` _where the two words do not share common letters_. If no such two words exist, return `0`. **Example 1:** **Input:** words = \[ "abcw ", "baz ", "foo ", "bar ", "xtfn ", "abcdef "\] **Output:** 16 **Explanation:** The two ...
null
Array,String,Bit Manipulation
Medium
null
155
yo what's up everybody how's it going so today we are going to solve the another coolest problem which is mean stack this problem is quite good so basically what we have to do in this problem we have to check whether like uh we have like we have to find the minimum value from the stack so how we gonna do is uh we will ...
Min Stack
min-stack
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. Implement the `MinStack` class: * `MinStack()` initializes the stack object. * `void push(int val)` pushes the element `val` onto the stack. * `void pop()` removes the element on the top of the stack. * `int top(...
Consider each node in the stack having a minimum value. (Credits to @aakarshmadhavan)
Stack,Design
Easy
239,716
902
hello everyone i hope all of you are having a great time over this weekend and now let's quickly talk about today's question is numbers at most n given digits lead code 902 it's a hard question on lead good and i would like to say that there is a very famous saying your hard work never goes in vain and that's true agai...
Numbers At Most N Given Digit Set
minimum-number-of-refueling-stops
Given an array of `digits` which is sorted in **non-decreasing** order. You can write numbers using each `digits[i]` as many times as we want. For example, if `digits = ['1','3','5']`, we may write numbers such as `'13'`, `'551'`, and `'1351315'`. Return _the number of positive integers that can be generated_ that are...
null
Array,Dynamic Programming,Greedy,Heap (Priority Queue)
Hard
null
70
elite code question 70 climb and stairs so you're climbing a staircase it takes n steps to reach the top each time you can either climb one or two steps in how many distinct ways can you climb to the top so the questions ask in four distinct ways the maximum amount of ways you can climb the stairs using either one or t...
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,814
hello guys and welcome back to lead Logics this is the count nice pairs in an array it is a lead code medium and the number for this is 1814 so in this question you are G given with an array nums that consist of non- with an array nums that consist of non- with an array nums that consist of non- negative integers and t...
Count Nice Pairs in an Array
jump-game-vi
You are given an array `nums` that consists of non-negative integers. Let us define `rev(x)` as the reverse of the non-negative integer `x`. For example, `rev(123) = 321`, and `rev(120) = 21`. A pair of indices `(i, j)` is **nice** if it satisfies all of the following conditions: * `0 <= i < j < nums.length` * `nu...
Let dp[i] be "the maximum score to reach the end starting at index i". The answer for dp[i] is nums[i] + max{dp[i+j]} for 1 <= j <= k. That gives an O(n*k) solution. Instead of checking every j for every i, keep track of the largest dp[i] values in a heap and calculate dp[i] from right to left. When the largest value i...
Array,Dynamic Programming,Queue,Sliding Window,Heap (Priority Queue),Monotonic Queue
Medium
239,2001
456
hey everyone welcome back today we are going to solve problem number four five six one three two pattern first we will see the exponential problem statement then the logic on the code now let's dive into the solution so in this problem we are given an input array nums and we need to find a one three two pattern right s...
132 Pattern
132-pattern
Given an array of `n` integers `nums`, a **132 pattern** is a subsequence of three integers `nums[i]`, `nums[j]` and `nums[k]` such that `i < j < k` and `nums[i] < nums[k] < nums[j]`. Return `true` _if there is a **132 pattern** in_ `nums`_, otherwise, return_ `false`_._ **Example 1:** **Input:** nums = \[1,2,3,4\] ...
null
Array,Binary Search,Stack,Monotonic Stack,Ordered Set
Medium
null
839
hey guys are your thing going this is yessir in this video I'm going to take a look at eight three nine similar string groups mmm the expression is very long two strings x and y are similar if we can swap two letters in different positions of X so that it equals to Y also two strings are similar if they are equal for e...
Similar String Groups
short-encoding-of-words
Two strings `X` and `Y` are similar if we can swap two letters (in different positions) of `X`, so that it equals `Y`. Also two strings `X` and `Y` are similar if they are equal. For example, `"tars "` and `"rats "` are similar (swapping at positions `0` and `2`), and `"rats "` and `"arts "` are similar, but `"star "`...
null
Array,Hash Table,String,Trie
Medium
null
1,062
hey what's up guys this is chong so today let's take a look at this list called problem 1062 longest repeating substring i think this is like a good interview question you know why is that because the description of the problem is easy but it can have a few follow-ups you but it can have a few follow-ups you but it can...
Longest Repeating Substring
partition-array-into-three-parts-with-equal-sum
Given a string `s`, return _the length of the longest repeating substrings_. If no repeating substring exists, return `0`. **Example 1:** **Input:** s = "abcd " **Output:** 0 **Explanation:** There is no repeating substring. **Example 2:** **Input:** s = "abbaba " **Output:** 2 **Explanation:** The longest repeat...
If we have three parts with the same sum, what is the sum of each? If you can find the first part, can you find the second part?
Array,Greedy
Easy
2102
104
given a binary tree can you write a program to find its maximum death that's today's video let's get into it hi everyone my name is Steve today we're going through a very classic interview problem or just computer science problem maximum depth of binary tree let's take a look at the problem description first given a bi...
Maximum Depth of Binary Tree
maximum-depth-of-binary-tree
Given the `root` of a binary tree, return _its maximum depth_. A binary tree's **maximum depth** is the number of nodes along the longest path from the root node down to the farthest leaf node. **Example 1:** **Input:** root = \[3,9,20,null,null,15,7\] **Output:** 3 **Example 2:** **Input:** root = \[1,null,2\] **...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Easy
110,111,774,1492
1,863
problem 1863 sum of all subset Z totals today's problem is in a way very simple but there has been a solution which I am not able to understand how it works but I do have solution this problem has several Solutions most of it is in order of n so we'll go through the question first and then I'll explain whatever I could...
Sum of All Subset XOR Totals
sum-of-all-subset-xor-totals
The **XOR total** of an array is defined as the bitwise `XOR` of **all its elements**, or `0` if the array is **empty**. * For example, the **XOR total** of the array `[2,5,6]` is `2 XOR 5 XOR 6 = 1`. Given an array `nums`, return _the **sum** of all **XOR totals** for every **subset** of_ `nums`. **Note:** Subset...
null
null
Easy
null
86
hello guys we're still grinding these lead code questions today we have partition list um lead code 86 very popular question it's been asked by Adobe Microsoft Apple Bloomberg wow even Google and Facebook have also asked it Amazon also wow okay that's impressive um that said this is a ling list question if you haven't ...
Partition List
partition-list
Given the `head` of a linked list and a value `x`, partition it such that all nodes **less than** `x` come before nodes **greater than or equal** to `x`. You should **preserve** the original relative order of the nodes in each of the two partitions. **Example 1:** **Input:** head = \[1,4,3,2,5,2\], x = 3 **Output:**...
null
Linked List,Two Pointers
Medium
2265
695
hey what's up guys Nick white here I do tech and coding stuff on twitch in YouTube and I just made this video uploaded it made the thumbnail and I have to redo it because I my face was in the way so now my face is on the left so hopefully you guys like that before I start this I'd say if you can support me on patreon p...
Max Area of Island
max-area-of-island
You are given an `m x n` binary matrix `grid`. An island is a group of `1`'s (representing land) connected **4-directionally** (horizontal or vertical.) You may assume all four edges of the grid are surrounded by water. The **area** of an island is the number of cells with a value `1` in the island. Return _the maxim...
null
Array,Depth-First Search,Breadth-First Search,Union Find,Matrix
Medium
200,463,1845,2206
414
hello uh so welcome to my YouTube channel this is my first video on YouTube so let's start our first YouTube video from a Le code question so the question is third maximum number in the question the given question statement is given an integer array that is nums and I have to return the third maximum number in the arra...
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
1,647
hey there everyone welcome back to lead coding in this video we are going to solve the question number two of lead code weekly contest 214 name of the problem is minimum deletion to make character frequencies unique also the solutions to other problems will be uploaded soon so subscribe to the channel and hit the bell ...
Minimum Deletions to Make Character Frequencies Unique
can-convert-string-in-k-moves
A string `s` is called **good** if there are no two different characters in `s` that have the same **frequency**. Given a string `s`, return _the **minimum** number of characters you need to delete to make_ `s` _**good**._ The **frequency** of a character in a string is the number of times it appears in the string. F...
Observe that shifting a letter x times has the same effect of shifting the letter x + 26 times. You need to check whether k is large enough to cover all shifts with the same remainder after modulo 26.
Hash Table,String
Medium
null
125
hello guys myself Amrita welcome back to our Channel techno Sage so in today's video we are going to discuss problem number 125 that is valid palindrome so let's get started let's first understand the problem a phrase is a palindrome if after converting all uppercase letters into lowercase letters and removing all non-...
Valid Palindrome
valid-palindrome
A phrase is a **palindrome** if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. Alphanumeric characters include letters and numbers. Given a string `s`, return `true` _if it is a **palindrome**, or_ `false` _otherwise_...
null
Two Pointers,String
Easy
234,680,2130,2231
1,776
hey what's up guys uh this is juan here so today uh this one number 1776 car fleet number two so they're like on cars traveling at the same direction right and then each cars each car has like the uh its current position and its current speed and different cars you know they can be they can collide to each other let's ...
Car Fleet II
minimum-operations-to-reduce-x-to-zero
There are `n` cars traveling at different speeds in the same direction along a one-lane road. You are given an array `cars` of length `n`, where `cars[i] = [positioni, speedi]` represents: * `positioni` is the distance between the `ith` car and the beginning of the road in meters. It is guaranteed that `positioni < ...
Think in reverse; instead of finding the minimum prefix + suffix, find the maximum subarray. Finding the maximum subarray is standard and can be done greedily.
Array,Hash Table,Binary Search,Sliding Window,Prefix Sum
Medium
209,560,2183,2290
1,878
hey everybody this is larry this is me going with you three getting the biggest rhombus sums in a grid even though i if you watch me on the video i can point that this is more like a diamond or something because this i mean all the links are the same it's still a squish just rotate it but in any case um hit the like bu...
Get Biggest Three Rhombus Sums in a Grid
check-if-array-is-sorted-and-rotated
You are given an `m x n` integer matrix `grid`​​​. A **rhombus sum** is the sum of the elements that form **the** **border** of a regular rhombus shape in `grid`​​​. The rhombus must have the shape of a square rotated 45 degrees with each of the corners centered in a grid cell. Below is an image of four valid rhombus ...
Brute force and check if it is possible for a sorted array to start from each position.
Array
Easy
2243
113
ki hey guys welcome back to my channel alarm back again with another interesting wedding interview question video festival solved 1382 off list subscribe my channel like programming and subscribe for latest videos like this and passed from delhi to know where the Total amount subscribe so 150 to do subscribe in a reade...
Path Sum II
path-sum-ii
Given the `root` of a binary tree and an integer `targetSum`, return _all **root-to-leaf** paths where the sum of the node values in the path equals_ `targetSum`_. Each path should be returned as a list of the node **values**, not node references_. A **root-to-leaf** path is a path starting from the root and ending at...
null
Backtracking,Tree,Depth-First Search,Binary Tree
Medium
112,257,437,666,2217
101
so the question is magic tree and you are giving a note 3 note and to check is the tree is mirror of itself and my idea is using a recursive and another method use preference search so let's try the recursive first so if the rule equal to no i just written false else i use the helper function to check left and right an...
Symmetric Tree
symmetric-tree
Given the `root` of a binary tree, _check whether it is a mirror of itself_ (i.e., symmetric around its center). **Example 1:** **Input:** root = \[1,2,2,3,4,4,3\] **Output:** true **Example 2:** **Input:** root = \[1,2,2,null,3,null,3\] **Output:** false **Constraints:** * The number of nodes in the tree is in...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Easy
null
497
in this problem we have a list of non-overlapping rectangles non-overlapping rectangles non-overlapping rectangles and we have to look at all the points that are included in those rectangles including at the boundary so we may have multiple rectangles like this but none of them will overlap and we have to consider only...
Random Point in Non-overlapping Rectangles
random-point-in-non-overlapping-rectangles
You are given an array of non-overlapping axis-aligned rectangles `rects` where `rects[i] = [ai, bi, xi, yi]` indicates that `(ai, bi)` is the bottom-left corner point of the `ith` rectangle and `(xi, yi)` is the top-right corner point of the `ith` rectangle. Design an algorithm to pick a random integer point inside th...
null
null
Medium
null
2
in this problem we are given two numbers and these numbers are represented in the form of linked list so digits are represented in the form of linked lists and we have two of those and we have to find the sum for example for this case the sum will be represented by another list and the numbers are in reverse order so l...
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
228
so written the small is sorted list of ranges that cover all the numbers in the array exactly so that is each of the element in the array is covered exactly by one of its ranges and there is no uh integer should be in the range such that it's not present in the array as well so let's understand the problem with an exam...
Summary Ranges
summary-ranges
You are given a **sorted unique** integer array `nums`. A **range** `[a,b]` is the set of all integers from `a` to `b` (inclusive). Return _the **smallest sorted** list of ranges that **cover all the numbers in the array exactly**_. That is, each element of `nums` is covered by exactly one of the ranges, and there is...
null
Array
Easy
163,352
202
this problem is called happy member a happy number is a number can be defined by the following process firstly star was a positive integer and the replaced and number by the sum of the squares of its digits if can end in one and they did a happy number otherwise it is not for example the given number is 19 first the st...
Happy Number
happy-number
Write an algorithm to determine if a number `n` is happy. A **happy number** is a number defined by the following process: * Starting with any positive integer, replace the number by the sum of the squares of its digits. * Repeat the process until the number equals 1 (where it will stay), or it **loops endlessly ...
null
Hash Table,Math,Two Pointers
Easy
141,258,263,2076
1,578
hello and welcome back to lead coding on this channel we discuss problems which are frequently asked in programming interviews today we are here with the problem minimum deletion cost to avoid repeating letters we are given a string s and array of integers cost where cost i is the cost of deletion of the character i in...
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,309
yeahyeah yeah Hi everyone, I'm a programmer. Today I will introduce to you a problem called decoding a string from a reference between characters and numbers. The following request gives us a string s. This string is composed of non-key characters and Thang characters. We non-key characters and Thang characters. We non...
Decrypt String from Alphabet to Integer Mapping
sort-items-by-groups-respecting-dependencies
You are given a string `s` formed by digits and `'#'`. We want to map `s` to English lowercase characters as follows: * Characters (`'a'` to `'i'`) are represented by (`'1'` to `'9'`) respectively. * Characters (`'j'` to `'z'`) are represented by (`'10#'` to `'26#'`) respectively. Return _the string formed after ...
Think of it as a graph problem. We need to find a topological order on the dependency graph. Build two graphs, one for the groups and another for the items.
Depth-First Search,Breadth-First Search,Graph,Topological Sort
Hard
null
162
welcome in this session we are going to discuss about one of the simple coding example from lead code find peak element from given array of inputs what is peak element as per the problem statement a peak element is an element that is strictly greater than its neighbors for example here is an input array 3 is a peak ele...
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
582
hello and welcome back to the cracking fang youtube channel today we're going to be solving lead code problem 582 kill process you have n processes forming a rooted tree structure you are given two integers array pid and ppid where pid of i is the id of the ith process and ppid is the id of the ith processes parent pro...
Kill Process
kill-process
You have `n` processes forming a rooted tree structure. You are given two integer arrays `pid` and `ppid`, where `pid[i]` is the ID of the `ith` process and `ppid[i]` is the ID of the `ith` process's parent process. Each process has only **one parent process** but may have multiple children processes. Only one process...
null
Array,Hash Table,Tree,Depth-First Search,Breadth-First Search
Medium
null
1
and guys, all beauty again today I'm going to show you how to solve the number one problem of Cold milk and this type of problem you will find out there and with different phrases in the colors of the Light of life in the thighs of life beauty don't underestimate This problem is a very simple problem but full of banana...
Two Sum
two-sum
Given an array of integers `nums` and an integer `target`, return _indices of the two numbers such that they add up to `target`_. You may assume that each input would have **_exactly_ one solution**, and you may not use the _same_ element twice. You can return the answer in any order. **Example 1:** **Input:** nums...
A really brute force way would be to search for all possible pairs of numbers but that would be too slow. Again, it's best to try out brute force solutions for just for completeness. It is from these brute force solutions that you can come up with optimizations. So, if we fix one of the numbers, say x, we have to scan ...
Array,Hash Table
Easy
15,18,167,170,560,653,1083,1798,1830,2116,2133,2320
98
everyone welcome back and let's write some more neat code today solving validate binary search a very good question for practicing binary search tree questions we're just given a root of a binary search tree and we just want to determine is it a valid binary search tree or not and from learning data structures and algo...
Validate Binary Search Tree
validate-binary-search-tree
Given the `root` of a binary tree, _determine if it is a valid binary search tree (BST)_. A **valid BST** is defined as follows: * The left subtree of a node contains only nodes with keys **less than** the node's key. * The right subtree of a node contains only nodes with keys **greater than** the node's key. * ...
null
Tree,Depth-First Search,Binary Search Tree,Binary Tree
Medium
94,501
131
good evening everyone today we are going to do the daily lead code challenge of 22nd January 2020 that is question number 131 palindrome partitioning so this week lead code challenges are all about backtracking and if I watched the previous videos this question will be very easy for you so the question is saying that y...
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
745
hello everyone welcome to coders camp so we are the first day of may liko challenge and the problem we are going to cover is prefix and suffix search so here the input given is a dictionary with words or strings and an f where the starting or the prefix and suffix of any word in the dictionary and we have to return the...
Prefix and Suffix Search
find-smallest-letter-greater-than-target
Design a special dictionary that searches the words in it by a prefix and a suffix. Implement the `WordFilter` class: * `WordFilter(string[] words)` Initializes the object with the `words` in the dictionary. * `f(string pref, string suff)` Returns _the index of the word in the dictionary,_ which has the prefix `p...
Try to find whether each of 26 next letters are in the given string array.
Array,Binary Search
Easy
2269
376
hello everyone welcome to learn how pro in this video we will discuss about another liquid problem that is the wiggle subsequence the question is the medium level question and we will understand how we can what the question is actually saying to us and how we can solve a question like this but before moving into the qu...
Wiggle Subsequence
wiggle-subsequence
A **wiggle sequence** is a sequence where the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either positive or negative. A sequence with one element and a sequence with two non-equal elements are trivially wiggle sequences. * For ...
null
Array,Dynamic Programming,Greedy
Medium
2271
1,394
looking at question one three nine four find lucky integer in an array so basically what this question is saying is that we are supposed to figure out if there are there is an and there is or our numbers in an array where it's the same frequency as the number itself so in this case we return 2 because this 2 appears tw...
Find Lucky Integer in an Array
find-lucky-integer-in-an-array
Given an array of integers `arr`, a **lucky integer** is an integer that has a frequency in the array equal to its value. Return _the largest **lucky integer** in the array_. If there is no **lucky integer** return `-1`. **Example 1:** **Input:** arr = \[2,2,3,4\] **Output:** 2 **Explanation:** The only lucky number...
null
null
Easy
null
179
Jhal Hello Hi Guys Welcome To Dad Today's Question Is The Largest Number In This Question Of Interest I Am List Of Nativity 10 Best Valentines Day Gifts For The Largest Number For Example In This Where Given Pennant Do Kal Subah To Amresh Two Numbers Between For The Largest Number of Frequency Reddy Number for Doing De...
Largest Number
largest-number
Given a list of non-negative integers `nums`, arrange them such that they form the largest number and return it. Since the result may be very large, so you need to return a string instead of an integer. **Example 1:** **Input:** nums = \[10,2\] **Output:** "210 " **Example 2:** **Input:** nums = \[3,30,34,5,9\] *...
null
String,Greedy,Sorting
Medium
2284
1,735
hey what's up guys this is jung so let's take a look at 1735 common ways to make array of this product and so this one is like a it's simply a math problem whereas to be more specific this is like a combinatoric problem basically you're given like a queries and on each of the queries they're like two elements the first...
Count Ways to Make Array With Product
the-most-frequently-ordered-products-for-each-customer
You are given a 2D integer array, `queries`. For each `queries[i]`, where `queries[i] = [ni, ki]`, find the number of different ways you can place positive integers into an array of size `ni` such that the product of the integers is `ki`. As the number of ways may be too large, the answer to the `ith` query is the numb...
null
Database
Medium
1688
318
okay 318 maximum product of word links Kim Yuna stirring away words find a maximum while your link of work supply times link of word sub J where two words do not share common that is you may assume each word will contain only lowercase that is if no such word excess returns zero okay so number one kind of comment is th...
Maximum Product of Word Lengths
maximum-product-of-word-lengths
Given a string array `words`, return _the maximum value of_ `length(word[i]) * length(word[j])` _where the two words do not share common letters_. If no such two words exist, return `0`. **Example 1:** **Input:** words = \[ "abcw ", "baz ", "foo ", "bar ", "xtfn ", "abcdef "\] **Output:** 16 **Explanation:** The two ...
null
Array,String,Bit Manipulation
Medium
null
76
hey guys how's everything going today that's continued to our continue our adventure elite code let's take a look at number 76 minimum windows substring or giving a string and a string find the minimum window in s which will contain all the characters in T in a complexity of Oh N hmm like this for ABC the minimum stren...
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
524
Hello hi guys welcome to girls Video give see the question longest word in dictionary deleted from the longest word in love with us the Vedas and input all on the other hand present and lexicographical small scale and poor see how to point to the dictionary subscribe and subscribe The Channel Ko Ki Police Ko One By One...
Longest Word in Dictionary through Deleting
longest-word-in-dictionary-through-deleting
Given a string `s` and a string array `dictionary`, return _the longest string in the dictionary that can be formed by deleting some of the given string characters_. If there is more than one possible result, return the longest word with the smallest lexicographical order. If there is no possible result, return the emp...
null
Array,Two Pointers,String,Sorting
Medium
720
231
Hello everyone welcome to my channel code sari with mike so today we are going to do video number 21 of our lead code easy playlist, okay and generally such question is right for phone interview or good practice problem, lead number is marked 231 easy and This question is asked by many people who are very approachable....
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
371
Hello everyone welcome to our coders in this video we will solve our blind 75 lead code problem number 11 which is sum of two integers so let's go to our problem and see what our problem is. Our today's problem is sum of two integers given two integers A and B return the sum of two integers without using the plus and m...
Sum of Two Integers
sum-of-two-integers
Given two integers `a` and `b`, return _the sum of the two integers without using the operators_ `+` _and_ `-`. **Example 1:** **Input:** a = 1, b = 2 **Output:** 3 **Example 2:** **Input:** a = 2, b = 3 **Output:** 5 **Constraints:** * `-1000 <= a, b <= 1000`
null
Math,Bit Manipulation
Medium
2
1,020
Happened and happy life Today they are going to solve some plate problem will select medium problem it is not to do subscribe to that ripe so let's be question a different solution specific playlist one phone number in this affects media mendis and kaisi ghanta questions and manners In the mid day it's year this roti p...
Number of Enclaves
longest-turbulent-subarray
You are given an `m x n` binary matrix `grid`, where `0` represents a sea cell and `1` represents a land cell. A **move** consists of walking from one land cell to another adjacent (**4-directionally**) land cell or walking off the boundary of the `grid`. Return _the number of land cells in_ `grid` _for which we cann...
null
Array,Dynamic Programming,Sliding Window
Medium
53