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
1,887
and good afternoon to all of you today we have problem which name is reduction operation to make the array element equal lead code B8 87 problem so before going forward in this video please make sure that you have like And subscribe to this Channel and also it's my advice to all of you that please read the problem care...
Reduction Operations to Make the Array Elements Equal
minimum-degree-of-a-connected-trio-in-a-graph
Given an integer array `nums`, your goal is to make all elements in `nums` equal. To complete one operation, follow these steps: 1. Find the **largest** value in `nums`. Let its index be `i` (**0-indexed**) and its value be `largest`. If there are multiple elements with the largest value, pick the smallest `i`. 2. F...
Consider a trio with nodes u, v, and w. The degree of the trio is just degree(u) + degree(v) + degree(w) - 6. The -6 comes from subtracting the edges u-v, u-w, and v-w, which are counted twice each in the vertex degree calculation. To get the trios (u,v,w), you can iterate on u, then iterate on each w,v such that w and...
Graph
Hard
null
729
hey everybody this is larry this is day three of the august leco day challenge hit the like button hit the subscribe button join me on discord let me know what you think about today's problem uh yeah just a random quick update i did trivia night here in new york there's a trivia league uh definitely recommend everyone ...
My Calendar I
my-calendar-i
You are implementing a program to use as your calendar. We can add a new event if adding the event will not cause a **double booking**. A **double booking** happens when two events have some non-empty intersection (i.e., some moment is common to both events.). The event can be represented as a pair of integers `start...
Store the events as a sorted list of intervals. If none of the events conflict, then the new event can be added.
Design,Segment Tree,Ordered Set
Medium
731,732
767
Hello gas welcome to me YouTube channel so today we are going to solve the problem seven six seven your nice string so what is the question that I have been given a string and the characters have to be rearranged in such a way that any two characters It should not be equal. The one with adjustment is fine as it is, so ...
Reorganize String
prime-number-of-set-bits-in-binary-representation
Given a string `s`, rearrange the characters of `s` so that any two adjacent characters are not the same. Return _any possible rearrangement of_ `s` _or return_ `" "` _if not possible_. **Example 1:** **Input:** s = "aab" **Output:** "aba" **Example 2:** **Input:** s = "aaab" **Output:** "" **Constraints:** * ...
Write a helper function to count the number of set bits in a number, then check whether the number of set bits is 2, 3, 5, 7, 11, 13, 17 or 19.
Math,Bit Manipulation
Easy
191
63
Aa Gayi Ab School And Welcome To Brothers Pages In This Video You Will See The Question Unique Part-2 Situated At The Top Left Corner Part-2 Situated At The Top Left Corner Part-2 Situated At The Top Left Corner And Download The Bottom Right Corner Of Northern Part Of Speech And Travels And Tours And Travels Distractio...
Unique Paths II
unique-paths-ii
You are given an `m x n` integer array `grid`. There is a robot initially located at the **top-left corner** (i.e., `grid[0][0]`). The robot tries to move to the **bottom-right corner** (i.e., `grid[m - 1][n - 1]`). The robot can only move either down or right at any point in time. An obstacle and space are marked as ...
The robot can only move either down or right. Hence any cell in the first row can only be reached from the cell left to it. However, if any cell has an obstacle, you don't let that cell contribute to any path. So, for the first row, the number of ways will simply be if obstacleGrid[i][j] is not an obstacle ...
Array,Dynamic Programming,Matrix
Medium
62,1022
1,689
hello friends so today in this video we're gonna discuss a problem from lead code which is a medium problem name is partition into minimum number of deci binary numbers so the code is very simple i'll first tell you what the problem statement is telling you to do it states that you are given a decimal number in desi bi...
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
1,588
hi i am shim gupta and today we are solving some of all odd length summaries it is a easy level problem on lead code uh problem is very straightforward like uh they give us a vector i have to return the sum of all odd length subsequence of this array like uh what will be the odd subsequence let uh see from this explana...
Sum of All Odd Length Subarrays
sum-of-all-odd-length-subarrays
Given an array of positive integers `arr`, return _the sum of all possible **odd-length subarrays** of_ `arr`. A **subarray** is a contiguous subsequence of the array. **Example 1:** **Input:** arr = \[1,4,2,5,3\] **Output:** 58 **Explanation:** The odd-length subarrays of arr and their sums are: \[1\] = 1 \[4\] = 4...
null
null
Easy
null
173
welcome to tim's leco challenge this problem is called binary search tree iterator implement the bst iterator class that represents an iterator over the in order traversal of a binary search tree now what is the in order traversal of a binary search tree if you recall it's basically the leftmost then the node itself an...
Binary Search Tree Iterator
binary-search-tree-iterator
Implement the `BSTIterator` class that represents an iterator over the **[in-order traversal](https://en.wikipedia.org/wiki/Tree_traversal#In-order_(LNR))** of a binary search tree (BST): * `BSTIterator(TreeNode root)` Initializes an object of the `BSTIterator` class. The `root` of the BST is given as part of the co...
null
Stack,Tree,Design,Binary Search Tree,Binary Tree,Iterator
Medium
94,251,281,284,285,1729
965
hello friends so today we are going to discuss another lead code problem the problem is uni valued binary tree so what is the problem description so we are given a binary tree and we have to check whether the tree is uni value so what does it mean univolu means what so if every node in the tree has the same value and w...
Univalued Binary Tree
unique-email-addresses
A binary tree is **uni-valued** if every node in the tree has the same value. Given the `root` of a binary tree, return `true` _if the given tree is **uni-valued**, or_ `false` _otherwise._ **Example 1:** **Input:** root = \[1,1,1,1,1,null,1\] **Output:** true **Example 2:** **Input:** root = \[2,2,2,5,2\] **Outpu...
null
Array,Hash Table,String
Easy
null
1,751
hey everyone welcome back and let's solve our more lead code problem today so today we're going to solve lead code uh 1751 which is going to be the maximum number of events that can be attended too uh so we're given an array of events where each event consists of three value or three values which is the start date the ...
Maximum Number of Events That Can Be Attended II
slowest-key
You are given an array of `events` where `events[i] = [startDayi, endDayi, valuei]`. The `ith` event starts at `startDayi` and ends at `endDayi`, and if you attend this event, you will receive a value of `valuei`. You are also given an integer `k` which represents the maximum number of events you can attend. You can o...
Get for each press its key and amount of time taken. Iterate on the presses, maintaining the answer so far. The current press will change the answer if and only if its amount of time taken is longer than that of the previous answer, or they are equal but the key is larger than that of the previous answer.
Array,String
Easy
null
654
hey everybody this is Larry this is day 20th or gen 20th I'm trying to do more uh basically we've done the pro or I've done the prom that the daily uh prom is and I'm trying to get my money's worth by picking one random PR I haven't done before and today's random PR is 998 maximum binary tree 2 it's a medium prom uh an...
Maximum Binary Tree
maximum-binary-tree
You are given an integer array `nums` with no duplicates. A **maximum binary tree** can be built recursively from `nums` using the following algorithm: 1. Create a root node whose value is the maximum value in `nums`. 2. Recursively build the left subtree on the **subarray prefix** to the **left** of the maximum val...
null
Array,Divide and Conquer,Stack,Tree,Monotonic Stack,Binary Tree
Medium
1040
760
hey guys today we're going to talk about rico 760. you know since i didn't pay the premium and so i cannot access it but i found a tweak they you know sim crush in lincol you can if you don't know his website he use it too you know they give you access to the premium problems in legal and basically the question is find...
Find Anagram Mappings
bold-words-in-string
You are given two integer arrays `nums1` and `nums2` where `nums2` is **an anagram** of `nums1`. Both arrays may contain duplicates. Return _an index mapping array_ `mapping` _from_ `nums1` _to_ `nums2` _where_ `mapping[i] = j` _means the_ `ith` _element in_ `nums1` _appears in_ `nums2` _at index_ `j`. If there are mu...
First, determine which letters are bold and store that information in mask[i] = if i-th character is bold. Then, insert the tags at the beginning and end of groups. The start of a group is if and only if (mask[i] and (i == 0 or not mask[i-1])), and the end of a group is similar.
Array,Hash Table,String,Trie,String Matching
Medium
null
1,091
hey everyone welcome back today we are going to solve problem number 1091 shortest path in binary Matrix first we will see the expansion of the problem statement then the logic and the code now let's dive into the solution so here I have taken the second example from the lake website so here we are given a binary Matri...
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
930
See in this video we are going to do question let code 930 binary sub ares with some live now binary are i.e live now binary are i.e live now binary are i.e one iragi of zero and one wait goal will be given to you d return d number of non empty sub is with some goal aisi kitni It will be sub ars whose sum is tu hai sab...
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,652
hey guys welcome back to my channel and i'm back again with another really interesting coding interview question video today guys we are going to solve questionable 1652 diffuse the bomb of lead code before i start with the video guys if you have not yet subscribed to my channel then please do subscribe and hit the bel...
Defuse the Bomb
minimum-suffix-flips
You have a bomb to defuse, and your time is running out! Your informer will provide you with a **circular** array `code` of length of `n` and a key `k`. To decrypt the code, you must replace every number. All the numbers are replaced **simultaneously**. * If `k > 0`, replace the `ith` number with the sum of the **n...
Consider a strategy where the choice of bulb with number i is increasing. In such a strategy, you no longer need to worry about bulbs that have been set to the left.
String,Greedy
Medium
null
67
Loot Hello Viewers Welcome Back To My Channel Suggestion Or Their Discussion Of The Problem With Difficult For Me To Death You Not Laga Do Video Please Like It Subscribe To My Channel Subah You Get Notified When The Most Innovative Without Any Positive Let's Get Started Problem In Add Binary Very Simple Problem Jeevan ...
Add Binary
add-binary
Given two binary strings `a` and `b`, return _their sum as a binary string_. **Example 1:** **Input:** a = "11", b = "1" **Output:** "100" **Example 2:** **Input:** a = "1010", b = "1011" **Output:** "10101" **Constraints:** * `1 <= a.length, b.length <= 104` * `a` and `b` consist only of `'0'` or `'1'` chara...
null
Math,String,Bit Manipulation,Simulation
Easy
2,43,66,1031
1,071
hey everyone welcome to techquired in this video we are going to solve problem number 1071 greatest common divisor of strings so here we are given two strings we need to find the largest string that divides both string 1 and string two and now let's see the logic on the solution for this problem so this is the first ex...
Greatest Common Divisor of Strings
binary-prefix-divisible-by-5
For two strings `s` and `t`, we say "`t` divides `s` " if and only if `s = t + ... + t` (i.e., `t` is concatenated with itself one or more times). Given two strings `str1` and `str2`, return _the largest string_ `x` _such that_ `x` _divides both_ `str1` _and_ `str2`. **Example 1:** **Input:** str1 = "ABCABC ", str2...
If X is the first i digits of the array as a binary number, then 2X + A[i] is the first i+1 digits.
Array
Easy
null
1,290
in this video we're going to go over elite code problem which is convert binary number in a linked list to integer so you have a binary number and you want to make it into an integer a decimal number base 10. so binary is base two that's something you need to know for this problem it's not terribly job specific thing s...
Convert Binary Number in a Linked List to Integer
make-array-strictly-increasing
Given `head` which is a reference node to a singly-linked list. The value of each node in the linked list is either `0` or `1`. The linked list holds the binary representation of a number. Return the _decimal value_ of the number in the linked list. The **most significant bit** is at the head of the linked list. **E...
Use dynamic programming. The state would be the index in arr1 and the index of the previous element in arr2 after sorting it and removing duplicates.
Array,Binary Search,Dynamic Programming
Hard
null
1,968
hey everybody this is larry this is me going with q2 of the weekly contest 254 a wave of elements not equal to at rich of neighbors hit the like button hit the subscribe button join me on discord especially if you like these kind of contest forms people talk about the problems all the time usually right after the conte...
Array With Elements Not Equal to Average of Neighbors
maximum-building-height
You are given a **0-indexed** array `nums` of **distinct** integers. You want to rearrange the elements in the array such that every element in the rearranged array is **not** equal to the **average** of its neighbors. More formally, the rearranged array should have the property such that for every `i` in the range `1...
Is it possible to find the max height if given the height range of a particular building? You can find the height range of a restricted building by doing 2 passes from the left and right.
Array,Math
Hard
null
508
uh this question is most frequent subtree sum so you are given a root and then particular return the most frequent subtruism so just keep adding and then for every single frequency you just put into the map or print to the counter and then you want to keep on track for the mass the highest frequency this is because if ...
Most Frequent Subtree Sum
most-frequent-subtree-sum
Given the `root` of a binary tree, return the most frequent **subtree sum**. If there is a tie, return all the values with the highest frequency in any order. The **subtree sum** of a node is defined as the sum of all the node values formed by the subtree rooted at that node (including the node itself). **Example 1:*...
null
Hash Table,Tree,Depth-First Search,Binary Tree
Medium
572,2126
329
hey everyone today we'll be looking at longest increasing path in a matrix we'll try to solve it in less than 15 minutes okay it's a hard problem so hopefully we can solve it but if not then need code Baba zindabad let's do this okay given an M N M and N integer mean Matrix return the length of the longest increasing p...
Longest Increasing Path in a Matrix
longest-increasing-path-in-a-matrix
Given an `m x n` integers `matrix`, return _the length of the longest increasing path in_ `matrix`. From each cell, you can either move in four directions: left, right, up, or down. You **may not** move **diagonally** or move **outside the boundary** (i.e., wrap-around is not allowed). **Example 1:** **Input:** matr...
null
Dynamic Programming,Depth-First Search,Breadth-First Search,Graph,Topological Sort,Memoization
Hard
null
1,539
hey guys welcome back to another video and today we're going to be solving the leakout question kate missing positive number alright so this question is an easy question but i think it is a little bit more complicated than that so let's actually see how we can solve this question okay so before that so in this question...
Kth Missing Positive Number
diagonal-traverse-ii
Given an array `arr` of positive integers sorted in a **strictly increasing order**, and an integer `k`. Return _the_ `kth` _**positive** integer that is **missing** from this array._ **Example 1:** **Input:** arr = \[2,3,4,7,11\], k = 5 **Output:** 9 **Explanation:** The missing positive integers are \[1,5,6,8,9,10...
Notice that numbers with equal sums of row and column indexes belong to the same diagonal. Store them in tuples (sum, row, val), sort them, and then regroup the answer.
Array,Sorting,Heap (Priority Queue)
Medium
null
16
hello everyone today we're going to be looking at three sum closest which is lead code problem number 16 this is a medium problem and it states given an integer array nums of length n in an integer Target find three integers in gnomes such that the sum is closest to Target so return the sum of the three integers we don...
3Sum Closest
3sum-closest
Given an integer array `nums` of length `n` and an integer `target`, find three integers in `nums` such that the sum is closest to `target`. Return _the sum of the three integers_. You may assume that each input would have exactly one solution. **Example 1:** **Input:** nums = \[-1,2,1,-4\], target = 1 **Output:** ...
null
Array,Two Pointers,Sorting
Medium
15,259
138
hello everyone welcome to day 12 of march lead code challenge and i hope all of you are having a great time even before jumping onto the details of today's question i would like to inform all of you out there that today i am going live it's gonna be the first the second doubt clearing session along with this i'll be gi...
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
1,395
hi guys hope you're fine and doing well so today we will be discussing this problem from the lead code which is count number of teams so this is the 19th problem of the dynamic programming series so if you haven't watched the previous videos you can consider watching them since it will be really helpful for you to unde...
Count Number of Teams
minimum-time-visiting-all-points
There are `n` soldiers standing in a line. Each soldier is assigned a **unique** `rating` value. You have to form a team of 3 soldiers amongst them under the following rules: * Choose 3 soldiers with index (`i`, `j`, `k`) with rating (`rating[i]`, `rating[j]`, `rating[k]`). * A team is valid if: (`rating[i] < rat...
To walk from point A to point B there will be an optimal strategy to walk ? Advance in diagonal as possible then after that go in straight line. Repeat the process until visiting all the points.
Array,Math,Geometry
Easy
null
151
Hi guys, welcome to the channel, you are doing 90 days software engineering prep with me, this is question number six, lead code is the overall question of 75, lead code is 151 question, reverse words in a string, okay so what is the question, let me show you. You have been given a string, The Sky is Blue, you have to ...
Reverse Words in a String
reverse-words-in-a-string
Given an input string `s`, reverse the order of the **words**. A **word** is defined as a sequence of non-space characters. The **words** in `s` will be separated by at least one space. Return _a string of the words in reverse order concatenated by a single space._ **Note** that `s` may contain leading or trailing s...
null
Two Pointers,String
Medium
186
126
hello everybody is a male and today I'm going to teach you how to solve the many rooms to problem given an array of meeting time intervals consisting of start and end times find the minimum number of conference rooms required example 1 the input is this list of intervals so every interval has a start time and an end ti...
Word Ladder II
word-ladder-ii
A **transformation sequence** from word `beginWord` to word `endWord` using a dictionary `wordList` is a sequence of words `beginWord -> s1 -> s2 -> ... -> sk` such that: * Every adjacent pair of words differs by a single letter. * Every `si` for `1 <= i <= k` is in `wordList`. Note that `beginWord` does not need ...
null
Hash Table,String,Backtracking,Breadth-First Search
Hard
127,2276
1,071
hey everybody this is Larry this is February first day of the uh the code daily challenge hit the like button hit the Subscribe button uh join me on Discord let me know what you think about today's prom and easy one and uh yeah if you're joining us uh look I'm on the lead code contest page because there's a click for 1...
Greatest Common Divisor of Strings
binary-prefix-divisible-by-5
For two strings `s` and `t`, we say "`t` divides `s` " if and only if `s = t + ... + t` (i.e., `t` is concatenated with itself one or more times). Given two strings `str1` and `str2`, return _the largest string_ `x` _such that_ `x` _divides both_ `str1` _and_ `str2`. **Example 1:** **Input:** str1 = "ABCABC ", str2...
If X is the first i digits of the array as a binary number, then 2X + A[i] is the first i+1 digits.
Array
Easy
null
445
Hello Hi Guys Welcome To Kushwaha Set Two Numbers Part 2 In This Question Science And MP Link Playlist Details * And MP Link Playlist Details * And MP Link Playlist Details * non-resident Indians Team Mostly Acid non-resident Indians Team Mostly Acid non-resident Indians Team Mostly Acid Comes First And Inch Of The Not...
Add Two Numbers II
add-two-numbers-ii
You are given two **non-empty** linked lists representing two non-negative integers. The most significant digit comes first 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 itsel...
null
Linked List,Math,Stack
Medium
2,1774
270
okay let's do today's question 270 closest the binary search tree value the question is given the number deputy binary search tree and the target value we need to find the value in the binary search tree that is closest to the target the dart endowed skier given target value is a 13-point the second target value is a 1...
Closest Binary Search Tree Value
closest-binary-search-tree-value
Given the `root` of a binary search tree and a `target` value, return _the value in the BST that is closest to the_ `target`. If there are multiple answers, print the smallest. **Example 1:** **Input:** root = \[4,2,5,1,3\], target = 3.714286 **Output:** 4 **Example 2:** **Input:** root = \[1\], target = 4.428571 *...
null
Binary Search,Tree,Depth-First Search,Binary Search Tree,Binary Tree
Easy
222,272,783
133
welcome back to Cod Meets World today we're looking at Elite code problem number 133 which is called clone graph so given a reference of a node in a connected undirected graph we need to return a deep copy a clone of that graph so each node in the graph contains a value which is an integer and then a list of all of its...
Clone Graph
clone-graph
Given a reference of a node in a **[connected](https://en.wikipedia.org/wiki/Connectivity_(graph_theory)#Connected_graph)** undirected graph. Return a [**deep copy**](https://en.wikipedia.org/wiki/Object_copying#Deep_copy) (clone) of the graph. Each node in the graph contains a value (`int`) and a list (`List[Node]`)...
null
Hash Table,Depth-First Search,Breadth-First Search,Graph
Medium
138,1624,1634
1,349
yes today we are going to solve a little co2 problem in 1349 it's a hard problem and it's posted by Rahul right so as always we are going to explain this problem by introduce the example here so in the input we are going to have a two-dimensional array and this array two-dimensional array and this array two-dimensional...
Maximum Students Taking Exam
check-if-it-is-a-straight-line
Given a `m * n` matrix `seats` that represent seats distributions in a classroom. If a seat is broken, it is denoted by `'#'` character otherwise it is denoted by a `'.'` character. Students can see the answers of those sitting next to the left, right, upper left and upper right, but he cannot see the answers of the s...
If there're only 2 points, return true. Check if all other points lie on the line defined by the first 2 points. Use cross product to check collinearity.
Array,Math,Geometry
Easy
null
1,716
Hello everyone welcome to my channel Quote Surrey with Mike So today we are going to do video number 18 of our maths playlist, it is marked easy but it is a very good question, we made it approachable, number 1716 is calculate money in lead code bank ok so let's see. What the question is trying to say is that Hersey wa...
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
5
hey so welcome back and there's another daily kill problem so today it's called longest palindromics substring and it's medium level dynamic programming problem and so essentially what you want to do is just find the longest uh pandoromic substring and what that is while a substring is when you just take a kind of fixe...
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
56
welcome to dab the light development done right and today I'm going to be solving a lead code problem number 56 merchant rules let's get started and don't forget to Like and subscribe merge intervals given a collection of intervals merge all overlapping intervals now this is a common type of problem sometimes they call...
Merge Intervals
merge-intervals
Given an array of `intervals` where `intervals[i] = [starti, endi]`, merge all overlapping intervals, and return _an array of the non-overlapping intervals that cover all the intervals in the input_. **Example 1:** **Input:** intervals = \[\[1,3\],\[2,6\],\[8,10\],\[15,18\]\] **Output:** \[\[1,6\],\[8,10\],\[15,18\]\...
null
Array,Sorting
Medium
57,252,253,495,616,715,761,768,1028,2297,2319
14
hi today we're going to be going over the java solution for lead code 14. longest common prefix write a function to write the longest common prefix string amongst an array of strings if there is no common prefix return an empty string as i guess given here so prefix means basically the starting letters of a word so you...
Longest Common Prefix
longest-common-prefix
Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string `" "`. **Example 1:** **Input:** strs = \[ "flower ", "flow ", "flight "\] **Output:** "fl " **Example 2:** **Input:** strs = \[ "dog ", "racecar ", "car "\] **Output:** " "...
null
String
Easy
null
310
hey guys what's up today's question we're going to say the three one low the minimum high trees is that giving us the 2d array which is uh in edges and it will be represented by the connection between two nodes and it wanted us to find the minimum high tree the root of a minimum high tree uh and uh for this for example...
Minimum Height Trees
minimum-height-trees
A tree is an undirected graph in which any two vertices are connected by _exactly_ one path. In other words, any connected graph without simple cycles is a tree. Given a tree of `n` nodes labelled from `0` to `n - 1`, and an array of `n - 1` `edges` where `edges[i] = [ai, bi]` indicates that there is an undirected edg...
How many MHTs can a graph have at most?
Depth-First Search,Breadth-First Search,Graph,Topological Sort
Medium
207,210
1,822
hey everyone today we are going to solve the little question sign of the product of an array so there is a function sine func X and that returns one if x is positive a minus 1 if x is negative zero if x is equal to zero so you are given integer array nouns let product be the product of all values in the array nouns ret...
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,802
hey everybody this is larry just me going with q3 of the weekly contest 233 uh maximum value at a given index in a bounded array um so this is a binary search problem i had a lot of struggles of this mostly because of a typo that i didn't catch uh and also i had some debugging code that i actually left in the submissio...
Maximum Value at a Given Index in a Bounded Array
number-of-students-unable-to-eat-lunch
You are given three positive integers: `n`, `index`, and `maxSum`. You want to construct an array `nums` (**0-indexed**) that satisfies the following conditions: * `nums.length == n` * `nums[i]` is a **positive** integer where `0 <= i < n`. * `abs(nums[i] - nums[i+1]) <= 1` where `0 <= i < n-1`. * The sum of a...
Simulate the given in the statement Calculate those who will eat instead of those who will not.
Array,Stack,Queue,Simulation
Easy
2195
70
hi guys welcome to algorithms made easy today we will go through the day 31 problem from july lead coding challenge climbing stairs please like the video and if you are new don't forget to subscribe to our channel so that you never miss any update suppose you are climbing a staircase and it takes n steps to reach to th...
Climbing Stairs
climbing-stairs
You are climbing a staircase. It takes `n` steps to reach the top. Each time you can either climb `1` or `2` steps. In how many distinct ways can you climb to the top? **Example 1:** **Input:** n = 2 **Output:** 2 **Explanation:** There are two ways to climb to the top. 1. 1 step + 1 step 2. 2 steps **Example 2:** ...
To reach nth step, what could have been your previous steps? (Think about the step sizes)
Math,Dynamic Programming,Memoization
Easy
747,1013,1236
523
all right I'll be solving continuous sub array sum and I think it's not medium it's going to be hard the level because yeah the logic here it's highly mathematical so let's take step by step and take for example this so basically the question is if you can find a sum of sub array that is a multiple of K so 6 is a multi...
Continuous Subarray Sum
continuous-subarray-sum
Given an integer array nums and an integer k, return `true` _if_ `nums` _has a **good subarray** or_ `false` _otherwise_. A **good subarray** is a subarray where: * its length is **at least two**, and * the sum of the elements of the subarray is a multiple of `k`. **Note** that: * A **subarray** is a contiguo...
null
Array,Hash Table,Math,Prefix Sum
Medium
560,2119,2240
347
okay guys let's solve top K frequent elements number 347 on leak code so given an integer array of nums and another integer K we need to return the K most frequent elements and you may return the answer in any order so that's pretty simple it's just the top K most occurring elements so for example with the numbers of 1...
Top K Frequent Elements
top-k-frequent-elements
Given an integer array `nums` and an integer `k`, return _the_ `k` _most frequent elements_. You may return the answer in **any order**. **Example 1:** **Input:** nums = \[1,1,1,2,2,3\], k = 2 **Output:** \[1,2\] **Example 2:** **Input:** nums = \[1\], k = 1 **Output:** \[1\] **Constraints:** * `1 <= nums.lengt...
null
Array,Hash Table,Divide and Conquer,Sorting,Heap (Priority Queue),Bucket Sort,Counting,Quickselect
Medium
192,215,451,659,692,1014,1919
968
hey guys welcome to algorithms made easy i am khushboo and in this video we are going to see the question binary tree cameras given a binary tree we install cameras on node of that tree each camera at a node can monitor its parent itself and its immediate children calculate the minimum number of cameras needed to monit...
Binary Tree Cameras
beautiful-array
You are given the `root` of a binary tree. We install cameras on the tree nodes where each camera at a node can monitor its parent, itself, and its immediate children. Return _the minimum number of cameras needed to monitor all nodes of the tree_. **Example 1:** **Input:** root = \[0,0,null,0,0\] **Output:** 1 **Exp...
null
Array,Math,Divide and Conquer
Medium
null
1,168
hello everyone this is yosando today let's talk about lit code 1168 optimized water distribution village if you like my videos please support me by subscribing my channel you can find the code of this program and the complete code list new video description link below look at the problem first we are given a house in a...
Optimize Water Distribution in a Village
duplicate-zeros
There are `n` houses in a village. We want to supply water for all the houses by building wells and laying pipes. For each house `i`, we can either build a well inside it directly with cost `wells[i - 1]` (note the `-1` due to **0-indexing**), or pipe in water from another well to it. The costs to lay pipes between ho...
This is a great introductory problem for understanding and working with the concept of in-place operations. The problem statement clearly states that we are to modify the array in-place. That does not mean we cannot use another array. We just don't have to return anything. A better way to solve this would be without us...
Array,Two Pointers
Easy
null