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
227
hello and welcome back to the cracking fang youtube channel today we're going to be solving leap code problem 227 basic calculator 2. let's read the question prompt given a string s which represents an expression evaluate this expression and return its value the integer division should truncate to zero and you may assu...
Basic Calculator II
basic-calculator-ii
Given a string `s` which represents an expression, _evaluate this expression and return its value_. The integer division should truncate toward zero. You may assume that the given expression is always valid. All intermediate results will be in the range of `[-231, 231 - 1]`. **Note:** You are not allowed to use any ...
null
Math,String,Stack
Medium
224,282,785
559
so hey guys what's up in this video we are going to see about the maximum depth of the generic tree right so how to find the height of a generic tree so if you are new to my channel do hit like share and subscribe to my channel and if you haven't watched my previous videos on generic tree i would highly recommend you t...
Maximum Depth of N-ary Tree
maximum-depth-of-n-ary-tree
Given a n-ary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. _Nary-Tree input serialization is represented in their level order traversal, each group of children is separated by the null value (See examples)._ **Example...
null
null
Easy
null
1,022
hello everyone welcome or welcome back to my channel so today we are going to discuss another problem but before going forward if you're not like the video please like it subscribe to my channel so that you get notified when i post a new video so without any further ado let's get started so uh the problem is you sum of...
Sum of Root To Leaf Binary Numbers
unique-paths-iii
You are given the `root` of a binary tree where each node has a value `0` or `1`. Each root-to-leaf path represents a binary number starting with the most significant bit. * For example, if the path is `0 -> 1 -> 1 -> 0 -> 1`, then this could represent `01101` in binary, which is `13`. For all leaves in the tree, c...
null
Array,Backtracking,Bit Manipulation,Matrix
Hard
37,63,212
930
hey what's going on guys it's ilya bailly here i recorded stuff on youtube chat description for all my information i do all liquid problems uh make sure you subscribe to this channel give me a big thumbs up to support it and this is called uh binary sub-race with sum uh binary sub-race with sum uh binary sub-race with ...
Binary Subarrays With Sum
all-possible-full-binary-trees
Given a binary array `nums` and an integer `goal`, return _the number of non-empty **subarrays** with a sum_ `goal`. A **subarray** is a contiguous part of the array. **Example 1:** **Input:** nums = \[1,0,1,0,1\], goal = 2 **Output:** 4 **Explanation:** The 4 subarrays are bolded and underlined below: \[**1,0,1**,0...
null
Dynamic Programming,Tree,Recursion,Memoization,Binary Tree
Medium
null
1,546
uh hey everybody this is larry this is maximum number of non-overlapped maximum number of non-overlapped maximum number of non-overlapped things sub arrays if somebody goes to target uh this is the q3 of a recent contest so this is another prefix sum problem uh the thing to notice is that you want to get you know for t...
Maximum Number of Non-Overlapping Subarrays With Sum Equals Target
find-the-quiet-students-in-all-exams
Given an array `nums` and an integer `target`, return _the maximum number of **non-empty** **non-overlapping** subarrays such that the sum of values in each subarray is equal to_ `target`. **Example 1:** **Input:** nums = \[1,1,1,1,1\], target = 2 **Output:** 2 **Explanation:** There are 2 non-overlapping subarrays \...
null
Database
Hard
null
1,689
in this video we are going to partition a decimal number into different dc binary numbers so first of all what is a deci binary number so a number is a dc binary if you can if the digits are themselves just binary that is they consist of either 0 or 1 and we will ignore the leading zeros so no need to write that for ex...
Partitioning Into Minimum Number Of Deci-Binary Numbers
detect-pattern-of-length-m-repeated-k-or-more-times
A decimal number is called **deci-binary** if each of its digits is either `0` or `1` without any leading zeros. For example, `101` and `1100` are **deci-binary**, while `112` and `3001` are not. Given a string `n` that represents a positive decimal integer, return _the **minimum** number of positive **deci-binary** n...
Use a three-layer loop to check all possible patterns by iterating through all possible starting positions, all indexes less than m, and if the character at the index is repeated k times.
Array,Enumeration
Easy
1764
146
hi guys in this video i'm going to go through this little 146 uh lru cache so we need to design a data structure uh that constraint of a lyu cache so um we need to initialize the lyu cache by the capacity and also we need to write a function get so we need to get return the value to key if the keys already exist otherw...
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
392
hi guys welcome to algorithms made easy today we will go through the day 9 problem is subsequence please like the video and if you are new don't forget to subscribe to our channel so that you never miss any update given a string s and a string t check if s is a subsequence of t a subsequence of a string is a new string...
Is Subsequence
is-subsequence
Given two strings `s` and `t`, return `true` _if_ `s` _is a **subsequence** of_ `t`_, or_ `false` _otherwise_. A **subsequence** of a string is a new string that is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (i...
null
Two Pointers,String,Dynamic Programming
Easy
808,1051
15
hi everyone so we are back with another video in our need code 150 DS question series and today's problem is three sum so this is a very important problem and has been repeatedly asked in multiple interviews so make sure to watch the video till the end right and before proceeding further guys make sure that you are sol...
3Sum
3sum
Given an integer array nums, return all the triplets `[nums[i], nums[j], nums[k]]` such that `i != j`, `i != k`, and `j != k`, and `nums[i] + nums[j] + nums[k] == 0`. Notice that the solution set must not contain duplicate triplets. **Example 1:** **Input:** nums = \[-1,0,1,2,-1,-4\] **Output:** \[\[-1,-1,2\],\[-1,0...
So, we essentially need to find three numbers x, y, and z such that they add up to the given value. If we fix one of the numbers say x, we are left with the two-sum problem at hand! For the two-sum problem, if we fix one of the numbers, say x, we have to scan the entire array to find the next numbery which is value - x...
Array,Two Pointers,Sorting
Medium
1,16,18,259
77
hi everyone just so little question called combinations so given to integer n and k we want to return all possible combinations of k numbers out of this range are 1 to n increasingly and we can't announce it in any order let's check example one to help understand example one here we have n equals to four this means the...
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
376
hello friends today in this video we'll be understanding the wiggly sequence problem from the lead code difficulty level marked for this question is medium now let's first understand the question and the problem constraints that are given to you so now let's first understand what is a wiggly sequence so wiggly sequence...
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
6
hello everyone welcome back to another video today we have an interesting coding problem to tackle converting a given string into a zigzag pattern with a specified number of rows this is number six on the code it's called zigzag conversion and today we'll be solving in C plus our solution uses a vector of strings to ef...
Zigzag Conversion
zigzag-conversion
The string `"PAYPALISHIRING "` is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N A P L S I I G Y I R And then read line by line: `"PAHNAPLSIIGYIR "` Write the code that will take a string and make this co...
null
String
Medium
null
208
our next problem is called Implement a try um or a prefix Tre basically a try pronounced as try is a or prefix Tre is a Tre data structure used to efficiently store in three keys in a data set of strengths um it is being used for um things like autocomplete or spell checker most commonly we have to implement a tri clas...
Implement Trie (Prefix Tree)
implement-trie-prefix-tree
A [**trie**](https://en.wikipedia.org/wiki/Trie) (pronounced as "try ") or **prefix tree** is a tree data structure used to efficiently store and retrieve keys in a dataset of strings. There are various applications of this data structure, such as autocomplete and spellchecker. Implement the Trie class: * `Trie()` ...
null
Hash Table,String,Design,Trie
Medium
211,642,648,676,1433,1949
1,010
hello everyone welcome back to another lead code problem solving session today we're going to be solving pairs of songs with total durations divisible by 60. so we are given a list of songs where the I song has a duration of time I second return the number of pairs of songs force their total duration in seconds divisib...
Pairs of Songs With Total Durations Divisible by 60
powerful-integers
You are given a list of songs where the `ith` song has a duration of `time[i]` seconds. Return _the number of pairs of songs for which their total duration in seconds is divisible by_ `60`. Formally, we want the number of indices `i`, `j` such that `i < j` with `(time[i] + time[j]) % 60 == 0`. **Example 1:** **Input...
null
Hash Table,Math
Medium
null
1,433
Hello viewers welcome back to my channel I hope you are doing all problems the time uploading history become subscribe To My Channel Please Share and subscribe this problem this channel subscribe to subscribe can break communication of subscribe and subscribe to subscribe our A True RFSU Chem Back end one should improv...
Check If a String Can Break Another String
encrypt-and-decrypt-strings
Given two strings: `s1` and `s2` with the same size, check if some permutation of string `s1` can break some permutation of string `s2` or vice-versa. In other words `s2` can break `s1` or vice-versa. A string `x` can break string `y` (both of size `n`) if `x[i] >= y[i]` (in alphabetical order) for all `i` between `0`...
For encryption, use hashmap to map each char of word1 to its value. For decryption, use trie to prune when necessary.
Array,Hash Table,String,Design,Trie
Hard
208,212,1949
1,669
welcome to march's lego challenge today's problem is intersection of two linked lists write a program to find the note at which the intersection of two singly linked lists begins for example if we have these two linked lists we want to return c1 because that's the point where it gets merged here we want to return eight...
Merge In Between Linked Lists
minimum-cost-to-cut-a-stick
You are given two linked lists: `list1` and `list2` of sizes `n` and `m` respectively. Remove `list1`'s nodes from the `ath` node to the `bth` node, and put `list2` in their place. The blue edges and nodes in the following figure indicate the result: _Build the result list and return its head._ **Example 1:** **In...
Build a dp array where dp[i][j] is the minimum cost to achieve all the cuts between i and j. When you try to get the minimum cost between i and j, try all possible cuts k between them, dp[i][j] = min(dp[i][k] + dp[k][j]) + (j - i) for all possible cuts k between them.
Array,Dynamic Programming
Hard
2251
95
Hello gas welcome to me YouTube channel, so today we are going to solve the problem of finding 95 unique binding factories, okay and the answer is that it can be in any order, meaning this binary tree can be in the front and this one can be in the back. It can also be R, meaning it is not necessary, it can be kept in a...
Unique Binary Search Trees II
unique-binary-search-trees-ii
Given an integer `n`, return _all the structurally unique **BST'**s (binary search trees), which has exactly_ `n` _nodes of unique values from_ `1` _to_ `n`. Return the answer in **any order**. **Example 1:** **Input:** n = 3 **Output:** \[\[1,null,2,null,3\],\[1,null,3,2\],\[2,1,3\],\[3,1,null,null,2\],\[3,2,null,1\...
null
Dynamic Programming,Backtracking,Tree,Binary Search Tree,Binary Tree
Medium
96,241
134
the first approach is the brute force method in this method we calculate all possible combinations of starting stations and check if they're valid tour is possible for each starting station we iterate through all the stations in the circular manner calculating the remaining fuel at each step if the remaining fuel ever ...
Gas Station
gas-station
There are `n` gas stations along a circular route, where the amount of gas at the `ith` station is `gas[i]`. You have a car with an unlimited gas tank and it costs `cost[i]` of gas to travel from the `ith` station to its next `(i + 1)th` station. You begin the journey with an empty tank at one of the gas stations. Gi...
null
Array,Greedy
Medium
1346
111
hey everyone today we are going to service a little question minimum depth of binary tree so you are given binary and find the find its minimum depth so the minimum depth is a number of nodes along the shortest path from the root node down to the nearest Leaf node now if node is a node with no child no children so let'...
Minimum Depth of Binary Tree
minimum-depth-of-binary-tree
Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. **Note:** A leaf is a node with no children. **Example 1:** **Input:** root = \[3,9,20,null,null,15,7\] **Output:** 2 **Example 2:** **Input:** root = \[2...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Easy
102,104
1,644
hello and welcome back to another video today we're going to be working on lowest common ancestor of a binary tree too so in this problem you're given a binary tree and you want to return the lowest common ancestor of two given nodes P or q and I'm going to show you what this is going to look like in these examples ess...
Lowest Common Ancestor of a Binary Tree II
maximum-number-of-non-overlapping-substrings
Given the `root` of a binary tree, return _the lowest common ancestor (LCA) of two given nodes,_ `p` _and_ `q`. If either node `p` or `q` **does not exist** in the tree, return `null`. All values of the nodes in the tree are **unique**. According to the **[definition of LCA on Wikipedia](https://en.wikipedia.org/wiki/...
Notice that it's impossible for any two valid substrings to overlap unless one is inside another. We can start by finding the starting and ending index for each character. From these indices, we can form the substrings by expanding each character's range if necessary (if another character exists in the range with small...
String,Greedy
Hard
null
904
Hi gas welcome and welcome back to my channel so today our problem is fruit in basket so what is given to us in this problem statement is given to you here not you are visiting a form where what is yours a single There are fruit trees in the room which have been arranged from left to right. Here, I have given you one w...
Fruit Into Baskets
leaf-similar-trees
You are visiting a farm that has a single row of fruit trees arranged from left to right. The trees are represented by an integer array `fruits` where `fruits[i]` is the **type** of fruit the `ith` tree produces. You want to collect as much fruit as possible. However, the owner has some strict rules that you must foll...
null
Tree,Depth-First Search,Binary Tree
Easy
null
37
hello everyone in this video we will be solving the problem sudoku solver its number is 37 on lead code yesterday we solved the problem valid sudoku where we were going through all the entries in the board and verifying if the sudoku board is valid or not and here we will be solving the sudoku problem the basic rules o...
Sudoku Solver
sudoku-solver
Write a program to solve a Sudoku puzzle by filling the empty cells. A sudoku solution must satisfy **all of the following rules**: 1. Each of the digits `1-9` must occur exactly once in each row. 2. Each of the digits `1-9` must occur exactly once in each column. 3. Each of the digits `1-9` must occur exactly onc...
null
Array,Backtracking,Matrix
Hard
36,1022
253
hello friends today I will share my solution to the meeting room to and I have tried to solve this problem many times so I want to share my solution with you okay given a array of meeting time intervals consisting on start and end times find the minimum number of conference rooms required let us see the example first t...
Meeting Rooms II
meeting-rooms-ii
Given an array of meeting time intervals `intervals` where `intervals[i] = [starti, endi]`, return _the minimum number of conference rooms required_. **Example 1:** **Input:** intervals = \[\[0,30\],\[5,10\],\[15,20\]\] **Output:** 2 **Example 2:** **Input:** intervals = \[\[7,10\],\[2,4\]\] **Output:** 1 **Constr...
Think about how we would approach this problem in a very simplistic way. We will allocate rooms to meetings that occur earlier in the day v/s the ones that occur later on, right? If you've figured out that we have to sort the meetings by their start time, the next thing to think about is how do we do the allocation? Th...
Array,Two Pointers,Greedy,Sorting,Heap (Priority Queue)
Medium
56,252,452,1184
83
in this video we'll be going over remove duplicates from sorted lists so given the head of a sorted linked list delete all duplicates such that each element appears only once return to linked list sorted as well so in this first example we have one and two if we remove the duplicates one we get one and two sorry that's...
Remove Duplicates from Sorted List
remove-duplicates-from-sorted-list
Given the `head` of a sorted linked list, _delete all duplicates such that each element appears only once_. Return _the linked list **sorted** as well_. **Example 1:** **Input:** head = \[1,1,2\] **Output:** \[1,2\] **Example 2:** **Input:** head = \[1,1,2,3,3\] **Output:** \[1,2,3\] **Constraints:** * The numb...
null
Linked List
Easy
82,1982
498
hello so this question is diagonal driver so you're giving an environment tree and then you have to return an array of all the elements of the array in a diagonal order so uh this is a question and then let me just summarize it very quickly so you're starting from zero sorry zero index and there's only two direction yo...
Diagonal Traverse
diagonal-traverse
Given an `m x n` matrix `mat`, return _an array of all the elements of the array in a diagonal order_. **Example 1:** **Input:** mat = \[\[1,2,3\],\[4,5,6\],\[7,8,9\]\] **Output:** \[1,2,4,7,5,3,6,8,9\] **Example 2:** **Input:** mat = \[\[1,2\],\[3,4\]\] **Output:** \[1,2,3,4\] **Constraints:** * `m == mat.leng...
null
Array,Matrix,Simulation
Medium
2197
1,857
welcome to Pomodoro Joe for Sunday April 9th 2023. today we're doing leapco problem 1857 largest color value in a directed graph this is a hard problem all right so there is a directed graph of n colored nodes and M edges the nodes are numbered from 0 to n minus 1. you are given a string colors where colors index I is ...
Largest Color Value in a Directed Graph
largest-color-value-in-a-directed-graph
There is a **directed graph** of `n` colored nodes and `m` edges. The nodes are numbered from `0` to `n - 1`. You are given a string `colors` where `colors[i]` is a lowercase English letter representing the **color** of the `ith` node in this graph (**0-indexed**). You are also given a 2D array `edges` where `edges[j]...
null
null
Hard
null
494
okay so welcome back and it's another day like a problem so today it's called Target sum so this is a medium level dynamic programming problem where essentially you're just given an array called nums here as well as a Target and so this type of problem is basically you want to find out all the different kind of express...
Target Sum
target-sum
You are given an integer array `nums` and an integer `target`. You want to build an **expression** out of nums by adding one of the symbols `'+'` and `'-'` before each integer in nums and then concatenate all the integers. * For example, if `nums = [2, 1]`, you can add a `'+'` before `2` and a `'-'` before `1` and ...
null
Array,Dynamic Programming,Backtracking
Medium
282
252
hey and welcome today we will solve meeting rooms interview question which mostly asked by top companies like that so let's get into it first example here we have a two-dimensional array which we have a two-dimensional array which we have a two-dimensional array which contains array elements that holds start and end ti...
Meeting Rooms
meeting-rooms
Given an array of meeting time `intervals` where `intervals[i] = [starti, endi]`, determine if a person could attend all meetings. **Example 1:** **Input:** intervals = \[\[0,30\],\[5,10\],\[15,20\]\] **Output:** false **Example 2:** **Input:** intervals = \[\[7,10\],\[2,4\]\] **Output:** true **Constraints:** * ...
null
Array,Sorting
Easy
56,253
988
Ajay Ko Hello Hi Friends Welcome To My Channel And Today We Are Going To Solve Dalil Ko Problem 98 Molesting Starting From Delhi In The Root Of Poisonous Trees Where Is Not Have Value In Dowry 100 Basically Wave In Tears From 0250 Representing The Characters Representing Return Ko Graphically subscribe zaroor chalenge ...
Smallest String Starting From Leaf
flip-equivalent-binary-trees
You are given the `root` of a binary tree where each node has a value in the range `[0, 25]` representing the letters `'a'` to `'z'`. Return _the **lexicographically smallest** string that starts at a leaf of this tree and ends at the root_. As a reminder, any shorter prefix of a string is **lexicographically smaller...
null
Tree,Depth-First Search,Binary Tree
Medium
null
501
find mode in binary s Tre is a tree in which the middle node is the key and the left node or the present value stored in the left node is less than the root node and the right node is uh contain the value or the root value which is greater than the key node so we have given the root of a b Sy with duplicates and we hav...
Find Mode in Binary Search Tree
find-mode-in-binary-search-tree
Given the `root` of a binary search tree (BST) with duplicates, return _all the [mode(s)](https://en.wikipedia.org/wiki/Mode_(statistics)) (i.e., the most frequently occurred element) in it_. If the tree has more than one mode, return them in **any order**. Assume a BST is defined as follows: * The left subtree of...
null
Tree,Depth-First Search,Binary Search Tree,Binary Tree
Easy
98
98
hey guys welcome to the quorum act if you are new to the Channel please do subscribe we solve a lot of competitive problems today's problem is very read binary search tree so what problems say is given a binary tree determine if it is a valid binary search tree or not assume a BST is a define as follows so what how to ...
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
1,235
hello guys and welcome back to lead Logics this is the maximum profit in job scheduling problem from lead code this is a lead code hard and the number for this is 1 1235 so in this problem we are given with n jobs and uh every job is scheduled from start time I to end time I so we are given with the start times and the...
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
1,493
Hello everyone welcome to my channel with mike so a who is going to do video number 10 of his sliding window mechanism ok and medium level question lead code no 1493 but it is going to be a very general sliding window problem ok that's why I don't think this is medium, it is quite easy, we will make it with many triang...
Longest Subarray of 1's After Deleting One Element
frog-position-after-t-seconds
Given a binary array `nums`, you should delete one element from it. Return _the size of the longest non-empty subarray containing only_ `1`_'s in the resulting array_. Return `0` if there is no such subarray. **Example 1:** **Input:** nums = \[1,1,0,1\] **Output:** 3 **Explanation:** After deleting the number in pos...
Use a variation of DFS with parameters 'curent_vertex' and 'current_time'. Update the probability considering to jump to one of the children vertices.
Tree,Depth-First Search,Breadth-First Search,Graph
Hard
null
1,385
okay we're going to be doing late code 1385 find the distance value between two arrays so given two integer arrays array one and array two and the integer d right return the distance value between the two arrays the distance value is defined as the number of elements in array 1 such that there is not any element in arr...
Find the Distance Value Between Two Arrays
number-of-ways-to-build-house-of-cards
Given two integer arrays `arr1` and `arr2`, and the integer `d`, _return the distance value between the two arrays_. The distance value is defined as the number of elements `arr1[i]` such that there is not any element `arr2[j]` where `|arr1[i]-arr2[j]| <= d`. **Example 1:** **Input:** arr1 = \[4,5,8\], arr2 = \[10,9...
If a row has k triangles, how many cards does it take to build that row? It takes 3 * k - 1 cards. If you still have i cards left, and on the previous row there were k triangles, what are the possible ways to build the current row? You can start at 1 triangle and continue adding more until you run out of cards or reach...
Math,Dynamic Programming
Medium
815
943
hello friends today there so find the shortest superstream given array a of strings find any smallest string that contains each string in a and the substring we must assume that no stringing a is substring of another string in a so let's see this true example we can see Alex loves Lea code this free stream do not have ...
Find the Shortest Superstring
sum-of-subarray-minimums
Given an array of strings `words`, return _the smallest string that contains each string in_ `words` _as a substring_. If there are multiple valid strings of the smallest length, return **any of them**. You may assume that no string in `words` is a substring of another string in `words`. **Example 1:** **Input:** wo...
null
Array,Dynamic Programming,Stack,Monotonic Stack
Medium
2227
235
hello everyone today we are going to solve lowest common ancestor of a binary search tree it's a medium problem so it's a problem related to Binary Source tree so we need to utilize the property of the binary search tree it means all the nodes in the left subtree of a node will be smaller than the value of the node and...
Lowest Common Ancestor of a Binary Search Tree
lowest-common-ancestor-of-a-binary-search-tree
Given a binary search tree (BST), find the lowest common ancestor (LCA) node of two given nodes in the BST. According to the [definition of LCA on Wikipedia](https://en.wikipedia.org/wiki/Lowest_common_ancestor): "The lowest common ancestor is defined between two nodes `p` and `q` as the lowest node in `T` that has bo...
null
Tree,Depth-First Search,Binary Search Tree,Binary Tree
Easy
236,1190,1780,1790,1816
1,289
hello so today you are doing continuing on this contest beauty contest 15 the last problem which is this hard problem 1289 minimum falling path some - so the 1289 minimum falling path some - so the 1289 minimum falling path some - so the problem says given a square grid of integers a falling path with non zero shift is...
Minimum Falling Path Sum II
day-of-the-week
Given an `n x n` integer matrix `grid`, return _the minimum sum of a **falling path with non-zero shifts**_. A **falling path with non-zero shifts** is a choice of exactly one element from each row of `grid` such that no two elements chosen in adjacent rows are in the same column. **Example 1:** **Input:** arr = \[\...
Sum up the number of days for the years before the given year. Handle the case of a leap year. Find the number of days for each month of the given year.
Math
Easy
null
1,482
hey everybody this is Larry I'm doing this problem as part of a contest so you're gonna watch me live as I go through my darts I'm coding they've been explanation near the end and for more context they'll be a link below on this actual screencast of the contest how did you do let me know you do hit the like button eith...
Minimum Number of Days to Make m Bouquets
how-many-numbers-are-smaller-than-the-current-number
You are given an integer array `bloomDay`, an integer `m` and an integer `k`. You want to make `m` bouquets. To make a bouquet, you need to use `k` **adjacent flowers** from the garden. The garden consists of `n` flowers, the `ith` flower will bloom in the `bloomDay[i]` and then can be used in **exactly one** bouquet...
Brute force for each array element. In order to improve the time complexity, we can sort the array and get the answer for each array element.
Array,Hash Table,Sorting,Counting
Easy
315
382
Hello Everyone Welcome to Date 7th January Liquid Chalu Ji Online Ho And Then Contents Time Without Much Difficulty Boxer Protest Question Today's Questions Link List Radhe In This Question Were Given In Earliest And Need To Define Adhi Not Being Able To Avoid Subscribe Subscribe subscribe one two three do subscribe an...
Linked List Random Node
linked-list-random-node
Given a singly linked list, return a random node's value from the linked list. Each node must have the **same probability** of being chosen. Implement the `Solution` class: * `Solution(ListNode head)` Initializes the object with the head of the singly-linked list `head`. * `int getRandom()` Chooses a node randoml...
null
Linked List,Math,Reservoir Sampling,Randomized
Medium
398
1,725
B Call So what do we have to do so what will happen to us National Rectangle Square Triangle And I see we will pass the result Okay we will check like the method of finding the maximum Max If our system is done, then this is ours. Again current, we are people again. Rectangle, minimum rectangle, what should we do If yo...
Number Of Rectangles That Can Form The Largest Square
number-of-sets-of-k-non-overlapping-line-segments
You are given an array `rectangles` where `rectangles[i] = [li, wi]` represents the `ith` rectangle of length `li` and width `wi`. You can cut the `ith` rectangle to form a square with a side length of `k` if both `k <= li` and `k <= wi`. For example, if you have a rectangle `[4,6]`, you can cut it to get a square wit...
Try to use dynamic programming where the current index and remaining number of line segments to form can describe any intermediate state. To make the computation of each state in constant time, we could add another flag to the state that indicates whether or not we are in the middle of placing a line (placed start poin...
Math,Dynamic Programming
Medium
null
1,044
That Today Will See Editing Matching Problem Pattern Finding Problem Uninstall Longest Duplicate Sub Screen Award Is Means The Giver Bring to Front Subscribe Multiple Times at Least to Do It is the Longest Subscribe if you liked The Video then subscribe to the Page if you liked The Video then subscribe to The Amazing A...
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
142
hello everyone welcome to codex camp in today's video we are going to see linked list cycle two so the input given here is the head of linked list and we have to return the point where the linked list cycle starts so now we have already seen the problem linked list cycle one which is very similar to this problem which ...
Linked List Cycle II
linked-list-cycle-ii
Given the `head` of a linked list, return _the node where the cycle begins. If there is no cycle, return_ `null`. There is a cycle in a linked list if there is some node in the list that can be reached again by continuously following the `next` pointer. Internally, `pos` is used to denote the index of the node that ta...
null
Hash Table,Linked List,Two Pointers
Medium
141,287
987
welcome to january's lego challenge today's problem is vertical order traversal of a binary tree given the root of a binary tree calculate the vertical order traversal for each node at position x y its left and right children will be at positions x minus 1 y minus 1 and x plus 1 y minus 1 respectively the vertical orde...
Vertical Order Traversal of a Binary Tree
reveal-cards-in-increasing-order
Given the `root` of a binary tree, calculate the **vertical order traversal** of the binary tree. For each node at position `(row, col)`, its left and right children will be at positions `(row + 1, col - 1)` and `(row + 1, col + 1)` respectively. The root of the tree is at `(0, 0)`. The **vertical order traversal** o...
null
Array,Queue,Sorting,Simulation
Medium
null
1,678
hey guys welcome back to my youtube channel how are you all doing so today in this video we will try to solve lead code problem 1678 which is to do goal passer interpretation so what we have to do is basically you have been given a string here which is a input uh the input string it's a string which is g and then uh th...
Goal Parser Interpretation
number-of-ways-to-split-a-string
You own a **Goal Parser** that can interpret a string `command`. The `command` consists of an alphabet of `"G "`, `"() "` and/or `"(al) "` in some order. The Goal Parser will interpret `"G "` as the string `"G "`, `"() "` as the string `"o "`, and `"(al) "` as the string `"al "`. The interpreted strings are then concat...
There is no way if the sum (number of '1's) is not divisible by the number of splits. So sum%3 should be 0. Preffix s1 , and suffix s3 should have sum/3 characters '1'. Follow up: Can you generalize the problem with numbers between [-10^9, 10^9] such the sum between subarrays s1, s2, s3 are the same?
Math,String
Medium
548
84
hello welcome back today I will solve liquid 84 the largest rectangle in histogram we're given an integer array height and this represents the height of each bar for the histogram the width of each bar is 1 where it has to find the area of the largest rectangle in the histogram here is another representation of the hei...
Largest Rectangle in Histogram
largest-rectangle-in-histogram
Given an array of integers `heights` representing the histogram's bar height where the width of each bar is `1`, return _the area of the largest rectangle in the histogram_. **Example 1:** **Input:** heights = \[2,1,5,6,2,3\] **Output:** 10 **Explanation:** The above is a histogram where width of each bar is 1. The l...
null
Array,Stack,Monotonic Stack
Hard
85,1918
1,026
hey everybody this is Larry this is day 11 of the Leo day challenge hit the like button hit the Subscribe button join me on Discord let me know what you think about today's prom uh and I'm doing a thing that I did last year but I kind of well I went traveling so I stopped doing uh I am going to do a random premium prob...
Maximum Difference Between Node and Ancestor
string-without-aaa-or-bbb
Given the `root` of a binary tree, find the maximum value `v` for which there exist **different** nodes `a` and `b` where `v = |a.val - b.val|` and `a` is an ancestor of `b`. A node `a` is an ancestor of `b` if either: any child of `a` is equal to `b` or any child of `a` is an ancestor of `b`. **Example 1:** **Input...
null
String,Greedy
Medium
null
231
alright so this lead code question is called power of two it says given an integer write a function to determine if it is a power of two example one is the number one a powerup - yes it is because number one a powerup - yes it is because number one a powerup - yes it is because two to the zeroth power is one example tw...
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
285
all right we're going to do inorder successor and a bst so they give us the root of the tree and they give us some node p and we just want to find the successor of p which is just the smallest value which is greater than p um so we'll do this two ways the first one we're gonna the first way we're gonna do it recursivel...
Inorder Successor in BST
inorder-successor-in-bst
Given the `root` of a binary search tree and a node `p` in it, return _the in-order successor of that node in the BST_. If the given node has no in-order successor in the tree, return `null`. The successor of a node `p` is the node with the smallest key greater than `p.val`. **Example 1:** **Input:** root = \[2,1,3\...
null
Tree,Depth-First Search,Binary Search Tree,Binary Tree
Medium
94,173,509
545
hey what's up guys this is Chung here again I'm still doing this please called tree problems so today let's talk about the this number 545 boundary of binary tree okay let's see what does this problem want us to do here so you're given a binary tree right and then you're going to return a value of the average boundarie...
Boundary of Binary Tree
boundary-of-binary-tree
The **boundary** of a binary tree is the concatenation of the **root**, the **left boundary**, the **leaves** ordered from left-to-right, and the **reverse order** of the **right boundary**. The **left boundary** is the set of nodes defined by the following: * The root node's left child is in the left boundary. If ...
null
Tree,Depth-First Search,Binary Tree
Medium
199
766
hello welcome to the channel and today we have lead code 766 topless matrix so given the damn time and matrix return true if the metric is topless otherwise return fast the topless is totally matches is being like from the top to the right bottom this uh diagonal line is all having the same number so we have two here t...
Toeplitz Matrix
flatten-a-multilevel-doubly-linked-list
Given an `m x n` `matrix`, return _`true` if the matrix is Toeplitz. Otherwise, return `false`._ A matrix is **Toeplitz** if every diagonal from top-left to bottom-right has the same elements. **Example 1:** **Input:** matrix = \[\[1,2,3,4\],\[5,1,2,3\],\[9,5,1,2\]\] **Output:** true **Explanation:** In the above gr...
null
Linked List,Depth-First Search,Doubly-Linked List
Medium
114,1796
93
hey everybody this is Larry this is November 17. uh I'm gonna do a bonus extra question because the other one was kind of silly uh so yeah and number three maybe I should have talked about the number three a little bit more anyway I'm gonna do an extra bonus question just to kind of you know uh Flex my muscle a little ...
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
235
hey what's up guys Nick white here I detect coding stuff on twitch and YouTube check the description you can see all my information where to follow me where to do whatever you know explaining all these problems on lee code hacker inc these platforms because people have a tough time understanding the code so i'm here to...
Lowest Common Ancestor of a Binary Search Tree
lowest-common-ancestor-of-a-binary-search-tree
Given a binary search tree (BST), find the lowest common ancestor (LCA) node of two given nodes in the BST. According to the [definition of LCA on Wikipedia](https://en.wikipedia.org/wiki/Lowest_common_ancestor): "The lowest common ancestor is defined between two nodes `p` and `q` as the lowest node in `T` that has bo...
null
Tree,Depth-First Search,Binary Search Tree,Binary Tree
Easy
236,1190,1780,1790,1816
39
hey everyone this is site so let's start with the question so the question is combination sum so you have given an array of distinct integer candidates and a target integer target you have to return a list of all unique combination of the candidates where the chosen number sums to target okay so your unique combination...
Combination Sum
combination-sum
Given an array of **distinct** integers `candidates` and a target integer `target`, return _a list of all **unique combinations** of_ `candidates` _where the chosen numbers sum to_ `target`_._ You may return the combinations in **any order**. The **same** number may be chosen from `candidates` an **unlimited number of...
null
Array,Backtracking
Medium
17,40,77,216,254,377
787
Hello friends today I'm going to solve liquid problem number 787 cheapest flights within case tops so in this problem we are given an error flights where um flight at index I represents the value um which is also an array um which has three elements the first one is the value from where we are traveling the second is t...
Cheapest Flights Within K Stops
sliding-puzzle
There are `n` cities connected by some number of flights. You are given an array `flights` where `flights[i] = [fromi, toi, pricei]` indicates that there is a flight from city `fromi` to city `toi` with cost `pricei`. You are also given three integers `src`, `dst`, and `k`, return _**the cheapest price** from_ `src` _...
Perform a breadth-first-search, where the nodes are the puzzle boards and edges are if two puzzle boards can be transformed into one another with one move.
Array,Breadth-First Search,Matrix
Hard
null
297
hey guys let's tap number 2 9 7 serialize and deserialize binary tree I'll skip the explanation is very simple just like we get a binary tree like this 1 2 3 4 5 we will see realize it - 1 2 3 4 5 we will see realize it - 1 2 3 4 5 we will see realize it - 1 2 3 new one two or four five and any in Reverse way you forge...
Serialize and Deserialize Binary Tree
serialize-and-deserialize-binary-tree
Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection link to be reconstructed later in the same or another computer environment. Design an algorithm to serialize and deserialize a bi...
null
String,Tree,Depth-First Search,Breadth-First Search,Design,Binary Tree
Hard
271,449,652,765
328
this leaflet question is called odd-even this leaflet question is called odd-even this leaflet question is called odd-even linked list it says given a singly linked list group all odd notes together followed by the even notes please note here we are talking about the node number and not the value in the notes you shoul...
Odd Even Linked List
odd-even-linked-list
Given the `head` of a singly linked list, group all the nodes with odd indices together followed by the nodes with even indices, and return _the reordered list_. The **first** node is considered **odd**, and the **second** node is **even**, and so on. Note that the relative order inside both the even and odd groups s...
null
Linked List
Medium
725
701
hey everybody this is larry this is day six of the october eco day challenge uh hit the like button the subscriber and join me on discord let me know what you think about today's problem insert into a binary search tree uh okay give it a treat does have to be balanced no it doesn't have to be balanced okay so that mean...
Insert into a Binary Search Tree
insert-into-a-binary-search-tree
You are given the `root` node of a binary search tree (BST) and a `value` to insert into the tree. Return _the root node of the BST after the insertion_. It is **guaranteed** that the new value does not exist in the original BST. **Notice** that there may exist multiple valid ways for the insertion, as long as the tre...
null
null
Medium
null
886
Hello gas welcome back to my channel need code challenge possible by partition so what to do in this question and there are some people who like someone like this okay so what you have to do is to separate those who dislike them into different groups We have to divide it into two groups and make two groups like this. O...
Possible Bipartition
score-of-parentheses
We want to split a group of `n` people (labeled from `1` to `n`) into two groups of **any size**. Each person may dislike some other people, and they should not go into the same group. Given the integer `n` and the array `dislikes` where `dislikes[i] = [ai, bi]` indicates that the person labeled `ai` does not like the...
null
String,Stack
Medium
null
141
141 link to list the cycle and it's an easy legal question so giving head ahead of a linked list to determine if the linked list has cycle in it there's a cycle in the linked list if their cell node in the list can be reached again by continuously following the next pointer initially pos is used to denote the index the...
Linked List Cycle
linked-list-cycle
Given `head`, the head of a linked list, determine if the linked list has a cycle in it. There is a cycle in a linked list if there is some node in the list that can be reached again by continuously following the `next` pointer. Internally, `pos` is used to denote the index of the node that tail's `next` pointer is co...
null
Hash Table,Linked List,Two Pointers
Easy
142,202
967
Hello hello guys welcome back to my channel thank you got introduced to challenge what is the difference of the same digit from the phone number Rashmi Karne meeting you girl has to be edited in such a way that what is the difference of the same digit from the number and which get even digit. That's K Okay like what's ...
Numbers With Same Consecutive Differences
minimum-falling-path-sum
Given two integers n and k, return _an array of all the integers of length_ `n` _where the difference between every two consecutive digits is_ `k`. You may return the answer in **any order**. Note that the integers should not have leading zeros. Integers as `02` and `043` are not allowed. **Example 1:** **Input:** n...
null
Array,Dynamic Programming,Matrix
Medium
1224
1,746
hey everybody this is Larry this is me doing nextra Alo problem because um well we just had a yeey prom for the da prom so let's take a look uh did I click on it I think I clicked on it right oh there you go and today's prom is uh and it's February 26 2024 almost said 2029 I don't know these years who knows and why is ...
Maximum Subarray Sum After One Operation
largest-substring-between-two-equal-characters
You are given an integer array `nums`. You must perform **exactly one** operation where you can **replace** one element `nums[i]` with `nums[i] * nums[i]`. Return _the **maximum** possible subarray sum after **exactly one** operation_. The subarray must be non-empty. **Example 1:** **Input:** nums = \[2,-1,-4,-3\] *...
Try saving the first and last position of each character Try finding every pair of indexes with equal characters
Hash Table,String
Easy
null
423
hello everyone welcome to another episode of coding decoded and today we'll be solving march 28 lead code challenge and today's question is reconstruct original digits from english in this question we are given a string that is out of order english representation of digits 0 to 9. just one line is given the question th...
Reconstruct Original Digits from English
reconstruct-original-digits-from-english
Given a string `s` containing an out-of-order English representation of digits `0-9`, return _the digits in **ascending** order_. **Example 1:** **Input:** s = "owoztneoer" **Output:** "012" **Example 2:** **Input:** s = "fviefuro" **Output:** "45" **Constraints:** * `1 <= s.length <= 105` * `s[i]` is one of ...
null
Hash Table,Math,String
Medium
null
394
uh this question is because shrink so uh I'm going to just quickly summarize it so you're giving a student s then there are integer and a bracket and a character right then you just want to decode it okay so this is the super straightforward summarize summarization now I'm going to explain how you uh solve this questio...
Decode String
decode-string
Given an encoded string, return its decoded string. The encoding rule is: `k[encoded_string]`, where the `encoded_string` inside the square brackets is being repeated exactly `k` times. Note that `k` is guaranteed to be a positive integer. You may assume that the input string is always valid; there are no extra white...
null
String,Stack,Recursion
Medium
471,726,1076
806
hey everyone today we'll be doing another lead code problem 806 number of lines to write string this is an easy one you are given a string as of lowercase English letters and an array which denoting how many pixels wide each lowercase English letter is so width at 0 will represent a and at 1 a will be representing B an...
Number of Lines To Write String
domino-and-tromino-tiling
You are given a string `s` of lowercase English letters and an array `widths` denoting **how many pixels wide** each lowercase English letter is. Specifically, `widths[0]` is the width of `'a'`, `widths[1]` is the width of `'b'`, and so on. You are trying to write `s` across several lines, where **each line is no long...
null
Dynamic Programming
Medium
null
1,963
What does the question say? The question says that if we give you the input of open closing bracket like this then what will be the minimum required to balance the string. Basically if I have to balance this string then I will check the last to last first position. If I do whatever it takes then something like this wil...
Minimum Number of Swaps to Make the String Balanced
find-xor-sum-of-all-pairs-bitwise-and
You are given a **0-indexed** string `s` of **even** length `n`. The string consists of **exactly** `n / 2` opening brackets `'['` and `n / 2` closing brackets `']'`. A string is called **balanced** if and only if: * It is the empty string, or * It can be written as `AB`, where both `A` and `B` are **balanced** s...
Think about (a&b) ^ (a&c). Can you simplify this expression? It is equal to a&(b^c). Then, (arr1[i]&arr2[0])^(arr1[i]&arr2[1]).. = arr1[i]&(arr2[0]^arr2[1]^arr[2]...). Let arr2XorSum = (arr2[0]^arr2[1]^arr2[2]...), arr1XorSum = (arr1[0]^arr1[1]^arr1[2]...) so the final answer is (arr2XorSum&arr1[0]) ^ (arr2XorSum&arr1[...
Array,Math,Bit Manipulation
Hard
null
1,062
hey guys how's everything going and it's continued our journey to these code this is one 0-62 longest repeated substring is one 0-62 longest repeated substring is one 0-62 longest repeated substring we're given a string s find out the length of longest repeated substring which is zero if not none is fun fine found it n...
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
264
hello friends welcome to algerie po so today we are going to solve ugly number to lead code week one day for the challenge so let us see what is the question so the question is that you have to find so you will be given an N equals to 10 so you have to find tenth ugly number so they will be giving position so you have ...
Ugly Number II
ugly-number-ii
An **ugly number** is a positive integer whose prime factors are limited to `2`, `3`, and `5`. Given an integer `n`, return _the_ `nth` _**ugly number**_. **Example 1:** **Input:** n = 10 **Output:** 12 **Explanation:** \[1, 2, 3, 4, 5, 6, 8, 9, 10, 12\] is the sequence of the first 10 ugly numbers. **Example 2:** ...
The naive approach is to call isUgly for every number until you reach the nth one. Most numbers are not ugly. Try to focus your effort on generating only the ugly ones. An ugly number must be multiplied by either 2, 3, or 5 from a smaller ugly number. The key is how to maintain the order of the ugly numbers. Try a simi...
Hash Table,Math,Dynamic Programming,Heap (Priority Queue)
Medium
23,204,263,279,313,1307
48
welcome to a new video in today's video we're going to look at a liquid problem and the problem's name is rotate image so in this question we're given a matrix so in this question we're given our nbined 2D Matrix representing an image and we need to display the output by rotating the image by 90 degrees clockwise and t...
Rotate Image
rotate-image
You are given an `n x n` 2D `matrix` representing an image, rotate the image by **90** degrees (clockwise). You have to rotate the image [**in-place**](https://en.wikipedia.org/wiki/In-place_algorithm), which means you have to modify the input 2D matrix directly. **DO NOT** allocate another 2D matrix and do the rotati...
null
Array,Math,Matrix
Medium
2015
116
hey what's up guys babybear4812 coming at you one more time today we're doing problem 1017 the populating next right pointers in each node part two problem there's this is a obviously a part two to a part one that i haven't answered before and i'll leave a link in the description um i'd say the problems they're not ent...
Populating Next Right Pointers in Each Node
populating-next-right-pointers-in-each-node
You are given a **perfect binary tree** where all leaves are on the same level, and every parent has two children. The binary tree has the following definition: struct Node { int val; Node \*left; Node \*right; Node \*next; } Populate each next pointer to point to its next right node. If there is no next righ...
null
Linked List,Tree,Depth-First Search,Breadth-First Search,Binary Tree
Medium
117,199
5
hey folks this is praveen and today we're gonna see the problem of longest columbic substring so what the problem statement says like there is a string provided and we have to find the longest palindromic string what does that mean so we'll have to check all this offset and in that we'll have to see the highest or the ...
Longest Palindromic Substring
longest-palindromic-substring
Given a string `s`, return _the longest_ _palindromic_ _substring_ in `s`. **Example 1:** **Input:** s = "babad " **Output:** "bab " **Explanation:** "aba " is also a valid answer. **Example 2:** **Input:** s = "cbbd " **Output:** "bb " **Constraints:** * `1 <= s.length <= 1000` * `s` consist of only dig...
How can we reuse a previously computed palindrome to compute a larger palindrome? If “aba” is a palindrome, is “xabax” a palindrome? Similarly is “xabay” a palindrome? Complexity based hint: If we use brute-force and check whether for every start and end position a substring is a palindrome we have O(n^2) start - end ...
String,Dynamic Programming
Medium
214,266,336,516,647
911
hey what's up guys chung here and so this time uh let's take a look at this problem uh number 911 online election it's a medium problem so uh you're given like two basically uh two parameters right the first one is a person's at least all the persons and the second one is the times so the ice element of a person means ...
Online Election
profitable-schemes
You are given two integer arrays `persons` and `times`. In an election, the `ith` vote was cast for `persons[i]` at time `times[i]`. For each query at a time `t`, find the person that was leading the election at time `t`. Votes cast at time `t` will count towards our query. In the case of a tie, the most recent vote (...
null
Array,Dynamic Programming
Hard
null
1,787
hello everyone let's take a look at this record problems it's the last problem in the weekly context and it's a very hard problem i also didn't figure out during this context let's take a look at this problem so the problem is uh we are given an a number and an integer k we need to find the minimum change we can make s...
Make the XOR of All Segments Equal to Zero
sum-of-absolute-differences-in-a-sorted-array
You are given an array `nums`​​​ and an integer `k`​​​​​. The XOR of a segment `[left, right]` where `left <= right` is the `XOR` of all the elements with indices between `left` and `right`, inclusive: `nums[left] XOR nums[left+1] XOR ... XOR nums[right]`. Return _the minimum number of elements to change in the array_...
Absolute difference is the same as max(a, b) - min(a, b). How can you use this fact with the fact that the array is sorted? For nums[i], the answer is (nums[i] - nums[0]) + (nums[i] - nums[1]) + ... + (nums[i] - nums[i-1]) + (nums[i+1] - nums[i]) + (nums[i+2] - nums[i]) + ... + (nums[n-1] - nums[i]). It can be simplifi...
Array,Math,Prefix Sum
Medium
null
502
hey everybody this is Larry this is stage 23 of delete code day challenge hit the like button hit the Subscribe button join me on Discord let me know what you think about today's Farm uh I will not be doing an extra Farm today just because I'm tired I not gonna lie I didn't sleep that well yesterday I'm going to try to...
IPO
ipo
Suppose LeetCode will start its **IPO** soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the **IPO**. Since it has limited resources, it can only finish at most `k` distinct projects before the **IPO**. Help LeetCode design...
null
Array,Greedy,Sorting,Heap (Priority Queue)
Hard
null
718
hey everybody this is Larry this is day 20 of the Lego day challenge hit the like button hit the Subscribe button join me on Discord let me know what you think about today's farm and today's contest and all this uh today's just problem here and today's uh video and all that stuff um yeah let's do it let's get started u...
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
326
hello welcome to my channel so today let's look at the recorder 3 2 6 power 3. given an integer n return true if the eta is a power tree otherwise it return force so um example if n is 27 then it's uh three cube so it's uh should i return true if n is zero it should return false if n is nice uh three square is still re...
Power of Three
power-of-three
Given an integer `n`, return _`true` if it is a power of three. Otherwise, return `false`_. An integer `n` is a power of three, if there exists an integer `x` such that `n == 3x`. **Example 1:** **Input:** n = 27 **Output:** true **Explanation:** 27 = 33 **Example 2:** **Input:** n = 0 **Output:** false **Explanat...
null
Math,Recursion
Easy
231,342,1889
389
Hello guys I am Lalita Agarwal welcome tu jo owner on coding channel confectionate same you made but you also let no start today this lead code problem aaj ki lead code problem kya bol rahi hai achcha before going towards d problem na 1 main decision par dosh Those who have understood the problem well and want to try i...
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
1,624
hello everyone this is Sher and today we are diving into the Leo daily challenge for December 31st as the final challenge of 20 23rd we're not holding back let's tackle it together right away first let's understand the problem we are giving a string s and we need to find the length of the longest sub string 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
208
Ajay Ko Hello viewers welcome back to my channel doing great history subscribe To My Channel Please eclipse subscribe week don't playlist ka various categories such problems true religious programming subscribe half-half problem deposit from description subscribe half-half problem deposit from description subscribe hal...
Implement Trie (Prefix Tree)
implement-trie-prefix-tree
A [**trie**](https://en.wikipedia.org/wiki/Trie) (pronounced as "try ") or **prefix tree** is a tree data structure used to efficiently store and retrieve keys in a dataset of strings. There are various applications of this data structure, such as autocomplete and spellchecker. Implement the Trie class: * `Trie()` ...
null
Hash Table,String,Design,Trie
Medium
211,642,648,676,1433,1949
1,846
so hello people so today we'll be solving need Cod equation 1846 that is maximum element after decreasing and rearranging and in this we are given a integer ARR of positive integers ARR perform some operations which can be zero also on array so that it satisfies the condition that the first value of the element in AR m...
Maximum Element After Decreasing and Rearranging
maximum-element-after-decreasing-and-rearranging
You are given an array of positive integers `arr`. Perform some operations (possibly none) on `arr` so that it satisfies these conditions: * The value of the **first** element in `arr` must be `1`. * The absolute difference between any 2 adjacent elements must be **less than or equal to** `1`. In other words, `abs...
null
null
Medium
null
1,624
Hello and welcome back to our channel today we are going to solve lead code question number 1624 which is about finding the largest substring between two equal characters so without wasting any time let us start to understand this question so first of all in this question we What is it said to the people? We have to fi...
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
962
hey everybody this is larry this is me doing the bonus question hit the like button hit the subscribe button draw me on discord um yeah so as you know i do an extra problem um because i usually have done it let's see if i get one because usually they give me i try to do a random question i haven't done before hence the...
Maximum Width Ramp
flip-string-to-monotone-increasing
A **ramp** in an integer array `nums` is a pair `(i, j)` for which `i < j` and `nums[i] <= nums[j]`. The **width** of such a ramp is `j - i`. Given an integer array `nums`, return _the maximum width of a **ramp** in_ `nums`. If there is no **ramp** in `nums`, return `0`. **Example 1:** **Input:** nums = \[6,0,8,2,1,...
null
String,Dynamic Programming
Medium
null
1,403
Hello hello friends today I will discuss question from greed kotputli contest 181 problem number nine updated on a result the record date sum of all its elements system temple run ki and 152 rds ki and I can assume that no plus 619 plus element of video plz subscribe Do How To Worship Can Do But Justice Chaudhary Co An...
Minimum Subsequence in Non-Increasing Order
palindrome-partitioning-iii
Given the array `nums`, obtain a subsequence of the array whose sum of elements is **strictly greater** than the sum of the non included elements in such subsequence. If there are multiple solutions, return the subsequence with **minimum size** and if there still exist multiple solutions, return the subsequence with t...
For each substring calculate the minimum number of steps to make it palindrome and store it in a table. Create a dp(pos, cnt) which means the minimum number of characters changed for the suffix of s starting on pos splitting the suffix on cnt chunks.
String,Dynamic Programming
Hard
1871
6
Welcome back tu de stylish kadhar hope you all are doing well so today we have question complete and one will be waiting which will tell us how many days it can be. Okay so it is possible daily we have to do jikjack conversion in it. Meaning, converting the string zigzag and writing it down means what will be its conve...
Zigzag Conversion
zigzag-conversion
The string `"PAYPALISHIRING "` is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N A P L S I I G Y I R And then read line by line: `"PAHNAPLSIIGYIR "` Write the code that will take a string and make this co...
null
String
Medium
null
545
Hello hi friends welcome back cover sleep today we are going to solve lift problem 878 boundary of binary tree this problem was previously found by Google and Amazon as you can see and here 100 before but after looking into the description of just want to mention that my Channel Focus On Helping People Who Are Preparin...
Boundary of Binary Tree
boundary-of-binary-tree
The **boundary** of a binary tree is the concatenation of the **root**, the **left boundary**, the **leaves** ordered from left-to-right, and the **reverse order** of the **right boundary**. The **left boundary** is the set of nodes defined by the following: * The root node's left child is in the left boundary. If ...
null
Tree,Depth-First Search,Binary Tree
Medium
199
138
Hello Guys Welcome To Reconsider Subscribe Point Question Adhadhundh Video subscribe and subscribe the Channel Please subscribe that team The Old and New Note Mapping Bhi Prevent Multiple Officer SIM Not Stopped And Two And Tried To Pray Jammu To Three And That Subscribe The Channel Ko Subscribe Do subscribe the channe...
Copy List with Random Pointer
copy-list-with-random-pointer
A linked list of length `n` is given such that each node contains an additional random pointer, which could point to any node in the list, or `null`. Construct a [**deep copy**](https://en.wikipedia.org/wiki/Object_copying#Deep_copy) of the list. The deep copy should consist of exactly `n` **brand new** nodes, where e...
Just iterate the linked list and create copies of the nodes on the go. Since a node can be referenced from multiple nodes due to the random pointers, make sure you are not making multiple copies of the same node. You may want to use extra space to keep old node ---> new node mapping to prevent creating multiples copies...
Hash Table,Linked List
Medium
133,1624,1634
500
Hello Rishta Bhi Toot Question Buffets Keyboard Road Problem Hai This Channel Subscribe Now To Receive The Award To Attend It Can Give Voice Keyboard Typing Fast Tips Business And Contains Trees And Plants These Things Are Helpful And Built In The Reports * Helpful And Built In The Reports * Helpful And Built In The Re...
Keyboard Row
keyboard-row
Given an array of strings `words`, return _the words that can be typed using letters of the alphabet on only one row of American keyboard like the image below_. In the **American keyboard**: * the first row consists of the characters `"qwertyuiop "`, * the second row consists of the characters `"asdfghjkl "`, and...
null
Array,Hash Table,String
Easy
null
1,457
welcome to december's leco challenge today's problem is pseudo-palindromic today's problem is pseudo-palindromic today's problem is pseudo-palindromic paths in a binary tree given a binary tree where node values are digits from 1 to 9 a path in the binary tree is said to be pseudopalindromic if at least one permutation...
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
1,624
hey everyone welcome back and let's write some more neat code today so today let's solve the problem largest substring between two equal characters we're given a string s which consists of only lowercase characters A through Z and we want to find the length of the substring between two characters that are equal so the ...
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
65
uh today we're gonna be working on lead quote question number 65 valid number uh a valid number can be split up into these components in order a decimal number an integer and optional is that an e or capital e followed by an integer a decimal number can be split up into these components where we can could be positive o...
Valid Number
valid-number
A **valid number** can be split up into these components (in order): 1. A **decimal number** or an **integer**. 2. (Optional) An `'e'` or `'E'`, followed by an **integer**. A **decimal number** can be split up into these components (in order): 1. (Optional) A sign character (either `'+'` or `'-'`). 2. One of the...
null
String
Hard
8
858
hey you everyone it's your girl xingchi from lico and today i will bring a little heart problem to you guys and it's 8 to 8 come unique characters of all substring of a given string the name is already super confusing right so let's directly down into the description so we're given um we define a function count unique ...
Mirror Reflection
masking-personal-information
There is a special square room with mirrors on each of the four walls. Except for the southwest corner, there are receptors on each of the remaining corners, numbered `0`, `1`, and `2`. The square room has walls of length `p` and a laser ray from the southwest corner first meets the east wall at a distance `q` from th...
null
String
Medium
null
1,448
Welcome to this new inside code video where we&nbsp; will see the "Count good nodes" problem. So, what&nbsp;&nbsp; does the problem say? It says, given a binary tree&nbsp; root, create a function that returns the number of&nbsp;&nbsp; good nodes. A node N is called good if there are&nbsp; no nodes that are greater than...
Count Good Nodes in Binary Tree
maximum-69-number
Given a binary tree `root`, a node _X_ in the tree is named **good** if in the path from root to _X_ there are no nodes with a value _greater than_ X. Return the number of **good** nodes in the binary tree. **Example 1:** **Input:** root = \[3,1,4,3,null,1,5\] **Output:** 4 **Explanation:** Nodes in blue are **good*...
Convert the number in an array of its digits. Brute force on every digit to get the maximum number.
Math,Greedy
Easy
null
515
Hello Hi Everyone Welcome To My Channel It's All The Problem Find Value In History To His Words Meaning 88 Road Yadav 12323 Maximo Subscribe List Of All The Maximum From All Subscribe Le Jis Find Out What Is The Maximum Level Similarly Maximum Volume maximum do this in third level this note Solving this problem by usin...
Find Largest Value in Each Tree Row
find-largest-value-in-each-tree-row
Given the `root` of a binary tree, return _an array of the largest value in each row_ of the tree **(0-indexed)**. **Example 1:** **Input:** root = \[1,3,2,5,3,null,9\] **Output:** \[1,3,9\] **Example 2:** **Input:** root = \[1,2,3\] **Output:** \[1,3\] **Constraints:** * The number of nodes in the tree will be...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Medium
null
1,275
hey everybody this is larry this is day 20 of the september leco daily challenge hit the like button hit the subscribe button join me on discord let me know what you think about today's problem still in spain still in san sebastian i did a long hike yesterday really tired my body is very beat i'm not in shape so anyway...
Find Winner on a Tic Tac Toe Game
validate-binary-tree-nodes
**Tic-tac-toe** is played by two players `A` and `B` on a `3 x 3` grid. The rules of Tic-Tac-Toe are: * Players take turns placing characters into empty squares `' '`. * The first player `A` always places `'X'` characters, while the second player `B` always places `'O'` characters. * `'X'` and `'O'` characters a...
Find the parent of each node. A valid tree must have nodes with only one parent and exactly one node with no parent.
Tree,Depth-First Search,Breadth-First Search,Union Find,Graph,Binary Tree
Medium
null
1,185
hello everybody and welcome back to the DCC channel where in this series we try to solve technical interview questions so I don't know which question to Joe so honestly devised again smallest range single number day of the week that sounds kinda interesting I guess 1185 day of the week given eight return the correspond...
Day of the Week
find-in-mountain-array
Given a date, return the corresponding day of the week for that date. The input is given as three integers representing the `day`, `month` and `year` respectively. Return the answer as one of the following values `{ "Sunday ", "Monday ", "Tuesday ", "Wednesday ", "Thursday ", "Friday ", "Saturday "}`. **Example 1:**...
Based on whether A[i-1] < A[i] < A[i+1], A[i-1] < A[i] > A[i+1], or A[i-1] > A[i] > A[i+1], we are either at the left side, peak, or right side of the mountain. We can binary search to find the peak. After finding the peak, we can binary search two more times to find whether the value occurs on either side of the pea...
Array,Binary Search,Interactive
Hard
882,1766,2205
948
and here I present day 12th of September lead Cod Challenge sincere apologies I was quite occupied with office work just came back from office and here I'm in front of my laptop solving this question up the problem that we have in today is bag of tokens here in this question we are given a game to play and what do we n...
Bag of Tokens
sort-an-array
You have an initial **power** of `power`, an initial **score** of `0`, and a bag of `tokens` where `tokens[i]` is the value of the `ith` token (0-indexed). Your goal is to maximize your total **score** by potentially playing each token in one of two ways: * If your current **power** is at least `tokens[i]`, you may...
null
Array,Divide and Conquer,Sorting,Heap (Priority Queue),Merge Sort,Bucket Sort,Radix Sort,Counting Sort
Medium
null
1,769
hey everybody this is larry this is me going with q2 of the uh weekly contest 229 minimum number of operations to move all boards to each box so this is a kind of a silly problem but i took a long time on this one because i just misread it um the thing i miss well i didn't miss read it but i just didn't really think it...
Minimum Number of Operations to Move All Balls to Each Box
get-maximum-in-generated-array
You have `n` boxes. You are given a binary string `boxes` of length `n`, where `boxes[i]` is `'0'` if the `ith` box is **empty**, and `'1'` if it contains **one** ball. In one operation, you can move **one** ball from a box to an adjacent box. Box `i` is adjacent to box `j` if `abs(i - j) == 1`. Note that after doing ...
Try generating the array. Make sure not to fall in the base case of 0.
Array,Dynamic Programming,Simulation
Easy
null
1
so ground 75 if I may introduce it is all about working through leak code problems that have increasing difficulty I guess so they have these different weeks yeah so you have week one which is these guys here you do some valid parenthesis emergency lists and so on and they're all easy and then I guess they could start ...
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,207
hey what's up guys Nick Boyd here I detect encoding stuff on Twitch in YouTube getting back in after a couple days so I got to start off easy to just get my brain going here this one's super easy I think it's new to 1207 unique number of occurrences given an array of integers array write a function that returns true if...
Unique Number of Occurrences
delete-nodes-and-return-forest
Given an array of integers `arr`, return `true` _if the number of occurrences of each value in the array is **unique** or_ `false` _otherwise_. **Example 1:** **Input:** arr = \[1,2,2,1,1,3\] **Output:** true **Explanation:** The value 1 has 3 occurrences, 2 has 2 and 3 has 1. No two values have the same number of oc...
null
Tree,Depth-First Search,Binary Tree
Medium
2175
139
hey guys welcome back to another video and today we're going to be solving the leakout question work break all right so in this question we're given a non-empty string given a non-empty string given a non-empty string s and a dictionary word dict which contains a list of non-empty words contains a list of non-empty wor...
Word Break
word-break
Given a string `s` and a dictionary of strings `wordDict`, return `true` if `s` can be segmented into a space-separated sequence of one or more dictionary words. **Note** that the same word in the dictionary may be reused multiple times in the segmentation. **Example 1:** **Input:** s = "leetcode ", wordDict = \[ "...
null
Hash Table,String,Dynamic Programming,Trie,Memoization
Medium
140
1,723
so today we are going to show off problem or find minimum time to finish all the job you have given an array where job I is the amount of time it's take to complete the Ayah job and you have to given K worker you have to assign the job to the cable curve such that it will take the minimum time and you have to return th...
Find Minimum Time to Finish All Jobs
maximum-number-of-achievable-transfer-requests
You are given an integer array `jobs`, where `jobs[i]` is the amount of time it takes to complete the `ith` job. There are `k` workers that you can assign jobs to. Each job should be assigned to **exactly** one worker. The **working time** of a worker is the sum of the time it takes to complete all jobs assigned to th...
Think brute force When is a subset of requests okay?
Array,Backtracking,Bit Manipulation,Enumeration
Hard
null