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
510
hey how's it going so today we're gonna do record in other successor mbst um two of so this question so given a note in the binary search should you find the in order successor that of that note in the bst if that node has no in order successor return none on the successor of a node is the node with the smallest key gr...
Inorder Successor in BST II
count-subarrays-with-more-ones-than-zeros
Given a `node` in a binary search tree, return _the in-order successor of that node in the BST_. If that node has no in-order successor, return `null`. The successor of a `node` is the node with the smallest key greater than `node.val`. You will have direct access to the node but not to the root of the tree. Each nod...
Change the zeros in nums to -1 and create a prefix sum array prefixSum using the new nums. If prefixSum[i] for any index i in the range 0 <= i < prefixSum.length is positive, that means that there are more ones than zeros in the prefix ending at index i. If prefixSum[j] > prefixSum[i] for two indexes i and j such that ...
Array,Binary Search,Divide and Conquer,Binary Indexed Tree,Segment Tree,Merge Sort,Ordered Set
Medium
474,1999,2261
1,377
Loot hello welcome to this list dot problem holidays subscribe and subscribe the channel questions related to follow subscribe my channel subscribe the one more that and you know the prime president don't forget to subscribe on thursday subscribe the channel Subscribe Must Subscribe To That A Atm Sabse 65 Years To That...
Frog Position After T Seconds
number-of-comments-per-post
Given an undirected tree consisting of `n` vertices numbered from `1` to `n`. A frog starts jumping from **vertex 1**. In one second, the frog jumps from its current vertex to another **unvisited** vertex if they are directly connected. The frog can not jump back to a visited vertex. In case the frog can jump to severa...
null
Database
Easy
null
113
Hello Everyone Welcome to the Video You Will Be Discussing Network Problem 95 Samudra Problems Ek Incident Jeevan Root of Binary Tree and Vitamin Enriched Turn on the Road to Leaf and Steel Workers Subscribe Bhi Problem Aaye Tree subscribe to the Page if you liked The Video then subscribe to the Page व्यापाट सोना विल न...
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
354
Hello Everyone Welcome to my YouTube Channel and Question for today is Russian Doll and Electronic Tubelight Ude Re Open Teachers in Vallabh Vya Everywhere you have to go to two states today are short tricks with jam The accident on the Light of and always present at the highest Position with solve Vasundhar them job i...
Russian Doll Envelopes
russian-doll-envelopes
You are given a 2D array of integers `envelopes` where `envelopes[i] = [wi, hi]` represents the width and the height of an envelope. One envelope can fit into another if and only if both the width and height of one envelope are greater than the other envelope's width and height. Return _the maximum number of envelope...
null
Array,Binary Search,Dynamic Programming,Sorting
Hard
300,2123
209
hello everyone welcome to another lit code so today we'll be doing a medium question which is the minimum size sub-array sum sub-array sum sub-array sum so given an array of positive integers and a positive integer which is called target we have to return the minimal length of a contiguous subarray so that means that t...
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
384
hello friends so today we're gonna discuss this question on the it code problem number 384 shuffle and hairy so in this question you are given inputted and edit and you have to make three two functions actually the first function should return the original edit and the second function should return a shuffle form of th...
Shuffle an Array
shuffle-an-array
Given an integer array `nums`, design an algorithm to randomly shuffle the array. All permutations of the array should be **equally likely** as a result of the shuffling. Implement the `Solution` class: * `Solution(int[] nums)` Initializes the object with the integer array `nums`. * `int[] reset()` Resets the arr...
The solution expects that we always use the original array to shuffle() else some of the test cases fail. (Credits; @snehasingh31)
Array,Math,Randomized
Medium
null
963
hi guys welcome to go to pro today we're going to be looking at another lead chord problem seems to be a pattern um called minimum area rectangle 2. we're given a x y plane with a bunch of points we need to figure out whether some of these points form a rectangle if they do we need to figure out which one of these rect...
Minimum Area Rectangle II
three-equal-parts
You are given an array of points in the **X-Y** plane `points` where `points[i] = [xi, yi]`. Return _the minimum area of any rectangle formed from these points, with sides **not necessarily parallel** to the X and Y axes_. If there is not any such rectangle, return `0`. Answers within `10-5` of the actual answer will...
null
Array,Math
Hard
null
1,463
hello friends so today we can discuss very important problem from lead code problem name cherry pick up two it is a problem which is of a hard version from lead code and this is based on dynamic programming i'm telling you in upfront but let's first understand the problem statement and try to devise a method to solve t...
Cherry Pickup II
the-k-weakest-rows-in-a-matrix
You are given a `rows x cols` matrix `grid` representing a field of cherries where `grid[i][j]` represents the number of cherries that you can collect from the `(i, j)` cell. You have two robots that can collect cherries for you: * **Robot #1** is located at the **top-left corner** `(0, 0)`, and * **Robot #2** is...
Sort the matrix row indexes by the number of soldiers and then row indexes.
Array,Binary Search,Sorting,Heap (Priority Queue),Matrix
Easy
null
1,361
Hello everyone welcome to my channel code sari with mike so today we are going to do video number 30 of our binary tree playlist lead code number 1361 is a medium level question but it is quite easy this question is a simple observation and we will make it approachable. That is, you have n notes of the binary tree whic...
Validate Binary Tree Nodes
tiling-a-rectangle-with-the-fewest-squares
You have `n` binary tree nodes numbered from `0` to `n - 1` where node `i` has two children `leftChild[i]` and `rightChild[i]`, return `true` if and only if **all** the given nodes form **exactly one** valid binary tree. If node `i` has no left child then `leftChild[i]` will equal `-1`, similarly for the right child. ...
Can you use backtracking to solve this problem ?. Suppose you've placed a bunch of squares. Where is the natural spot to place the next square ?. The maximum number of squares to be placed will be ≤ max(n,m).
Dynamic Programming,Backtracking
Hard
null
1,942
hey everybody thank you so today i'm going to talk about a question it's from the pipe working contest as that saturday question two so it's question 1942 number of the smallest architecture let's look at the description first there's a party where inference number from zero to n minus one are attending there's an infi...
The Number of the Smallest Unoccupied Chair
primary-department-for-each-employee
There is a party where `n` friends numbered from `0` to `n - 1` are attending. There is an **infinite** number of chairs in this party that are numbered from `0` to `infinity`. When a friend arrives at the party, they sit on the unoccupied chair with the **smallest number**. * For example, if chairs `0`, `1`, and `5...
null
Database
Easy
null
315
uh today we're gonna be working on lead quote question number 315 count of smaller numbers after ourselves and given an integer area numbers return an integer array counts where counts of i is the number of smaller elements to the right of numbers of i so if we have been given five to six one uh the answer is going to ...
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
1,909
hello let's talk about a remove one element to make a r quickly increasing so yeah pretty straight forward you can only remove one at most one the element to make a r strictly increasing if there are more than one you return false so what does increasing mean you want to make sure list satisfied so less than equal like...
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
152
welcome back to our jest today's question is leak code 152 maximum product submarine so we're given an array nums find a contiguous non-empty array nums find a contiguous non-empty array nums find a contiguous non-empty subarray with the array that has the largest product and return that product a subarray is a contigu...
Maximum Product Subarray
maximum-product-subarray
Given an integer array `nums`, find a subarray that has the largest product, and return _the product_. The test cases are generated so that the answer will fit in a **32-bit** integer. **Example 1:** **Input:** nums = \[2,3,-2,4\] **Output:** 6 **Explanation:** \[2,3\] has the largest product 6. **Example 2:** **I...
null
Array,Dynamic Programming
Medium
53,198,238,628,713
1,025
welcome guys uh so this problem uh let me self a legal section one two five but before i start please be uh be sure to uh subscribe to my channel okay so uh ellis and barbara turn play again and uh initially choose x right x is less than uh from zero to n and uh if n must be uh and it's divisible by x and replacing the...
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
220
hi i am mayushi rawat and welcome to my channel today we will discuss the september lead code challenge day 2 problem contains duplicate 3 let's look at the problem statement given an array of integers find out whether there are two distinct indices i and j in the array such that the absolute difference between nums of...
Contains Duplicate III
contains-duplicate-iii
You are given an integer array `nums` and two integers `indexDiff` and `valueDiff`. Find a pair of indices `(i, j)` such that: * `i != j`, * `abs(i - j) <= indexDiff`. * `abs(nums[i] - nums[j]) <= valueDiff`, and Return `true` _if such pair exists or_ `false` _otherwise_. **Example 1:** **Input:** nums = \[1...
Time complexity O(n logk) - This will give an indication that sorting is involved for k elements. Use already existing state to evaluate next state - Like, a set of k sorted numbers are only needed to be tracked. When we are processing the next number in array, then we can utilize the existing sorted state and it is...
Array,Sliding Window,Sorting,Bucket Sort,Ordered Set
Medium
217,219
3
in this video we have to find the longest substring in a given string and the condition is that there should be no repeating character in that substring so let us take an example so this is a lead code problem number three and it has been asked quite a few times in Google and Amazon interviews so the problem statement ...
Longest Substring Without Repeating Characters
longest-substring-without-repeating-characters
Given a string `s`, find the length of the **longest** **substring** without repeating characters. **Example 1:** **Input:** s = "abcabcbb " **Output:** 3 **Explanation:** The answer is "abc ", with the length of 3. **Example 2:** **Input:** s = "bbbbb " **Output:** 1 **Explanation:** The answer is "b ", with t...
null
Hash Table,String,Sliding Window
Medium
159,340,1034,1813,2209
337
hello and welcome back today we will be discussing the sixth practice problem on DP this is going to be the first problem wherein we are going to apply dynamic programming entries as a prerequisite I am assuming that you are comfortable with trees data structure so let's quickly go through the problem statement it stat...
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
129
let's Implement lead code 129 given the root note of a binary tree with each node having a value from 0 to 9 we're asked to return the sum of all paths from the roots to the leaves now in addition to having an integer value each node has a pointer to its left child and appointed to its right child which are both null b...
Sum Root to Leaf Numbers
sum-root-to-leaf-numbers
You are given the `root` of a binary tree containing digits from `0` to `9` only. Each root-to-leaf path in the tree represents a number. * For example, the root-to-leaf path `1 -> 2 -> 3` represents the number `123`. Return _the total sum of all root-to-leaf numbers_. Test cases are generated so that the answer w...
null
Tree,Depth-First Search,Binary Tree
Medium
112,124,1030
205
Hello Friends Caught Discuss The Fourth Problem Sun Latest Festival Season Walking Alone And Middle 100 Easy Problem Andar Salasi Power To Ghaghare Vidmate Apps Soft Vegetable Problem Solve This Question Statement The Name Of The Giver Shy Subscribe What Means By Subscribe Replaced With This A To Z Tak Tent And All The...
Isomorphic Strings
isomorphic-strings
Given two strings `s` and `t`, _determine if they are isomorphic_. Two strings `s` and `t` are isomorphic if the characters in `s` can be replaced to get `t`. All occurrences of a character must be replaced with another character while preserving the order of characters. No two characters may map to the same characte...
null
Hash Table,String
Easy
290
1,650
welcome to june's leco challenge today's problem is lowest common ancestor of a binary tree given a binary tree find the lowest common ancestor of the two given nodes in the tree according to the definition of lca on wikipedia the lowest common ancestor is defined between two nodes p and q as the lowest note in t the b...
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
78
hey what's up guys john here again and so this time let's take a look at another classic problem here number 78 subsets alright so you're given a set of distinct integers return all the possible subsets right and then it's not the permutation of itself right basically it asks you to return all the possible subsets righ...
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
718
hello all welcome to CODA let us solve today's lead code daily challenge and the problem is maximum length of the repeated summary given to integer array nums one nums to return the maximum length of the sub array that appears in both the arrays it is a straightforward question they are given two arrays one two three t...
Maximum Length of Repeated Subarray
maximum-length-of-repeated-subarray
Given two integer arrays `nums1` and `nums2`, return _the maximum length of a subarray that appears in **both** arrays_. **Example 1:** **Input:** nums1 = \[1,2,3,2,1\], nums2 = \[3,2,1,4,7\] **Output:** 3 **Explanation:** The repeated subarray with maximum length is \[3,2,1\]. **Example 2:** **Input:** nums1 = \[0...
Use dynamic programming. dp[i][j] will be the answer for inputs A[i:], B[j:].
Array,Binary Search,Dynamic Programming,Sliding Window,Rolling Hash,Hash Function
Medium
209,2051
1,653
Hello Hi Everyone Welcome To My Channel It's All The Problem Minimum Delhi To Make A String Align With Your Given String Is Consisting Only Of Characters In The Easy You Can Delete Any Number Of Characters In Add To Make Gas Balance Acid Balance Television Repair Office Icon Because Zee Beach Means A To Find The Point ...
Minimum Deletions to Make String Balanced
number-of-good-leaf-nodes-pairs
You are given a string `s` consisting only of characters `'a'` and `'b'`​​​​. You can delete any number of characters in `s` to make `s` **balanced**. `s` is **balanced** if there is no pair of indices `(i,j)` such that `i < j` and `s[i] = 'b'` and `s[j]= 'a'`. Return _the **minimum** number of deletions needed to ma...
Start DFS from each leaf node. stop the DFS when the number of steps done > distance. If you reach another leaf node within distance steps, add 1 to the answer. Note that all pairs will be counted twice so divide the answer by 2.
Tree,Depth-First Search,Binary Tree
Medium
null
131
It will come in this video, we will fold this question, at this time all the ringtones in partitions, see what is this, joining the question is also better than fixing ADEN, you can break it into rooms in as many ways as possible, first you have to leave it like If you separate each character then put each part of it i...
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
797
hello friends today less of the old parties from source to target problem that first see the statement given a directed acyclic graph of a notes find opers both parties from note zero to note and minus one and return them in any order the graph is given as follows the noes are 0 1 to graph the lens -1 the noes are 0 1 ...
All Paths From Source to Target
rabbits-in-forest
Given a directed acyclic graph (**DAG**) of `n` nodes labeled from `0` to `n - 1`, find all possible paths from node `0` to node `n - 1` and return them in **any order**. The graph is given as follows: `graph[i]` is a list of all nodes you can visit from node `i` (i.e., there is a directed edge from node `i` to node `...
null
Array,Hash Table,Math,Greedy
Medium
null
1,218
hi everyone wit Calvin here so let's discuss about weekly contest for a 57 second question longest active it might take subsequence of given difference so we are given array and then we've been asked like the subsequence that can form an aromatic with constant difference according to the input so for example on the fir...
Longest Arithmetic Subsequence of Given Difference
lowest-common-ancestor-of-deepest-leaves
Given an integer array `arr` and an integer `difference`, return the length of the longest subsequence in `arr` which is an arithmetic sequence such that the difference between adjacent elements in the subsequence equals `difference`. A **subsequence** is a sequence that can be derived from `arr` by deleting some or n...
Do a postorder traversal. Then, if both subtrees contain a deepest leaf, you can mark this node as the answer (so far). The final node marked will be the correct answer.
Hash Table,Tree,Depth-First Search,Breadth-First Search,Binary Tree
Medium
1816
146
alright guys let's start it today's video so today's video is about the code number 146 our ru cash so it's a very typical and very interesting problem so let's look at it so s-- asked us to design and Ibelin so s-- asked us to design and Ibelin so s-- asked us to design and Ibelin implement the data structure for leas...
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,822
welcome to Pomodoro doe for Tuesday May 2nd 2023. today we're doing lead code problem 1822 sign of the product of an array this is an easy problem there is a function sine func X that returns one if x is positive negative one if x is negative and 0 if x is equal to zero you are given an integer array nums let product b...
Sign of the Product of an Array
longest-palindromic-subsequence-ii
There is a function `signFunc(x)` that returns: * `1` if `x` is positive. * `-1` if `x` is negative. * `0` if `x` is equal to `0`. You are given an integer array `nums`. Let `product` be the product of all values in the array `nums`. Return `signFunc(product)`. **Example 1:** **Input:** nums = \[-1,-2,-3,-4,...
As with any good dp problem that uses palindromes, try building the palindrome from the edges The prime point is to check that no two adjacent characters are equal, so save the past character while building the palindrome.
String,Dynamic Programming
Medium
516
1,540
hey everybody this is larry this is q2 of the recent bi-weekly contest of the recent bi-weekly contest of the recent bi-weekly contest can convert strings and k moves so i actually uh for example this problem there's one trick case to begin with uh which is that um which is if the links are not the same i actually ate ...
Can Convert String in K Moves
can-convert-string-in-k-moves
Given two strings `s` and `t`, your goal is to convert `s` into `t` in `k` moves or less. During the `ith` (`1 <= i <= k`) move you can: * Choose any index `j` (1-indexed) from `s`, such that `1 <= j <= s.length` and `j` has not been chosen in any previous move, and shift the character at that index `i` times. * ...
null
null
Medium
null
997
hey everyone welcome back and let's write some more neat code today so today let's solve the problem find the town judge we're given a town where there are n people labeled from 1 to n so already this is kind of looking like a graph problem setup and then if you read a little bit below you can see well these in a graph...
Find the Town Judge
find-the-town-judge
In a town, there are `n` people labeled from `1` to `n`. There is a rumor that one of these people is secretly the town judge. If the town judge exists, then: 1. The town judge trusts nobody. 2. Everybody (except for the town judge) trusts the town judge. 3. There is exactly one person that satisfies properties **...
null
null
Easy
null
1
hello and welcome today we are doing question number one on Leo the most popular question it is called toome we are going to jump right into it 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 so...
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
1,716
hey everyone today we are going to solve the Lal question calculate money in Lal Bank okay so first of all the description said he starts by putting in$ on Monday the first day and every in$ on Monday the first day and every in$ on Monday the first day and every day from Tuesday to Sunday uh he will put in$ more than t...
Calculate Money in Leetcode Bank
maximum-non-negative-product-in-a-matrix
Hercy wants to save money for his first car. He puts money in the Leetcode bank **every day**. He starts by putting in `$1` on Monday, the first day. Every day from Tuesday to Sunday, he will put in `$1` more than the day before. On every subsequent Monday, he will put in `$1` more than the **previous Monday**. Given...
Use Dynamic programming. Keep the highest value and lowest value you can achieve up to a point.
Array,Dynamic Programming,Matrix
Medium
null
1,480
welcome to mazelico challenge today's problem is running sum of 1d array given an array nums we define a running sum of an array as running some i equals the sum of num0 up to the nums i so it's like the accumulation the rolling sum i've used so here it's like starting with one then we sum that up to three to six to te...
Running Sum of 1d Array
movie-rating
Given an array `nums`. We define a running sum of an array as `runningSum[i] = sum(nums[0]...nums[i])`. Return the running sum of `nums`. **Example 1:** **Input:** nums = \[1,2,3,4\] **Output:** \[1,3,6,10\] **Explanation:** Running sum is obtained as follows: \[1, 1+2, 1+2+3, 1+2+3+4\]. **Example 2:** **Input:** ...
null
Database
Medium
null
1,958
Everyone Welcome to Turn Date Today We Are Going to Solve the List to Depression 19048 Which App We Look Forward to in This Question is Basically a It is Very Simple Question and Will Just Explanation Question and Follow the Approach and You Can You Yourself to the middle end and no problem you will get all my videos a...
Check if Move is Legal
ad-free-sessions
You are given a **0-indexed** `8 x 8` grid `board`, where `board[r][c]` represents the cell `(r, c)` on a game board. On the board, free cells are represented by `'.'`, white cells are represented by `'W'`, and black cells are represented by `'B'`. Each move in this game consists of choosing a free cell and changing i...
null
Database
Easy
null
468
hello guys welcome back to the coordinate it says there 16 from the lead cortisone challenge and today's problem is a valid IP address now for this a problem we will see a different approach to solve this problem before we proceed if you are new to the Channel please do subscribe we solves a lot of competitive problems...
Validate IP Address
validate-ip-address
Given a string `queryIP`, return `"IPv4 "` if IP is a valid IPv4 address, `"IPv6 "` if IP is a valid IPv6 address or `"Neither "` if IP is not a correct IP of any type. **A valid IPv4** address is an IP in the form `"x1.x2.x3.x4 "` where `0 <= xi <= 255` and `xi` **cannot contain** leading zeros. For example, `"192.16...
null
String
Medium
752
521
hey guys welcome back to my channel and i'm back again with another really interesting coding intervision video this time guys we are going to solve question number 521 of lead code called longest uncommon sequence part one and before i start with the problem statement guys i just want to request you to do subscribe to...
Longest Uncommon Subsequence I
longest-uncommon-subsequence-i
Given two strings `a` and `b`, return _the length of the **longest uncommon subsequence** between_ `a` _and_ `b`. If the longest uncommon subsequence does not exist, return `-1`. An **uncommon subsequence** between two strings is a string that is a **subsequence of one but not the other**. A **subsequence** of a stri...
null
String
Easy
522
792
792 number of matching sequences this is today's um lead code question let me see if i can solve it given a string yes and an array of string words written the number of words of i that is subsequence of s the subsequence of a string is a new string generated from original string with some characters can be none delete...
Number of Matching Subsequences
binary-search
Given a string `s` and an array of strings `words`, return _the number of_ `words[i]` _that is a subsequence of_ `s`. A **subsequence** of a string is a new string generated from the original string with some characters (can be none) deleted without changing the relative order of the remaining characters. * For exa...
null
Array,Binary Search
Easy
786
907
hey everybody this is Larry this is Thursdays and on November 24th so uh Happy Thanksgiving for everyone who's celebrating hope y'all have a good turkey and whatever it is that you like eating uh in my family actually we usually just get a chicken because yeah we uh family's a little bit smaller so turkey is kind of bi...
Sum of Subarray Minimums
koko-eating-bananas
Given an array of integers arr, find the sum of `min(b)`, where `b` ranges over every (contiguous) subarray of `arr`. Since the answer may be large, return the answer **modulo** `109 + 7`. **Example 1:** **Input:** arr = \[3,1,2,4\] **Output:** 17 **Explanation:** Subarrays are \[3\], \[1\], \[2\], \[4\], \[3,1\], \...
null
Array,Binary Search
Medium
788,1335,2188
1,439
that a hello hi guys welcome back to I want the question categories 110 Adhavwali 823 600 Avoid pickup exactly one element key and find the sum of elements and to-do list key and find the sum of elements and to-do list key and find the sum of elements and to-do list in element subscribe The Amazing element from this li...
Find the Kth Smallest Sum of a Matrix With Sorted Rows
running-total-for-different-genders
You are given an `m x n` matrix `mat` that has its rows sorted in non-decreasing order and an integer `k`. You are allowed to choose **exactly one element** from each row to form an array. Return _the_ `kth` _smallest array sum among all possible arrays_. **Example 1:** **Input:** mat = \[\[1,3,11\],\[2,4,6\]\], k ...
null
Database
Medium
1327
1,235
Hello friends, in today's video let us put the list to be discussed, this problem is called Maximum Profit in Job Dealer Problem, hence here you are set up and every job is the next time when your ante and with In this, when profit is associated with whatever you want in life, then you have to use it in the virtual tou...
Maximum Profit in Job Scheduling
maximum-profit-in-job-scheduling
We have `n` jobs, where every job is scheduled to be done from `startTime[i]` to `endTime[i]`, obtaining a profit of `profit[i]`. You're given the `startTime`, `endTime` and `profit` arrays, return the maximum profit you can take such that there are no two jobs in the subset with overlapping time range. If you choose...
null
null
Hard
null
790
Hello everyone in this video we will discuss about the problem domino and domino tearing so basically what we have given one domino so basically this domino its height is two and with e one and we have given one domino like that we need to Fill two crosses and would be using this domino and domino OK and we need to tel...
Domino and Tromino Tiling
global-and-local-inversions
You have two types of tiles: a `2 x 1` domino shape and a tromino shape. You may rotate these shapes. Given an integer n, return _the number of ways to tile an_ `2 x n` _board_. Since the answer may be very large, return it **modulo** `109 + 7`. In a tiling, every square must be covered by a tile. Two tilings are dif...
Where can the 0 be placed in an ideal permutation? What about the 1?
Array,Math
Medium
null
984
oh hello and welcome here we are let's take a few seconds make sure the audio is working see one two three yeah it's working very good all right I'll pop the chat out so um here we are another day wow I uh um you know I don't know what to say I had a kind of a rough day today um I think I can get right into this here j...
String Without AAA or BBB
most-stones-removed-with-same-row-or-column
Given two integers `a` and `b`, return **any** string `s` such that: * `s` has length `a + b` and contains exactly `a` `'a'` letters, and exactly `b` `'b'` letters, * The substring `'aaa'` does not occur in `s`, and * The substring `'bbb'` does not occur in `s`. **Example 1:** **Input:** a = 1, b = 2 **Output:...
null
Depth-First Search,Union Find,Graph
Medium
null
791
hey everyone my name is puru rhoda and i welcome you all to this channel today we are looking at the problem custom sort string this is a medium level problem only code and it is on the easier side of the medium spectrum now let's look at the problem order and str are strings composed of lowercase letters in order no l...
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
1,750
hey everyone welcome back and let's write some more neat code today so today let's solve the problem minimum length of string after deleting similar ends we're given a string s consisting of only three different characters and this actually isn't really super important for this problem we're also given a algorithm here...
Minimum Length of String After Deleting Similar Ends
check-if-two-expression-trees-are-equivalent
Given a string `s` consisting only of characters `'a'`, `'b'`, and `'c'`. You are asked to apply the following algorithm on the string any number of times: 1. Pick a **non-empty** prefix from the string `s` where all the characters in the prefix are equal. 2. Pick a **non-empty** suffix from the string `s` where all...
Count for each variable how many times it appeared in the first tree. Do the same for the second tree and check if the count is the same for both tree.
Tree,Depth-First Search,Binary Tree
Medium
1736
1,721
um hello so today we are going to do this problem called swapping nodes in a linked list so what the problem says here is that we get a the head of a Lincoln list and then in teacher k um and we want to return the head of the linked list after swapping the values of the kth node and K note from the beginning and the va...
Swapping Nodes in a Linked List
maximum-profit-of-operating-a-centennial-wheel
You are given the `head` of a linked list, and an integer `k`. Return _the head of the linked list after **swapping** the values of the_ `kth` _node from the beginning and the_ `kth` _node from the end (the list is **1-indexed**)._ **Example 1:** **Input:** head = \[1,2,3,4,5\], k = 2 **Output:** \[1,4,3,2,5\] **Ex...
Think simulation Note that the number of turns will never be more than 50 / 4 * n
Array,Simulation
Medium
null
1,758
all right so let's talk about the minimum change to make automatic final training so this question is pretty simple so you can only contain zero and one and then you can go for two uh zero one or you can go for one zero one here so basically you can do like this i'm gonna say i'm gonna create a two uh to counter so ent...
Minimum Changes To Make Alternating Binary String
distribute-repeating-integers
You are given a string `s` consisting only of the characters `'0'` and `'1'`. In one operation, you can change any `'0'` to `'1'` or vice versa. The string is called alternating if no two adjacent characters are equal. For example, the string `"010 "` is alternating, while the string `"0100 "` is not. Return _the **m...
Count the frequencies of each number. For example, if nums = [4,4,5,5,5], frequencies = [2,3]. Each customer wants all of their numbers to be the same. This means that each customer will be assigned to one number. Use dynamic programming. Iterate through the numbers' frequencies, and choose some subset of customers to ...
Array,Dynamic Programming,Backtracking,Bit Manipulation,Bitmask
Hard
null
914
I I I I want a safe channel, I have to take a saree, it is cut according to my device, 131 two pieces take time, but it is not easy, it is not true that its fans are not enough. And there are guards, there are some technical tricks, make some story line policy, what about those whose health numbers remain, you want to ...
X of a Kind in a Deck of Cards
random-point-in-non-overlapping-rectangles
You are given an integer array `deck` where `deck[i]` represents the number written on the `ith` card. Partition the cards into **one or more groups** such that: * Each group has **exactly** `x` cards where `x > 1`, and * All the cards in one group have the same integer written on them. Return `true` _if such pa...
null
Math,Binary Search,Reservoir Sampling,Prefix Sum,Ordered Set,Randomized
Medium
912,915
1,192
hey everybody this is larry this is day 24th of the april leco daddy challenge uh hit the like button hit the subscribe button join me on discord let me know what you think about today's prom critical connections in the red work now i'll let you know what i think about this form uh if this is the problem that i think i...
Critical Connections in a Network
divide-chocolate
There are `n` servers numbered from `0` to `n - 1` connected by undirected server-to-server `connections` forming a network where `connections[i] = [ai, bi]` represents a connection between servers `ai` and `bi`. Any server can reach other servers directly or indirectly through the network. A _critical connection_ is ...
After dividing the array into K+1 sub-arrays, you will pick the sub-array with the minimum sum. Divide the sub-array into K+1 sub-arrays such that the minimum sub-array sum is as maximum as possible. Use binary search with greedy check.
Array,Binary Search
Hard
410,1056
1,260
Robber Guys Welcome Back To My Channel English Video We Are Going To Solve It's Too Good To Show What Is Governor Statement Here Given A To Read Off Side Is Minute Ventral's Unit To Shift Brigade's Times In One Search Operation Element Attitude Is A Boost To great i g plus one element airtel.in - Wants to plus one elem...
Shift 2D Grid
day-of-the-year
Given a 2D `grid` of size `m x n` and an integer `k`. You need to shift the `grid` `k` times. In one shift operation: * Element at `grid[i][j]` moves to `grid[i][j + 1]`. * Element at `grid[i][n - 1]` moves to `grid[i + 1][0]`. * Element at `grid[m - 1][n - 1]` moves to `grid[0][0]`. Return the _2D grid_ after...
Have a integer array of how many days there are per month. February gets one extra day if its a leap year. Then, we can manually count the ordinal as day + (number of days in months before this one).
Math,String
Easy
null
3
Hello hello friends welcome to my channel again and special we are going to talk about letter code pack problem longest serving and petting character 200 feet Agrasain if you are there then please subscribe NDA if you like it then please like it ok so let's start For which I had started the playlist of Topper Interview...
Longest Substring Without Repeating Characters
longest-substring-without-repeating-characters
Given a string `s`, find the length of the **longest** **substring** without repeating characters. **Example 1:** **Input:** s = "abcabcbb " **Output:** 3 **Explanation:** The answer is "abc ", with the length of 3. **Example 2:** **Input:** s = "bbbbb " **Output:** 1 **Explanation:** The answer is "b ", with t...
null
Hash Table,String,Sliding Window
Medium
159,340,1034,1813,2209
450
Half of our today's problem delivery in binary search tree means tasty, now we have descendants, if anyone is committed to delete the value of the goods, just delete this number, okay, then we will have to do it to everyone, then skin elementary. Mid the best e After clicking on that what to do is to do your main opera...
Delete Node in a BST
delete-node-in-a-bst
Given a root node reference of a BST and a key, delete the node with the given key in the BST. Return _the **root node reference** (possibly updated) of the BST_. Basically, the deletion can be divided into two stages: 1. Search for a node to remove. 2. If the node is found, delete the node. **Example 1:** **Inpu...
null
Tree,Binary Search Tree,Binary Tree
Medium
791
849
hey everybody this is larry this is day 16 of the general elite code daily challenge hit the like button in the subscribe button join me on discord let me know what you think about today's prom um yeah i don't know what else to say about that it's saturday uh there's a contest in about an hour saturday for me maybe sun...
Maximize Distance to Closest Person
maximize-distance-to-closest-person
You are given an array representing a row of `seats` where `seats[i] = 1` represents a person sitting in the `ith` seat, and `seats[i] = 0` represents that the `ith` seat is empty **(0-indexed)**. There is at least one empty seat, and at least one person sitting. Alex wants to sit in the seat such that the distance b...
null
null
Medium
null
60
Coming soon on this show Today they are going to see the problem Open the permission sequence from the list Find the challenge Net see the problem first 20 * Set off these numbers from which you can 20 * Set off these numbers from which you can 20 * Set off these numbers from which you can generate and factorial unique...
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
401
The festival I wore this Adarsh ​​Mishra and The festival I wore this Adarsh ​​Mishra and The festival I wore this Adarsh ​​Mishra and you urination dress, today we are going to talk about the problem of binary lust on the list, it says to the problem that this will save you battery, it is a hand watch which has four L...
Binary Watch
binary-watch
A binary watch has 4 LEDs on the top to represent the hours (0-11), and 6 LEDs on the bottom to represent the minutes (0-59). Each LED represents a zero or one, with the least significant bit on the right. * For example, the below binary watch reads `"4:51 "`. Given an integer `turnedOn` which represents the number...
Simplify by seeking for solutions that involve comparing bit counts. Consider calculating all possible times for comparison purposes.
Backtracking,Bit Manipulation
Easy
17,191
480
hi Ricky here this is little code question number four eighty sliding window medium this is the hard question let's get into all right our median is with value in an order to integer list if size of the list is even there is no value like this there are no needle so the median is mean opportunity value example this is ...
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
724
hello everyone in today's video I'm going to be showing you this cool the code problem called find pivot index now a pivot index is defined as any index such that the sum of the array to the left of the index is equal to the sum of the ray to the right of the index so using our example here this is just a first example...
Find Pivot Index
find-pivot-index
Given an array of integers `nums`, calculate the **pivot index** of this array. The **pivot index** is the index where the sum of all the numbers **strictly** to the left of the index is equal to the sum of all the numbers **strictly** to the index's right. If the index is on the left edge of the array, then the left...
We can precompute prefix sums P[i] = nums[0] + nums[1] + ... + nums[i-1]. Then for each index, the left sum is P[i], and the right sum is P[P.length - 1] - P[i] - nums[i].
Array,Prefix Sum
Easy
560,2102,2369
1,557
hi this is Josh from Over the shoulder coding and I'm going to go over Lee code problem today for number 155 minimum number of vertices to reach all notes so this is today's daily problem and we're going to try and tackle it in about 15 minutes or so let's get started so given a directed acyclic graph with n vertices n...
Minimum Number of Vertices to Reach All Nodes
check-if-a-string-contains-all-binary-codes-of-size-k
Given a **directed acyclic graph**, with `n` vertices numbered from `0` to `n-1`, and an array `edges` where `edges[i] = [fromi, toi]` represents a directed edge from node `fromi` to node `toi`. Find _the smallest set of vertices from which all nodes in the graph are reachable_. It's guaranteed that a unique solution ...
We need only to check all sub-strings of length k. The number of distinct sub-strings should be exactly 2^k.
Hash Table,String,Bit Manipulation,Rolling Hash,Hash Function
Medium
null
155
he was of gasma quite here I detect encoding stuff on twitch and YouTube check description for all my information join the discord a lot of perks a lot of being in the discord there's a lot of like talented engineers and they're studying for specific things so also I'm doing this live on Twitch right now I do stream fo...
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
152
everyone welcome back and let's write some more neat code today let's look at maximum product subarray and this is actually a dynamic programming problem and i'm going to show you how to solve this problem easily so we're given an integer array of numbers and we want to find the contiguous subarray that contains at lea...
Maximum Product Subarray
maximum-product-subarray
Given an integer array `nums`, find a subarray that has the largest product, and return _the product_. The test cases are generated so that the answer will fit in a **32-bit** integer. **Example 1:** **Input:** nums = \[2,3,-2,4\] **Output:** 6 **Explanation:** \[2,3\] has the largest product 6. **Example 2:** **I...
null
Array,Dynamic Programming
Medium
53,198,238,628,713
443
Hi Gas Welcome And Welcome Back To My Channel Today Are Going To Discuss And Other Problem But Before Going Forward If Not Like The Video Please Like It Subscribe To My Channel And The Bell Icon So That You Get Notified Whenever Posted New Video So Without Others For date let's get started problem is string compressor ...
String Compression
string-compression
Given an array of characters `chars`, compress it using the following algorithm: Begin with an empty string `s`. For each group of **consecutive repeating characters** in `chars`: * If the group's length is `1`, append the character to `s`. * Otherwise, append the character followed by the group's length. The co...
How do you know if you are at the end of a consecutive group of characters?
Two Pointers,String
Medium
38,271,604,1241
93
hey everybody this is Larry this is day 21 of delete code daily challenge hit the like button in the Subscribe button join me on Discord let me know what you think about today's Forum restored IP address let's see what this is about um okay seems like this is uh yeah so I've added IP address okay oh yeah hit the like b...
Restore IP Addresses
restore-ip-addresses
A **valid IP address** consists of exactly four integers separated by single dots. Each integer is between `0` and `255` (**inclusive**) and cannot have leading zeros. * For example, `"0.1.2.201 "` and `"192.168.1.1 "` are **valid** IP addresses, but `"0.011.255.245 "`, `"192.168.1.312 "` and `"192.168@1.1 "` are **...
null
String,Backtracking
Medium
752
42
Hello Friends In This Section We Are Going To Discuss About Another List Co Problem Trapping Rain Water Divya Famous Interview According Question Given Interior Field With Negative Winters Different Elevation Map Edition Here With Love You All Will Calculate How Many Units In Water Park With Problem Egis Of elevation r...
Trapping Rain Water
trapping-rain-water
Given `n` non-negative integers representing an elevation map where the width of each bar is `1`, compute how much water it can trap after raining. **Example 1:** **Input:** height = \[0,1,0,2,1,0,1,3,2,1,2,1\] **Output:** 6 **Explanation:** The above elevation map (black section) is represented by array \[0,1,0,2,1,...
null
Array,Two Pointers,Dynamic Programming,Stack,Monotonic Stack
Hard
11,238,407,756
1,419
Ajay Ko Hello viewers welcome back to my channel I hope you enjoying all problems meaning of uploading him subscribe my channel please do subscribe can also share with your friends to this problem from difficulties minimum number of frogs cropping in different characters which represents a combination of distinct Perfo...
Minimum Number of Frogs Croaking
minimum-number-of-frogs-croaking
You are given the string `croakOfFrogs`, which represents a combination of the string `"croak "` from different frogs, that is, multiple frogs can croak at the same time, so multiple `"croak "` are mixed. _Return the minimum number of_ different _frogs to finish all the croaks in the given string._ A valid `"croak "`...
null
null
Medium
null
1,943
Hello so today we will discuss the list role number one four three do subscribe painting come so I will explain you in short question what is shikar basically what is given in it some segments are given which has starting and pending index of each statement and Some color of each segment which is this 5 to 7 minutes co...
Describe the Painting
count-pairs-of-equal-substrings-with-minimum-difference
There is a long and thin painting that can be represented by a number line. The painting was painted with multiple overlapping segments where each segment was painted with a **unique** color. You are given a 2D integer array `segments`, where `segments[i] = [starti, endi, colori]` represents the **half-closed segment**...
If the chosen substrings are of size larger than 1, then you can remove all but the first character from both substrings, and you'll get equal substrings of size 1, with the same a but less j. Hence, it's always optimal to choose substrings of size 1. If you choose a specific letter, then it's optimal to choose its fir...
Hash Table,String,Greedy
Medium
null
1,625
hey everybody this is larry this is q2 uh of the weekly leco contest 211. uh hit the like button hit the subscribe button join me on discord uh and we're gonna go over lecture graphically smallest string after applying operations so this one it's a lot of reading it's a really tricky problem uh if you look at the score...
Lexicographically Smallest String After Applying Operations
group-sold-products-by-the-date
You are given a string `s` of **even length** consisting of digits from `0` to `9`, and two integers `a` and `b`. You can apply either of the following two operations any number of times and in any order on `s`: * Add `a` to all odd indices of `s` **(0-indexed)**. Digits post `9` are cycled back to `0`. For example...
null
Database
Easy
2335
1
hello everybody my name is Ryan powers I'm going to be coding through the leak top 100 and I hope that a lot of you will be joining me this is my first video so hopefully it goes smoothly but yeah so the first problem on the leak code top 100 is too soon so we'll be starting with twosome so I'm given array of integers ...
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
981
this video we're going to look at a legal problem called time based key value store so in this question we're going to show you two approach to solve this problem one is you can use a tree map to solve this problem and the other one is you can use a binary search a lot of programming languages like python which doesn't...
Time Based Key-Value Store
delete-columns-to-make-sorted
Design a time-based key-value data structure that can store multiple values for the same key at different time stamps and retrieve the key's value at a certain timestamp. Implement the `TimeMap` class: * `TimeMap()` Initializes the object of the data structure. * `void set(String key, String value, int timestamp)...
null
Array,String
Easy
null
2
hey guys welcome back to another video and today we're going to be solving the lead code question add two numbers all right so in this question we're going to be given two non-empty linked lists representing two non-empty linked lists representing two non-empty linked lists representing two non-negative non-negative no...
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
1,047
hey everybody this is larry this is june 28th of the june the code daddy challenge only a couple more days to go so give yourself a pat in the back hit the like button and hit the subscribe button join me on discord let me know what you think about this problem and if you somehow just stumbled in um i'm gonna also do t...
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
916
hey everybody this is larry this is day 25 of the lead code daily challenge in march uh hit the like button the subscribe button join me on discord there's a lot of cooking and loading and stuff like that um yeah i couldn't find my glasses if you were watching yesterday i don't know where my glasses are so uh yeah so i...
Word Subsets
decoded-string-at-index
You are given two string arrays `words1` and `words2`. A string `b` is a **subset** of string `a` if every letter in `b` occurs in `a` including multiplicity. * For example, `"wrr "` is a subset of `"warrior "` but is not a subset of `"world "`. A string `a` from `words1` is **universal** if for every string `b` i...
null
String,Stack
Medium
null
1,690
hello everyone welcome to chorus camp we are at 11th day of june leeco challenge and the problem we are going to cover in this video is stone game 7. the problem statement says alice and bob take turns playing the stone game and i'll start first as usual as per any other stone game problems so here they said there are ...
Stone Game VII
maximum-length-of-subarray-with-positive-product
Alice and Bob take turns playing a game, with **Alice starting first**. There are `n` stones arranged in a row. On each player's turn, they can **remove** either the leftmost stone or the rightmost stone from the row and receive points equal to the **sum** of the remaining stones' values in the row. The winner is the ...
Split the whole array into subarrays by zeroes since a subarray with positive product cannot contain any zero. If the subarray has even number of negative numbers, the whole subarray has positive product. Otherwise, we have two choices, either - remove the prefix till the first negative element in this subarray, or rem...
Array,Dynamic Programming,Greedy
Medium
null
1,648
hi everyone it's albert today let's solve the leak code contact question cell diminishing value color both the question statement so we have an inventory of different color balls and there's a customer that wants to make orders of balls of any color and when selling balls to the customer the value of the ball is determ...
Sell Diminishing-Valued Colored Balls
minimum-insertions-to-balance-a-parentheses-string
You have an `inventory` of different colored balls, and there is a customer that wants `orders` balls of **any** color. The customer weirdly values the colored balls. Each colored ball's value is the number of balls **of that color** you currently have in your `inventory`. For example, if you own `6` yellow balls, the...
Use a stack to keep opening brackets. If you face single closing ')' add 1 to the answer and consider it as '))'. If you have '))' with empty stack, add 1 to the answer, If after finishing you have x opening remaining in the stack, add 2x to the answer.
String,Stack,Greedy
Medium
2095
377
hey guys it's off by one here and today we're going to be solving combination sum 4. in this problem we're given an array of distinct integers meaning that we don't have any duplicates and the array is called nums and they give us a Target integer called Target and they wanted to return the number of possible combinati...
Combination Sum IV
combination-sum-iv
Given an array of **distinct** integers `nums` and a target integer `target`, return _the number of possible combinations that add up to_ `target`. The test cases are generated so that the answer can fit in a **32-bit** integer. **Example 1:** **Input:** nums = \[1,2,3\], target = 4 **Output:** 7 **Explanation:** Th...
null
Array,Dynamic Programming
Medium
39
77
hello everyone welcome back here's what I'm saying and today we are going to tackle a very interesting lead code problem combination so this problem is uh all about generating combination of number so it's a great opportunity to explore some fundamental Concept in combination so the problem asks us to generate all poss...
Combinations
combinations
Given two integers `n` and `k`, return _all possible combinations of_ `k` _numbers chosen from the range_ `[1, n]`. You may return the answer in **any order**. **Example 1:** **Input:** n = 4, k = 2 **Output:** \[\[1,2\],\[1,3\],\[1,4\],\[2,3\],\[2,4\],\[3,4\]\] **Explanation:** There are 4 choose 2 = 6 total combin...
null
Backtracking
Medium
39,46
1,838
hello hi guys good morning welcome back to the new video this video going see the problem frequency of the most frequent element and this question has been asked by Amazon Uber and D bank it's a most frequest asked question in Amazon in last six months so please make sure that if you're preparing for plac intership do ...
Frequency of the Most Frequent Element
number-of-distinct-substrings-in-a-string
The **frequency** of an element is the number of times it occurs in an array. You are given an integer array `nums` and an integer `k`. In one operation, you can choose an index of `nums` and increment the element at that index by `1`. Return _the **maximum possible frequency** of an element after performing **at mos...
Calculate the prefix hashing array for s. Use the prefix hashing array to calculate the hashing value of each substring. Compare the hashing values to determine the unique substrings. There could be collisions if you use hashing, what about double hashing.
String,Trie,Rolling Hash,Suffix Array,Hash Function
Medium
null
1,011
hey everyone welcome to Tech wired in this video we are going to solve problem number one zero one capacity to ship packages within D days you will see the logic on the code for this problem now let's dive into the solution so here I've taken the second example from the lead code website so here we are given two inputs...
Capacity To Ship Packages Within D Days
flip-binary-tree-to-match-preorder-traversal
A conveyor belt has packages that must be shipped from one port to another within `days` days. The `ith` package on the conveyor belt has a weight of `weights[i]`. Each day, we load the ship with packages on the conveyor belt (in the order given by `weights`). We may not load more weight than the maximum weight capaci...
null
Tree,Depth-First Search,Binary Tree
Medium
null
54
so spinal matrix all they want to do is go through the matrix in a spiral while adding those elements into an array or a list and then return the list so uh i've seen some people the way they do this problem is where they set let's say they have these boundaries and you could just think of this as like row zero and wha...
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
1,431
hello how's everyone this is lead coding today and when you start with a very new playlist in this playlist I will add solutions to the question starting from the very easy one gradually moving on to the intermediate questions and then finally to the difficult ones so even the complete beginners can start with this pla...
Kids With the Greatest Number of Candies
all-ancestors-of-a-node-in-a-directed-acyclic-graph
There are `n` kids with candies. You are given an integer array `candies`, where each `candies[i]` represents the number of candies the `ith` kid has, and an integer `extraCandies`, denoting the number of extra candies that you have. Return _a boolean array_ `result` _of length_ `n`_, where_ `result[i]` _is_ `true` _i...
Consider how reversing each edge of the graph can help us. How can performing BFS/DFS on the reversed graph help us find the ancestors of every node?
Depth-First Search,Breadth-First Search,Graph,Topological Sort
Medium
1912
389
hey how's it going um just running a little script here uh pre-computing spacing on some sentences pre-computing spacing on some sentences pre-computing spacing on some sentences and they'll be stored in a cache database but let's take a look at the daily lead code because it's after 6 PM my time find the difference yo...
Find the Difference
find-the-difference
You are given two strings `s` and `t`. String `t` is generated by random shuffling string `s` and then add one more letter at a random position. Return the letter that was added to `t`. **Example 1:** **Input:** s = "abcd ", t = "abcde " **Output:** "e " **Explanation:** 'e' is the letter that was added. **Exam...
null
Hash Table,String,Bit Manipulation,Sorting
Easy
136
3
[Laughter] hey everybody this is larry this is day 10 of the june lego day challenge hit the like button to subscribe when drama and discord let me know what you think about today's prom uh so hopefully you know you enjoyed the intro yeah i don't know earlier today i had a power outage apparently happens like once or t...
Longest Substring Without Repeating Characters
longest-substring-without-repeating-characters
Given a string `s`, find the length of the **longest** **substring** without repeating characters. **Example 1:** **Input:** s = "abcabcbb " **Output:** 3 **Explanation:** The answer is "abc ", with the length of 3. **Example 2:** **Input:** s = "bbbbb " **Output:** 1 **Explanation:** The answer is "b ", with t...
null
Hash Table,String,Sliding Window
Medium
159,340,1034,1813,2209
637
binary tree well what do i say about it this is such an interesting and a very important data structure and due to this i have often seen that interviewers will come up with some random questions and they just want to test out how well do you actually understand this data structure they want to make sure that you are n...
Average of Levels in Binary Tree
average-of-levels-in-binary-tree
Given the `root` of a binary tree, return _the average value of the nodes on each level in the form of an array_. Answers within `10-5` of the actual answer will be accepted. **Example 1:** **Input:** root = \[3,9,20,null,null,15,7\] **Output:** \[3.00000,14.50000,11.00000\] Explanation: The average value of nodes on...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Easy
102,107
1,007
what is up guys Debbie Allen here today we're going over minimum Domino rotations for equal row so this was a popular very popular google question as you can see here I actually picked this for my slack channel because we were discussing Google questions so I'm gonna be going over that today so the description reads in...
Minimum Domino Rotations For Equal Row
numbers-with-same-consecutive-differences
In a row of dominoes, `tops[i]` and `bottoms[i]` represent the top and bottom halves of the `ith` domino. (A domino is a tile with two numbers from 1 to 6 - one on each half of the tile.) We may rotate the `ith` domino, so that `tops[i]` and `bottoms[i]` swap values. Return the minimum number of rotations so that all...
null
Backtracking,Breadth-First Search
Medium
null
371
hello everyone welcome to my channel so today we are going to do leave code 975 question sum of two integers so let us first take this question about the constraint then about examples and finally the coding part for the same so here let us first read this question given two integer A and B return the sum of two intege...
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
21
this is one of my favorite linked list questions we're given the heads of these two linked lists and they're both sorted in ascending order our job is to get the new list of the same nodes but also in ascending order so we start off with the dummy node D well L1 is smaller so we would rather point this to the first ele...
Merge Two Sorted Lists
merge-two-sorted-lists
You are given the heads of two sorted linked lists `list1` and `list2`. Merge the two lists in a one **sorted** list. The list should be made by splicing together the nodes of the first two lists. Return _the head of the merged linked list_. **Example 1:** **Input:** list1 = \[1,2,4\], list2 = \[1,3,4\] **Output:**...
null
Linked List,Recursion
Easy
23,88,148,244,1774,2071
131
Jhal Hello Welcome Parivartan 100 Indian subscribe The Channel And subscribe The Amazing Don't forget to subscribe on Thursday and subscribe chatting loudly and subscribe the Channel Please subscribe And subscribe The Amazing subscribe and subscribe the Channel Please subscribe and subscirbe mein bhi naagin track bandh...
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
1,901
today we're going to take a look at this peculiar question called find a peak element 2. the reason why I want to make this video is because uh from the solution I sing online the most optimal and correct way to do it is by using a Brute Force search inside a binary search now if you have no idea what I'm talking about...
Find a Peak Element II
equal-sum-arrays-with-minimum-number-of-operations
A **peak** element in a 2D grid is an element that is **strictly greater** than all of its **adjacent** neighbors to the left, right, top, and bottom. Given a **0-indexed** `m x n` matrix `mat` where **no two adjacent cells are equal**, find **any** peak element `mat[i][j]` and return _the length 2 array_ `[i,j]`. Yo...
Let's note that we want to either decrease the sum of the array with a larger sum or increase the array's sum with the smaller sum. You can maintain the largest increase or decrease you can make in a binary search tree and each time get the maximum one.
Array,Hash Table,Greedy,Counting
Medium
1263
1,091
Ko same guys welcome to day keida mili vedita and this video wear go into soft faith in binary matrix problem mein jeevan kya hai kya aapko and into and binary matrix hridaya rakha hai hume dhan karna hai land af bhi soft clear path in matric chup clearpath Do they understand here okay so a clear part in the matrix it ...
Shortest Path in Binary Matrix
maximum-average-subtree
Given an `n x n` binary matrix `grid`, return _the length of the shortest **clear path** in the matrix_. If there is no clear path, return `-1`. A **clear path** in a binary matrix is a path from the **top-left** cell (i.e., `(0, 0)`) to the **bottom-right** cell (i.e., `(n - 1, n - 1)`) such that: * All the visite...
Can you find the sum of values and the number of nodes for every sub-tree ? Can you find the sum of values and the number of nodes for a sub-tree given the sum of values and the number of nodes of it's left and right sub-trees ? Use depth first search to recursively find the solution for the children of a node then use...
Tree,Depth-First Search,Binary Tree
Medium
2126
1,773
That Aapke Ajay Ko Hua Hai Hello Everyone Welcome To New Video In This Video By Going To Discuss Nazar Problem List Code Problem In This Account Items Matching Rule Knowledge To The Problem He Problem Items Where Items By Tag Color Subscribe And also give you strength and rule 's 's 's item, subscribe, definitely one o...
Count Items Matching a Rule
percentage-of-users-attended-a-contest
You are given an array `items`, where each `items[i] = [typei, colori, namei]` describes the type, color, and name of the `ith` item. You are also given a rule represented by two strings, `ruleKey` and `ruleValue`. The `ith` item is said to match the rule if **one** of the following is true: * `ruleKey == "type "` ...
null
Database
Easy
1338
368
Hello everyone welcome back to my channel I hope you guys are doing well and today we are going to solve a very interesting problem Largest divisible subset its difficulty level is medium First of all we understand the question that what will we have to do in this we have to do a The given array will be of numbers n si...
Largest Divisible Subset
largest-divisible-subset
Given a set of **distinct** positive integers `nums`, return the largest subset `answer` such that every pair `(answer[i], answer[j])` of elements in this subset satisfies: * `answer[i] % answer[j] == 0`, or * `answer[j] % answer[i] == 0` If there are multiple solutions, return any of them. **Example 1:** **Inp...
null
Array,Math,Dynamic Programming,Sorting
Medium
null
1,832
hey there guys this is code tutorial for you back with another lead code problem this one's called check of the sentences pangram so it says 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 ...
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
43
Hello Hi Everyone Thoda We Are Going To And Make Multi Product To Idhar Aa That Is To Give Another Form Something Specific Converted Into The Form Of A 220 S2 Cost Multiple Edifice Number Dial Numbers Schedule Yahan Diary Nahi Aa 2015 TV Channel Which Word Between To Do We Are Dividing It Can We Make In The Question Re...
Multiply Strings
multiply-strings
Given two non-negative integers `num1` and `num2` represented as strings, return the product of `num1` and `num2`, also represented as a string. **Note:** You must not use any built-in BigInteger library or convert the inputs to integer directly. **Example 1:** **Input:** num1 = "2", num2 = "3" **Output:** "6" **Ex...
null
Math,String,Simulation
Medium
2,66,67,415
75
hey everyone welcome back and let's write some more neat code today so today let's solve sort colors this is a pretty good problem i actually really like this problem we are given an array of nums and they give us a little bit of a description like each number each you know value in nums is a color but let's just skip ...
Sort Colors
sort-colors
Given an array `nums` with `n` objects colored red, white, or blue, sort them **[in-place](https://en.wikipedia.org/wiki/In-place_algorithm)** so that objects of the same color are adjacent, with the colors in the order red, white, and blue. We will use the integers `0`, `1`, and `2` to represent the color red, white,...
A rather straight forward solution is a two-pass algorithm using counting sort. Iterate the array counting number of 0's, 1's, and 2's. Overwrite array with the total number of 0's, then 1's and followed by 2's.
Array,Two Pointers,Sorting
Medium
148,280,324
283
how's it going guys hey I mean going over a problem called move zeroes delete code problems commonly asked by Facebook Bloomberg Google and a couple other companies like Microsoft so the problem description says given an array numbers write a function to move all zeros to the end of it while maintaining the relative or...
Move Zeroes
move-zeroes
Given an integer array `nums`, move all `0`'s to the end of it while maintaining the relative order of the non-zero elements. **Note** that you must do this in-place without making a copy of the array. **Example 1:** **Input:** nums = \[0,1,0,3,12\] **Output:** \[1,3,12,0,0\] **Example 2:** **Input:** nums = \[0\]...
In-place means we should not be allocating any space for extra array. But we are allowed to modify the existing array. However, as a first step, try coming up with a solution that makes use of additional space. For this problem as well, first apply the idea discussed using an additional array and the in-place solution ...
Array,Two Pointers
Easy
27
127
hello everyone welcome back to sudokoda this is raveena and today I'm gonna talk about the high problem Word ladder uh let's start by reading the question here uh it says that a transformation sequence from word begin word to end word using a dictionary word list is a sequence of words begin word and then it goes throu...
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
978
hey what's up guys this is chung here so this time lead code number 978 longest turbulent sub array right so this time we're given like array and then we need to find the turbulent so what is the turbulent turbulence is the rays that you know every adjacent pair of elements uh the comparison sign will be flipped right ...
Longest Turbulent Subarray
valid-mountain-array
Given an integer array `arr`, return _the length of a maximum size turbulent subarray of_ `arr`. A subarray is **turbulent** if the comparison sign flips between each adjacent pair of elements in the subarray. More formally, a subarray `[arr[i], arr[i + 1], ..., arr[j]]` of `arr` is said to be turbulent if and only i...
It's very easy to keep track of a monotonically increasing or decreasing ordering of elements. You just need to be able to determine the start of the valley in the mountain and from that point onwards, it should be a valley i.e. no mini-hills after that. Use this information in regards to the values in the array and yo...
Array
Easy
1766
105
hello guys so let's talk about construct binary tree from pre-order and in order binary tree from pre-order and in order binary tree from pre-order and in order to traversal so given two individual arrays pre-order so given two individual arrays pre-order so given two individual arrays pre-order in order where pre-orde...
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
289
hey what's up guys this is zhong so let's take a look at this one today's dating challenge problem number 289 game of life um so you're given like a 2d board m by n grades of cells and each cell only has two values so one represent live and g represents that and each cell interacts with its eight neighbors okay so and ...
Game of Life
game-of-life
According to [Wikipedia's article](https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life): "The **Game of Life**, also known simply as **Life**, is a cellular automaton devised by the British mathematician John Horton Conway in 1970. " The board is made up of an `m x n` grid of cells, where each cell has an initial st...
null
Array,Matrix,Simulation
Medium
73
1,828
hey guys and this is steve um hope you guys are doing well today let's go through little problem 1828 i think this is um today this is this morning's contest the second question um pretty streetville actually brute force but i just want to quickly go through um so that don't be scared just by looking at the graph right...
Queries on Number of Points Inside a Circle
count-ways-to-distribute-candies
You are given an array `points` where `points[i] = [xi, yi]` is the coordinates of the `ith` point on a 2D plane. Multiple points can have the **same** coordinates. You are also given an array `queries` where `queries[j] = [xj, yj, rj]` describes a circle centered at `(xj, yj)` with a radius of `rj`. For each query `...
Try to define a recursive approach. For the ith candies, there will be one of the two following cases: If the i - 1 previous candies are already distributed into k bags for the ith candy, you can have k * dp[n - 1][k] ways to distribute the ith candy. We need then to solve the state of (n - 1, k). If the i - 1 previous...
Dynamic Programming
Hard
null
304
a look about the zero Lee code 304 range sum query 2D immutable given 2D Matrix handle the multiple queries of the following types calculate the sum of the element of Matrix inside the rectangle defined by its upper left corner Row 1 and column 1 and lower right corner Row 2 and the column to implement number Matrix cl...
Range Sum Query 2D - Immutable
range-sum-query-2d-immutable
Given a 2D matrix `matrix`, handle multiple queries of the following type: * Calculate the **sum** of the elements of `matrix` inside the rectangle defined by its **upper left corner** `(row1, col1)` and **lower right corner** `(row2, col2)`. Implement the `NumMatrix` class: * `NumMatrix(int[][] matrix)` Initial...
null
Array,Design,Matrix,Prefix Sum
Medium
303,308
1,971
welcome back everyone we're going to be solving Lee code 1971 find if path exists in graph so there is a bi-directional graph with so there is a bi-directional graph with so there is a bi-directional graph with n vertices where each vertex is labeled from 0 to n minus 1. the edges in the graph are represented as a 2d i...
Find if Path Exists in Graph
incremental-memory-leak
There is a **bi-directional** graph with `n` vertices, where each vertex is labeled from `0` to `n - 1` (**inclusive**). The edges in the graph are represented as a 2D integer array `edges`, where each `edges[i] = [ui, vi]` denotes a bi-directional edge between vertex `ui` and vertex `vi`. Every vertex pair is connecte...
What is the upper bound for the number of seconds? Simulate the process of allocating memory.
Simulation
Medium
null