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,295
hello municipal i am aayushi roy jo welcome to my channel twisted tours to introduce solution box open list code problem numbers with number of this movement and subscribe like every time subscribe problem se give me the number 90 vihar two example give me value of 5a 5216 From these and without this to fix well and fr...
Find Numbers with Even Number of Digits
minimum-garden-perimeter-to-collect-enough-apples
Given an array `nums` of integers, return how many of them contain an **even number** of digits. **Example 1:** **Input:** nums = \[12,345,2,6,7896\] **Output:** 2 **Explanation:** 12 contains 2 digits (even number of digits). 345 contains 3 digits (odd number of digits). 2 contains 1 digit (odd number of digits)....
Find a formula for the number of apples inside a square with a side length L. Iterate over the possible lengths of the square until enough apples are collected.
Math,Binary Search
Medium
null
875
Hello everyone, today we discuss the problem number of the list, this is 25o setting making in this and we have suppose it is okay to make for laying, making from paragraph Vivek and in every subject something or the other has to be made and what is it that you are given a proverb. Time has been given, okay, and you ha...
Koko Eating Bananas
longest-mountain-in-array
Koko loves to eat bananas. There are `n` piles of bananas, the `ith` pile has `piles[i]` bananas. The guards have gone and will come back in `h` hours. Koko can decide her bananas-per-hour eating speed of `k`. Each hour, she chooses some pile of bananas and eats `k` bananas from that pile. If the pile has less than `k...
null
Array,Two Pointers,Dynamic Programming,Enumeration
Medium
1766,2205
309
hey folks welcome back to another video today we'll be looking at question 309 best time to buy and sell stocks with cooldown so the way we'll be solving this problem is by using dynamic programming and the basis of this entire solution is that we'll be storing states uh of the maximum profit that you can earn at every...
Best Time to Buy and Sell Stock with Cooldown
best-time-to-buy-and-sell-stock-with-cooldown
You are given an array `prices` where `prices[i]` is the price of a given stock on the `ith` day. Find the maximum profit you can achieve. You may complete as many transactions as you like (i.e., buy one and sell one share of the stock multiple times) with the following restrictions: * After you sell your stock, yo...
null
Array,Dynamic Programming
Medium
121,122
68
text justification in JavaScript this is a hard problem it's very tedious and messy with little edge cases and things to watch out for given an array of strings words and a word and a width Max width format the text such that each line is exactly maxed with characters and is fully left and right Justified you should pa...
Text Justification
text-justification
Given an array of strings `words` and a width `maxWidth`, format the text such that each line has exactly `maxWidth` characters and is fully (left and right) justified. You should pack your words in a greedy approach; that is, pack as many words as you can in each line. Pad extra spaces `' '` when necessary so that ea...
null
Array,String,Simulation
Hard
1714,2260
61
hi friends welcome back today we are going to solve lead code problem 61 rotate list so given the head of a linked list rotate the list to the right by k places so let's just consider this first example which i have it here so this is the list that we have been given one two three four five and we have to rotate it by ...
Rotate List
rotate-list
Given the `head` of a linked list, rotate the list to the right by `k` places. **Example 1:** **Input:** head = \[1,2,3,4,5\], k = 2 **Output:** \[4,5,1,2,3\] **Example 2:** **Input:** head = \[0,1,2\], k = 4 **Output:** \[2,0,1\] **Constraints:** * The number of nodes in the list is in the range `[0, 500]`. * ...
null
Linked List,Two Pointers
Medium
189,725
1,041
Jhaal hello everyone welcome and welcome back to my channel today were going to solve the problem with different for different video please like and subscribe my channel subah kyunki not fur when and nutrition new video software for any positive let's get started show the problem is this robot Bonding current very easy...
Robot Bounded In Circle
available-captures-for-rook
On an infinite plane, a robot initially stands at `(0, 0)` and faces north. Note that: * The **north direction** is the positive direction of the y-axis. * The **south direction** is the negative direction of the y-axis. * The **east direction** is the positive direction of the x-axis. * The **west direction**...
null
Array,Matrix,Simulation
Easy
null
1,091
[Laughter] hey everybody this is larry this is day 16 of the mainly go daily challenge the like button to subscribe and join me in discord let me know what you think about today's farm and especially that intro uh as you can tell or maybe not i don't know i'm in atlanta so i'm just hanging out and trying to figure out ...
Shortest Path in Binary Matrix
maximum-average-subtree
Given an `n x n` binary matrix `grid`, return _the length of the shortest **clear path** in the matrix_. If there is no clear path, return `-1`. A **clear path** in a binary matrix is a path from the **top-left** cell (i.e., `(0, 0)`) to the **bottom-right** cell (i.e., `(n - 1, n - 1)`) such that: * All the visite...
Can you find the sum of values and the number of nodes for every sub-tree ? Can you find the sum of values and the number of nodes for a sub-tree given the sum of values and the number of nodes of it's left and right sub-trees ? Use depth first search to recursively find the solution for the children of a node then use...
Tree,Depth-First Search,Binary Tree
Medium
2126
1,806
hey everybody this is larry this is me going with q2 of the weekly contest 234 minimum number of operations to reinitiate uh a permutation um hit the like button hit the subscribe button join me on discord so you can ask me questions about this other problems whatever you like um but yeah this is basically a simulation...
Minimum Number of Operations to Reinitialize a Permutation
count-of-matches-in-tournament
You are given an **even** integer `n`​​​​​​. You initially have a permutation `perm` of size `n`​​ where `perm[i] == i`​ **(0-indexed)**​​​​. In one operation, you will create a new array `arr`, and for each `i`: * If `i % 2 == 0`, then `arr[i] = perm[i / 2]`. * If `i % 2 == 1`, then `arr[i] = perm[n / 2 + (i - 1...
Simulate the tournament as given in the statement. Be careful when handling odd integers.
Math,Simulation
Easy
null
231
today we will solve a very simple problem of checking whether a number is a power of 2 or not so first thing you must know about the numbers which are power of 2 like 2 4 6 and not 6 2 4 8 16 32 and so on and even one is that they have just one bit set in them for example here are four examples of numbers which are pow...
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
1,854
do that welcome back friends today we are going to solve lift problem 850 char maximum population hair soft reminder already aware that will come open create solution videos in java j2ee interview helpful videos and would have created a big play list all ur videos 28 over 65 problem Solve and Explain Along with Example...
Maximum Population Year
maximum-population-year
You are given a 2D integer array `logs` where each `logs[i] = [birthi, deathi]` indicates the birth and death years of the `ith` person. The **population** of some year `x` is the number of people alive during that year. The `ith` person is counted in year `x`'s population if `x` is in the **inclusive** range `[birthi...
null
null
Easy
null
954
given that array of integers with even less design an algorithm to check whether this array can be reordered such that in two pairs one number in the pair is exactly the twice the other number that's about today's video Valley this is where my dream started hi everyone this is Steve here today we are going through a li...
Array of Doubled Pairs
maximum-sum-circular-subarray
Given an integer array of even length `arr`, return `true` _if it is possible to reorder_ `arr` _such that_ `arr[2 * i + 1] = 2 * arr[2 * i]` _for every_ `0 <= i < len(arr) / 2`_, or_ `false` _otherwise_. **Example 1:** **Input:** arr = \[3,1,3,6\] **Output:** false **Example 2:** **Input:** arr = \[2,1,2,6\] **Out...
For those of you who are familiar with the Kadane's algorithm, think in terms of that. For the newbies, Kadane's algorithm is used to finding the maximum sum subarray from a given array. This problem is a twist on that idea and it is advisable to read up on that algorithm first before starting this problem. Unless you ...
Array,Divide and Conquer,Dynamic Programming,Queue,Monotonic Queue
Medium
null
47
welcome to jbk school today we are going to solve number 47 permutation 2. so this is very similar at the Legacy that we served as 46 permutations and there is Norms array and then um we are gonna return all the possible Plantation but it should be unique so we are going to start first of all we are gonna sort this num...
Permutations II
permutations-ii
Given a collection of numbers, `nums`, that might contain duplicates, return _all possible unique permutations **in any order**._ **Example 1:** **Input:** nums = \[1,1,2\] **Output:** \[\[1,1,2\], \[1,2,1\], \[2,1,1\]\] **Example 2:** **Input:** nums = \[1,2,3\] **Output:** \[\[1,2,3\],\[1,3,2\],\[2,1,3\],\[2,3,...
null
Array,Backtracking
Medium
31,46,267,1038
1,198
It is the number my elite qods belt that is called annoying fans as an element but rose what this problem is very simple we have this matrix and we have to find what is the smallest number that appears in all the rows for that we go to census of binary search society into account we only have to use the numbers in the ...
Find Smallest Common Element in All Rows
unpopular-books
Given an `m x n` matrix `mat` where every row is sorted in **strictly** **increasing** order, return _the **smallest common element** in all rows_. If there is no common element, return `-1`. **Example 1:** **Input:** mat = \[\[1,2,3,4,5\],\[2,4,5,8,10\],\[3,5,7,9,11\],\[1,3,5,7,9\]\] **Output:** 5 **Example 2:** ...
null
Database
Medium
null
234
hello everyone welcome to learn overflow in this video we will discuss uh a little problem that is the palindrome linked list so this is a little problem and we'll see how what should be your thought process behind finding a solution of questions like this okay so the question is uh pretty short and simple the question...
Palindrome Linked List
palindrome-linked-list
Given the `head` of a singly linked list, return `true` _if it is a_ _palindrome_ _or_ `false` _otherwise_. **Example 1:** **Input:** head = \[1,2,2,1\] **Output:** true **Example 2:** **Input:** head = \[1,2\] **Output:** false **Constraints:** * The number of nodes in the list is in the range `[1, 105]`. * ...
null
Linked List,Two Pointers,Stack,Recursion
Easy
9,125,206,2236
1,416
Hello everyone welcome you are going to do video number 26 of my channel ok and the name of the question is restore d are liquid number one on one six friend I am telling you even if you are a beginner you can solve it dog just a little bit Please wait for my explanation, it is a hard level question but it will be very...
Restore The Array
check-if-an-array-is-consecutive
A program was supposed to print an array of integers. The program forgot to print whitespaces and the array is printed as a string of digits `s` and all we know is that all integers in the array were in the range `[1, k]` and there are no leading zeros in the array. Given the string `s` and the integer `k`, return _th...
Try sorting nums. If nums is consecutive and sorted in ascending order, then nums[i] + 1 = nums[i + 1] for every i in the range 0 ≤ i < nums.length - 1.
Array
Easy
298,549,1542
383
Jhaal Ajay Ko Hello guys once again welcome all of you to your YouTube channel TLC so what is the list in today's video new question ransom note nutrition is easy if you have not subscribed the channel before starting the video please Do more ignorance today I am creating a complete playlist of Ignore the Day so just f...
Ransom Note
ransom-note
Given two strings `ransomNote` and `magazine`, return `true` _if_ `ransomNote` _can be constructed by using the letters from_ `magazine` _and_ `false` _otherwise_. Each letter in `magazine` can only be used once in `ransomNote`. **Example 1:** **Input:** ransomNote = "a", magazine = "b" **Output:** false **Example ...
null
Hash Table,String,Counting
Easy
691
1,046
hello everyone welcome or welcome back to my channel so today we are going to discuss another problem is last stone weight very easy problem we are given an integer uh area of integers where stone of i is the weight of its stone so this integer error is given to us and each uh element at each index is the weight of the...
Last Stone Weight
max-consecutive-ones-iii
You are given an array of integers `stones` where `stones[i]` is the weight of the `ith` stone. We are playing a game with the stones. On each turn, we choose the **heaviest two stones** and smash them together. Suppose the heaviest two stones have weights `x` and `y` with `x <= y`. The result of this smash is: * I...
One thing's for sure, we will only flip a zero if it extends an existing window of 1s. Otherwise, there's no point in doing it, right? Think Sliding Window! Since we know this problem can be solved using the sliding window construct, we might as well focus in that direction for hints. Basically, in a given window, we c...
Array,Binary Search,Sliding Window,Prefix Sum
Medium
340,424,485,487,2134
373
Hello Gas Welcome To Me YouTube Channel Today We Are Going To Solve D Daily Leaders Challenge And Produce Problem Name Is Find K Pairs D Smallest Some So D Question Statement And One Elements From D Second Ring Written D K Pairs With Smallest Some Question Elements Of D Terms tu have tu return se relatively in the firs...
Find K Pairs with Smallest Sums
find-k-pairs-with-smallest-sums
You are given two integer arrays `nums1` and `nums2` sorted in **ascending order** and an integer `k`. Define a pair `(u, v)` which consists of one element from the first array and one element from the second array. Return _the_ `k` _pairs_ `(u1, v1), (u2, v2), ..., (uk, vk)` _with the smallest sums_. **Example 1:**...
null
Array,Heap (Priority Queue)
Medium
378,719,2150
1,551
hello everyone welcome to my channel code with sunny and today i'm going to discuss the problem minimum operations to make array equal index number is 1551 and the problem is of medium type of lead code okay so before moving further i wanted to make clear to you all guys that this problem i don't think that this proble...
Minimum Operations to Make Array Equal
npv-queries
You have an array `arr` of length `n` where `arr[i] = (2 * i) + 1` for all valid values of `i` (i.e., `0 <= i < n`). In one operation, you can select two indices `x` and `y` where `0 <= x, y < n` and subtract `1` from `arr[x]` and add `1` to `arr[y]` (i.e., perform `arr[x] -=1` and `arr[y] += 1`). The goal is to make ...
null
Database
Easy
null
1,372
hello guys welcome to deep codes and in today's video we will discuss lead code question 1372 that says longest exact path in binary trim so here you are given the root of the binary tree and you need to find the longest length of a zigzag path so now what is the zigzag path so let's say you choose any node in a binary...
Longest ZigZag Path in a Binary Tree
check-if-it-is-a-good-array
You are given the `root` of a binary tree. A ZigZag path for a binary tree is defined as follow: * Choose **any** node in the binary tree and a direction (right or left). * If the current direction is right, move to the right child of the current node; otherwise, move to the left child. * Change the direction f...
Eq. ax+by=1 has solution x, y if gcd(a,b) = 1. Can you generalize the formula?. Check Bézout's lemma.
Array,Math,Number Theory
Hard
null
49
hello welcome to my channel today we have leeco 49 group anagrams so given an array of string strings group the anagram together so you can return the answer in any order so an anagram is a word or phrase formed by rearranging a letter of the different words and phrase typically using all the original letter exact one ...
Group Anagrams
group-anagrams
Given an array of strings `strs`, group **the anagrams** together. You can return the answer in **any order**. An **Anagram** is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. **Example 1:** **Input:** strs = \["eat","tea","tan...
null
Hash Table,String,Sorting
Medium
242,249
1,071
hello everyone so today we are here to see lead code DPP first question which is uh greatest common divisor offering the let's see what the question is saying basically photo string snd we say t divides s or it's Sim like that like 40 by 2 uh if and only if s equal to this concatenation of T's and given to string uh st...
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,742
hello everyone so in this video let us talk about the easy problem from lead code the problem name is maximum number of balls in a box so the problem statement goes like this that you are working in a ball Factory where you have N Balls numbered from the lower limit to the higher limit inclusive so what you can see is ...
Maximum Number of Balls in a Box
widest-vertical-area-between-two-points-containing-no-points
You are working in a ball factory where you have `n` balls numbered from `lowLimit` up to `highLimit` **inclusive** (i.e., `n == highLimit - lowLimit + 1`), and an infinite number of boxes numbered from `1` to `infinity`. Your job at this factory is to put each ball in the box with a number equal to the sum of digits ...
Try sorting the points Think is the y-axis of a point relevant
Array,Sorting
Medium
null
1,671
hey what's up guys this is juan here so let's take a look at number 1671 minimum number of removals to make mountain array so this is the last problem of this week's bi-weekly contest i think this is a bi-weekly contest i think this is a bi-weekly contest i think this is a pretty cool problem you know basically you kno...
Minimum Number of Removals to Make Mountain Array
the-most-recent-three-orders
You may recall that an array `arr` is a **mountain array** if and only if: * `arr.length >= 3` * There exists some index `i` (**0-indexed**) with `0 < i < arr.length - 1` such that: * `arr[0] < arr[1] < ... < arr[i - 1] < arr[i]` * `arr[i] > arr[i + 1] > ... > arr[arr.length - 1]` Given an integer arr...
null
Database
Medium
1688
394
hi everyone how are you doing uh sorry for haven't been posting for a couple of days I was actually in Toronto for a business trip and I was kind of occupied through work but now I'm back and we're gonna go to solve another problem in decode this problem that's actually kind of cool it's called decode string it's one o...
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
1,656
all right so let's talk about design and all the strings so in this question you are giving the key and value in the insert function and then you have to return the bits of string for where your pointer point at to the id key so basically that is you have your id key but so you have a pointer to zero right and then whe...
Design an Ordered Stream
count-good-triplets
There is a stream of `n` `(idKey, value)` pairs arriving in an **arbitrary** order, where `idKey` is an integer between `1` and `n` and `value` is a string. No two pairs have the same `id`. Design a stream that returns the values in **increasing order of their IDs** by returning a **chunk** (list) of values after each...
Notice that the constraints are small enough for a brute force solution to pass. Loop through all triplets, and count the ones that are good.
Array,Enumeration
Easy
2122
332
Hello, today we are going to do the granddaughter question of reconstruction department. Now let us take an example in this . How to see this if we go from A to P and there can be another answer to this. In which we first go to the one which can give the correct answer according to the answer, which has according to th...
Reconstruct Itinerary
reconstruct-itinerary
You are given a list of airline `tickets` where `tickets[i] = [fromi, toi]` represent the departure and the arrival airports of one flight. Reconstruct the itinerary in order and return it. All of the tickets belong to a man who departs from `"JFK "`, thus, the itinerary must begin with `"JFK "`. If there are multiple...
null
Depth-First Search,Graph,Eulerian Circuit
Hard
2051,2201
811
hello everyone so in this video let us talk about a medium level problem from lead code the problem name is sub domain visit count so problem statement goes like this that a website domain is named as discuss dot which as discuss dot which as discuss dot which consists of various sub domains at the top level it has com...
Subdomain Visit Count
number-of-subarrays-with-bounded-maximum
A website domain `"discuss.leetcode.com "` consists of various subdomains. At the top level, we have `"com "`, at the next level, we have `"leetcode.com "` and at the lowest level, `"discuss.leetcode.com "`. When we visit a domain like `"discuss.leetcode.com "`, we will also visit the parent domains `"leetcode.com "` a...
null
Array,Two Pointers
Medium
null
44
Tiger so we will request some cotton match what has he done on this day and given one cotton does it match the pattern or not so friends in this way I will give you Loot Marg na he take any container Can send means he will become wife, this will also become semen or become the same character on Twitter, this kind of sp...
Wildcard Matching
wildcard-matching
Given an input string (`s`) and a pattern (`p`), implement wildcard pattern matching with support for `'?'` and `'*'` where: * `'?'` Matches any single character. * `'*'` Matches any sequence of characters (including the empty sequence). The matching should cover the **entire** input string (not partial). **Exam...
null
String,Dynamic Programming,Greedy,Recursion
Hard
10
700
in this problem we have to search a value in a binary search tree so this is the classical uh use case of searching in a binary history no changes made so here we will look at a recursive as well as iterative approach and both will depend on where the node is located so if the node is located uh very deep then that wil...
Search in a Binary Search Tree
search-in-a-binary-search-tree
You are given the `root` of a binary search tree (BST) and an integer `val`. Find the node in the BST that the node's value equals `val` and return the subtree rooted with that node. If such a node does not exist, return `null`. **Example 1:** **Input:** root = \[4,2,7,1,3\], val = 2 **Output:** \[2,1,3\] **Example...
null
null
Easy
null
222
Jhal Hello Hi How are you I am O Aaliya doing good welcome to the land co disney today will do come account complete free mode and it's really it's personal question this cancer it is not visit after wave some service given in this witch mins solution liquid up sid this company bank so baikunth wikipedia every level su...
Count Complete Tree Nodes
count-complete-tree-nodes
Given the `root` of a **complete** binary tree, return the number of the nodes in the tree. According to **[Wikipedia](http://en.wikipedia.org/wiki/Binary_tree#Types_of_binary_trees)**, every level, except possibly the last, is completely filled in a complete binary tree, and all nodes in the last level are as far lef...
null
Binary Search,Tree,Depth-First Search,Binary Tree
Medium
270
148
hi my name is anley and welcome back today we'll see how to sort link list so we have given a link list say 4 2 1 and three we need to sort the list in ascending order and return the modified list so our output would be 1 2 3 and four similarly for the example number two in example number three when the link list is em...
Sort List
sort-list
Given the `head` of a linked list, return _the list after sorting it in **ascending order**_. **Example 1:** **Input:** head = \[4,2,1,3\] **Output:** \[1,2,3,4\] **Example 2:** **Input:** head = \[-1,5,3,4,0\] **Output:** \[-1,0,3,4,5\] **Example 3:** **Input:** head = \[\] **Output:** \[\] **Constraints:** * ...
null
Linked List,Two Pointers,Divide and Conquer,Sorting,Merge Sort
Medium
21,75,147,1992
341
Hello everyone Welcome to my channel here we solve problems Lead code today task 341 bringing a nested list into a plane Flat state level medium We are given a nested list of numbers N L Each element of this list can be either a number or also with it is necessary to implement an iterator such that it has there were Ne...
Flatten Nested List Iterator
flatten-nested-list-iterator
You are given a nested list of integers `nestedList`. Each element is either an integer or a list whose elements may also be integers or other lists. Implement an iterator to flatten it. Implement the `NestedIterator` class: * `NestedIterator(List nestedList)` Initializes the iterator with the nested list `nestedLi...
null
Stack,Tree,Depth-First Search,Design,Queue,Iterator
Medium
251,281,385,565
763
hello everyone welcome to quartus camp i am here with another interesting problem from lead code which is partition labels so the input given here is a string and we have to return an integer array which represent the size of the substrings so the problem statement says we are given a string yes and we want to partitio...
Partition Labels
special-binary-string
You are given a string `s`. We want to partition the string into as many parts as possible so that each letter appears in at most one part. Note that the partition is done so that after concatenating all the parts in order, the resultant string should be `s`. Return _a list of integers representing the size of these ...
Draw a line from (x, y) to (x+1, y+1) if we see a "1", else to (x+1, y-1). A special substring is just a line that starts and ends at the same y-coordinate, and that is the lowest y-coordinate reached. Call a mountain a special substring with no special prefixes - ie. only at the beginning and end is the lowest y-coo...
String,Recursion
Hard
678
305
to my YouTube channel and for this video we will talk about problem 305 this is the second iteration of number of Island and we will solve this problem using this joint set also known as Union find I want you guys to post this video to read the problem statement I'm going to make this mild assumption that you guys have...
Number of Islands II
number-of-islands-ii
You are given an empty 2D binary grid `grid` of size `m x n`. The grid represents a map where `0`'s represent water and `1`'s represent land. Initially, all the cells of `grid` are water cells (i.e., all the cells are `0`'s). We may perform an add land operation which turns the water at position into a land. You are g...
null
Array,Union Find
Hard
200,2198
1,823
hello today we'll be working on Elite code 1823 find the winner of the circular game we're given a number called n an account called K what they want us to do is imagine that the numbers are in a Circle the numbers start at one and go up to the whatever value n is we start at one and we move a pointer around this Circl...
Find the Winner of the Circular Game
determine-if-string-halves-are-alike
There are `n` friends that are playing a game. The friends are sitting in a circle and are numbered from `1` to `n` in **clockwise order**. More formally, moving clockwise from the `ith` friend brings you to the `(i+1)th` friend for `1 <= i < n`, and moving clockwise from the `nth` friend brings you to the `1st` friend...
Create a function that checks if a character is a vowel, either uppercase or lowercase.
String,Counting
Easy
null
1,849
Ajay Ko Hello Everyone Welcome to Lotus Camp Secretary and Other Interesting Problem Contest Which Split String into Depending Must Subscribe YouTube Channel and Considering Problem 05030 Number 4 O 90 Five for Entries Consecutive Dependent Arranged This Difference Between There Values ​​and Decreasing Old Values ​​and...
Splitting a String Into Descending Consecutive Values
maximum-absolute-sum-of-any-subarray
You are given a string `s` that consists of only digits. Check if we can split `s` into **two or more non-empty substrings** such that the **numerical values** of the substrings are in **descending order** and the **difference** between numerical values of every two **adjacent** **substrings** is equal to `1`. * Fo...
What if we asked for maximum sum, not absolute sum? It's a standard problem that can be solved by Kadane's algorithm. The key idea is the max absolute sum will be either the max sum or the min sum. So just run kadane twice, once calculating the max sum and once calculating the min sum.
Array,Dynamic Programming
Medium
53
1,898
hi everyone welcome back to lead coding i'm your host faraz so i have decided to make detailed solutions to the lead code weekly and bi-weekly problems bi-weekly problems bi-weekly problems so here it is the contest number 245 and we are going to solve problem number two and problem number three so first of all let's s...
Maximum Number of Removable Characters
leetflex-banned-accounts
You are given two strings `s` and `p` where `p` is a **subsequence** of `s`. You are also given a **distinct 0-indexed** integer array `removable` containing a subset of indices of `s` (`s` is also **0-indexed**). You want to choose an integer `k` (`0 <= k <= removable.length`) such that, after removing `k` characters...
null
Database
Medium
null
394
Jhaal Hello Viewers Welcome To Your Consideration Question Record Friends In This Question Were Wedding Invitation To Its Subscribe Now To Receive New Updates Subscribe Mode Turn On Vivah Aisi Subscribe Tablet To Candidates Selected In Description When Skin Use Subscribe And Subscribe Channel Subscribe The Students Cod...
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
1,582
That welcome back guys loot problem 1582 special position in binary matrix so if you have already subscribe my channel please subscribe my channel subscribe our create list code solution videos in java j2ee technology this website create videos to help people you know in Rahta J2 interview time Mom Please subscribe The...
Special Positions in a Binary Matrix
design-browser-history
Given an `m x n` binary matrix `mat`, return _the number of special positions in_ `mat`_._ A position `(i, j)` is called **special** if `mat[i][j] == 1` and all other elements in row `i` and column `j` are `0` (rows and columns are **0-indexed**). **Example 1:** **Input:** mat = \[\[1,0,0\],\[0,0,1\],\[1,0,0\]\] **O...
Use two stack one for back history and one for forward history and simulate the functions. Can you do faster by using different data structure ?
Array,Linked List,Stack,Design,Doubly-Linked List,Data Stream
Medium
null
1,732
hello everyone welcome back here is vanamsen and in today's video we are going to tackle interesting problem find the highest altitude we will try to solve it in Rust uh so the task is to find the highest altitude given an RI that represent net gains in altitude between points so let's start our implementation in Rust ...
Find the Highest Altitude
minimum-one-bit-operations-to-make-integers-zero
There is a biker going on a road trip. The road trip consists of `n + 1` points at different altitudes. The biker starts his trip on point `0` with altitude equal `0`. You are given an integer array `gain` of length `n` where `gain[i]` is the **net gain in altitude** between points `i`​​​​​​ and `i + 1` for all (`0 <=...
The fastest way to convert n to zero is to remove all set bits starting from the leftmost one. Try some simple examples to learn the rule of how many steps are needed to remove one set bit. consider n=2^k case first, then solve for all n.
Dynamic Programming,Bit Manipulation,Memoization
Hard
2119
205
of easy legal question isomorphic strings giving two strings s and t determine if there are subformic and two strings they give you s and t egg and add or can um two strings or isophonic if the characters in s can be replaced to t all occurrence of a character must be replaced with another character while preserving th...
Isomorphic Strings
isomorphic-strings
Given two strings `s` and `t`, _determine if they are isomorphic_. Two strings `s` and `t` are isomorphic if the characters in `s` can be replaced to get `t`. All occurrences of a character must be replaced with another character while preserving the order of characters. No two characters may map to the same characte...
null
Hash Table,String
Easy
290
179
hi i am ayushi rawat and welcome to my channel today we will discuss the september lead code challenge week 4 problem largest number now let's have a look at the problem statement let's see what it says given a list of non-negative integers given a list of non-negative integers given a list of non-negative integers arr...
Largest Number
largest-number
Given a list of non-negative integers `nums`, arrange them such that they form the largest number and return it. Since the result may be very large, so you need to return a string instead of an integer. **Example 1:** **Input:** nums = \[10,2\] **Output:** "210 " **Example 2:** **Input:** nums = \[3,30,34,5,9\] *...
null
String,Greedy,Sorting
Medium
2284
160
all right hey what's up guys it's fond and we're going over top interview questions medium set linked list question number three intersection of two linked lists so given the heads of two single linked lists heads a and head b return the node at which these two lists intersect if the two linked lists have no intersecti...
Intersection of Two Linked Lists
intersection-of-two-linked-lists
Given the heads of two singly linked-lists `headA` and `headB`, return _the node at which the two lists intersect_. If the two linked lists have no intersection at all, return `null`. For example, the following two linked lists begin to intersect at node `c1`: The test cases are generated such that there are no cycle...
null
Hash Table,Linked List,Two Pointers
Easy
599
43
hey guys so today for you I have whoops we could problem number 43 which is the multiple and strings question so you're given two strings you're asked to multiply them now obviously you could just convert them both to integers multiplying them convert it back to a string and return it but you're not allowed to do that ...
Multiply Strings
multiply-strings
Given two non-negative integers `num1` and `num2` represented as strings, return the product of `num1` and `num2`, also represented as a string. **Note:** You must not use any built-in BigInteger library or convert the inputs to integer directly. **Example 1:** **Input:** num1 = "2", num2 = "3" **Output:** "6" **Ex...
null
Math,String,Simulation
Medium
2,66,67,415
4
Hello everyone, I welcome you friends, today we are Mukesh, don't wait so much, we will solve important questions which are very tiffin, really top, its logic may not be understood at once but inside and if you are like job. I have done it when I will tell you, if you do it on pen and paper then you will definitely und...
Median of Two Sorted Arrays
median-of-two-sorted-arrays
Given two sorted arrays `nums1` and `nums2` of size `m` and `n` respectively, return **the median** of the two sorted arrays. The overall run time complexity should be `O(log (m+n))`. **Example 1:** **Input:** nums1 = \[1,3\], nums2 = \[2\] **Output:** 2.00000 **Explanation:** merged array = \[1,2,3\] and median is ...
null
Array,Binary Search,Divide and Conquer
Hard
null
234
how's it going guys sorry if I hurt your ears there I got a new mic recently but yeah we're just gonna be doing another thing if you don't know who I am check the description I do tech encoding stuff on twitch and YouTube and I've been doing all these leak code problems and kind of explaining them so we already did a p...
Palindrome Linked List
palindrome-linked-list
Given the `head` of a singly linked list, return `true` _if it is a_ _palindrome_ _or_ `false` _otherwise_. **Example 1:** **Input:** head = \[1,2,2,1\] **Output:** true **Example 2:** **Input:** head = \[1,2\] **Output:** false **Constraints:** * The number of nodes in the list is in the range `[1, 105]`. * ...
null
Linked List,Two Pointers,Stack,Recursion
Easy
9,125,206,2236
62
hello everyone welcome to codus camp we are at 17th day of normal eco challenge and the problem we are going to cover in this video is unique paths so we have already solved unique part 2 and 3 in our channel so this is comparatively the basic version of those and here the input given here is m and n which is nothing b...
Unique Paths
unique-paths
There is a robot on an `m x n` grid. The robot is 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. Given the two integers `m` and `n`, return _the nu...
null
Math,Dynamic Programming,Combinatorics
Medium
63,64,174,2192
1,695
hello everyone and welcome back to another video so today we're going to be solving the lethal question maximum erasure value so in this question we're going to be given an area of positive integers called nums and we want to erase a sub area containing unique elements and the score that you get by erasing the sub area...
Maximum Erasure Value
maximum-sum-obtained-of-any-permutation
You are given an array of positive integers `nums` and want to erase a subarray containing **unique elements**. The **score** you get by erasing the subarray is equal to the **sum** of its elements. Return _the **maximum score** you can get by erasing **exactly one** subarray._ An array `b` is called to be a subarray...
Indexes with higher frequencies should be bound with larger values
Array,Greedy,Sorting,Prefix Sum
Medium
null
909
hey everyone welcome back and let's write some more neat code today so today let's solve the problems snakes and ladders and this is a pretty challenging problem especially for a medium it's got some good fundamentals to it but there's also some uniqueness to this problem that you can't really get in most problems so w...
Snakes and Ladders
stone-game
You are given an `n x n` integer matrix `board` where the cells are labeled from `1` to `n2` in a [**Boustrophedon style**](https://en.wikipedia.org/wiki/Boustrophedon) starting from the bottom left of the board (i.e. `board[n - 1][0]`) and alternating direction each row. You start on square `1` of the board. In each ...
null
Array,Math,Dynamic Programming,Game Theory
Medium
1685,1788,1808,2002,2156
1,394
guys today we're going to be looking at leak code problem 1394 find lucky integer in an array in this problem we are given an array of ins and need to return the largest integer that appears the same number of times in the array as its value for example we looked at the first example here 2 appears in the array twice s...
Find Lucky Integer in an Array
find-lucky-integer-in-an-array
Given an array of integers `arr`, a **lucky integer** is an integer that has a frequency in the array equal to its value. Return _the largest **lucky integer** in the array_. If there is no **lucky integer** return `-1`. **Example 1:** **Input:** arr = \[2,2,3,4\] **Output:** 2 **Explanation:** The only lucky number...
null
null
Easy
null
345
hey everyone welcome back and today we'll be doing another lead got three four five reverse Bob balls of a string an easy one given a string as reverse also all now only all the vowels in the string and returning all vowels are a e i o u and they can appear in both cases like you can see from the example and one and tw...
Reverse Vowels of a String
reverse-vowels-of-a-string
Given a string `s`, reverse only all the vowels in the string and return it. The vowels are `'a'`, `'e'`, `'i'`, `'o'`, and `'u'`, and they can appear in both lower and upper cases, more than once. **Example 1:** **Input:** s = "hello" **Output:** "holle" **Example 2:** **Input:** s = "leetcode" **Output:** "leotc...
null
Two Pointers,String
Easy
344,1089
86
hey guys how's everything going today let's to take a look at number 86 partitionless we're giving a link list and the value separated such that all nodes less than X come before nodes greater than or equal to X we're giving it less like this one four three two five two and target is history okay so the output should b...
Partition List
partition-list
Given the `head` of a linked list and a value `x`, partition it such that all nodes **less than** `x` come before nodes **greater than or equal** to `x`. You should **preserve** the original relative order of the nodes in each of the two partitions. **Example 1:** **Input:** head = \[1,4,3,2,5,2\], x = 3 **Output:**...
null
Linked List,Two Pointers
Medium
2265
1,277
today's question is count square some matrices with all ones or in other words given this picture how many squares can you find so we're going to solve this with dynamic programming an idea behind dynamic programming is we want to split this question into subproblems and then you know using those subproblems come up wi...
Count Square Submatrices with All Ones
largest-multiple-of-three
Given a `m * n` matrix of ones and zeros, return how many **square** submatrices have all ones. **Example 1:** **Input:** matrix = \[ \[0,1,1,1\], \[1,1,1,1\], \[0,1,1,1\] \] **Output:** 15 **Explanation:** There are **10** squares of side 1. There are **4** squares of side 2. There is **1** square of side 3....
A number is a multiple of three if and only if its sum of digits is a multiple of three. Use dynamic programming. To find the maximum number, try to maximize the number of digits of the number. Sort the digits in descending order to find the maximum number.
Array,Dynamic Programming,Greedy
Hard
null
384
That's Hi Everyone Welcome To My Channel It's All Your Problems Safal And Are Forgiven And Journals Ghritam Safal Are All Competition Are Like A Result Of The Video subscribe to subscribe our Channel And subscribe The Amazing Click on the link for 12345 Safal 100 We Need To Subscribe Mode Off Eid Canteen Factorial Thes...
Shuffle an Array
shuffle-an-array
Given an integer array `nums`, design an algorithm to randomly shuffle the array. All permutations of the array should be **equally likely** as a result of the shuffling. Implement the `Solution` class: * `Solution(int[] nums)` Initializes the object with the integer array `nums`. * `int[] reset()` Resets the arr...
The solution expects that we always use the original array to shuffle() else some of the test cases fail. (Credits; @snehasingh31)
Array,Math,Randomized
Medium
null
1
Hello everyone welcome back my channel Hi I am Sunny and I am a software engineer today in this video we are going to solve a problem from leedkut the name of the problem is tu even and the difficulty level is easy it is easy so let's see the problem statement so Problem statement what is life and are of integers numbe...
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
147
Indian Oil Welcome to Learn Repeat Today's Date of the Number Four Inches The Name of the Problem Is Information Short List Na Chipke Na Problem Solve Problems Sheets for Telling List Using These Short Numbers Graphical Representation of Information Sot and Will Go Through One Example for Intervention Sot And Algorithm...
Insertion Sort List
insertion-sort-list
Given the `head` of a singly linked list, sort the list using **insertion sort**, and return _the sorted list's head_. The steps of the **insertion sort** algorithm: 1. Insertion sort iterates, consuming one input element each repetition and growing a sorted output list. 2. At each iteration, insertion sort removes...
null
Linked List,Sorting
Medium
148,850
61
we have to rotate the list to the right by K places that means and just give an example first therefore k equal to so the last two nodes will get rotated so first five will move to the beginning this first rotation and second rotation k equal to right so the second rotation 4 will get moved to the begin and we have to ...
Rotate List
rotate-list
Given the `head` of a linked list, rotate the list to the right by `k` places. **Example 1:** **Input:** head = \[1,2,3,4,5\], k = 2 **Output:** \[4,5,1,2,3\] **Example 2:** **Input:** head = \[0,1,2\], k = 4 **Output:** \[2,0,1\] **Constraints:** * The number of nodes in the list is in the range `[0, 500]`. * ...
null
Linked List,Two Pointers
Medium
189,725
492
hey everyone welcome back and today we'll be doing another loot code 492 construct the rectangle an easy one a web developer needs to know how to design a web page size so given a specific rectangular web page area your job is now to design a rectangular web page whose length L bits W satisfy the following requirements...
Construct the Rectangle
construct-the-rectangle
A web developer needs to know how to design a web page's size. So, given a specific rectangular web page's area, your job by now is to design a rectangular web page, whose length L and width W satisfy the following requirements: 1. The area of the rectangular web page you designed must equal to the given target area....
The W is always less than or equal to the square root of the area, so we start searching at sqrt(area) till we find the result.
Math
Easy
null
1,498
Hello everyone welcome, we are going to do video number four of my channel's playlist. The name of the question is number of sequences, thoughts, it is the same condition, it is a medium question, liquid is fine, it comes in the category of medium hard, but story points. When you write this and once you understand the ...
Number of Subsequences That Satisfy the Given Sum Condition
find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree
You are given an array of integers `nums` and an integer `target`. Return _the number of **non-empty** subsequences of_ `nums` _such that the sum of the minimum and maximum element on it is less or equal to_ `target`. Since the answer may be too large, return it **modulo** `109 + 7`. **Example 1:** **Input:** nums =...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Medium
null
342
hey everybody this is Larry this is day 23 of the Leo day challenge and we didn't do the uh weekly premium Farm yet so let's get it today uh okay today is a kind of a easy one it seems like 242 power of four so good time to take a break uh mentally I mean hopefully um yeah so I mean I don't know is there anything diffi...
Power of Four
power-of-four
Given an integer `n`, return _`true` if it is a power of four. Otherwise, return `false`_. An integer `n` is a power of four, if there exists an integer `x` such that `n == 4x`. **Example 1:** **Input:** n = 16 **Output:** true **Example 2:** **Input:** n = 5 **Output:** false **Example 3:** **Input:** n = 1 **O...
null
Math,Bit Manipulation,Recursion
Easy
231,326
1,423
hey everyone welcome back and let's write some more neat code today so today let's solve google's most asked question of 2021 at least according to leak code and actually i think this question is tied for this for the most asked question there's two questions that are asked very frequently and this one is pretty much t...
Maximum Points You Can Obtain from Cards
maximum-number-of-occurrences-of-a-substring
There are several cards **arranged in a row**, and each card has an associated number of points. The points are given in the integer array `cardPoints`. In one step, you can take one card from the beginning or from the end of the row. You have to take exactly `k` cards. Your score is the sum of the points of the card...
Check out the constraints, (maxSize <=26). This means you can explore all substrings in O(n * 26). Find the Maximum Number of Occurrences of a Substring with bruteforce.
Hash Table,String,Sliding Window
Medium
null
1,770
hello everyone welcome to goddess camp so today we are at the fifth video of our recursion series in a previous video we have seen what is memoization and how to work with recursion and memorization and we have seen an example of a bonus a series how we work with memorization and recursion to work on the problem so tod...
Maximum Score from Performing Multiplication Operations
minimum-deletions-to-make-character-frequencies-unique
You are given two **0-indexed** integer arrays `nums` and `multipliers` of size `n` and `m` respectively, where `n >= m`. You begin with a score of `0`. You want to perform **exactly** `m` operations. On the `ith` operation (**0-indexed**) you will: * Choose one integer `x` from **either the start or the end** of t...
As we can only delete characters, if we have multiple characters having the same frequency, we must decrease all the frequencies of them, except one. Sort the alphabet characters by their frequencies non-increasingly. Iterate on the alphabet characters, keep decreasing the frequency of the current character until it re...
String,Greedy,Sorting
Medium
1355,2212
152
Le code problem number 152 maximum product subray so this produ so this problem gives us an integer array called nums and our goal is to find a sub array that has the largest product and return the product itself here it just gives us the information that the answer will fit in a integer right so the way I chose to app...
Maximum Product Subarray
maximum-product-subarray
Given an integer array `nums`, find a subarray that has the largest product, and return _the product_. The test cases are generated so that the answer will fit in a **32-bit** integer. **Example 1:** **Input:** nums = \[2,3,-2,4\] **Output:** 6 **Explanation:** \[2,3\] has the largest product 6. **Example 2:** **I...
null
Array,Dynamic Programming
Medium
53,198,238,628,713
1,629
hello everyone so in this video let us talk about another easy problem from lead code the problem name is slowest key so possible states that you are given a newly designed keypad and you are testing that where a tester passed a sequence of n keys at a particular moment of time so you are given that there are some like...
Slowest Key
minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits
A newly designed keypad was tested, where a tester pressed a sequence of `n` keys, one at a time. You are given a string `keysPressed` of length `n`, where `keysPressed[i]` was the `ith` key pressed in the testing sequence, and a sorted list `releaseTimes`, where `releaseTimes[i]` was the time the `ith` key was releas...
We want to make the smaller digits the most significant digits in the number. For each index i, check the smallest digit in a window of size k and append it to the answer. Update the indices of all digits in this range accordingly.
String,Greedy,Binary Indexed Tree,Segment Tree
Hard
null
26
hey everyone welcome back and let's write some more neat code today so today let's solve the problem remove duplicates from sorted array 2. so we're given an integer array nums that's sorted in non-decreasing order that sorted in non-decreasing order that sorted in non-decreasing order that basically means that it's so...
Remove Duplicates from Sorted Array
remove-duplicates-from-sorted-array
Given an integer array `nums` sorted in **non-decreasing order**, remove the duplicates [**in-place**](https://en.wikipedia.org/wiki/In-place_algorithm) such that each unique element appears only **once**. The **relative order** of the elements should be kept the **same**. Then return _the number of unique elements in_...
In this problem, the key point to focus on is the input array being sorted. As far as duplicate elements are concerned, what is their positioning in the array when the given array is sorted? Look at the image above for the answer. If we know the position of one of the elements, do we also know the positioning of all th...
Array,Two Pointers
Easy
27,80
1,814
Hello everyone welcome to my channel code story with mike so today we are going to do video number nine of our hash map hash set playlist okay lead code number 1814 is actually quite easy and a little bit I will tell you a suggestion and a pattern It is fine for this type of questions. Mostly in all such problems, you ...
Count Nice Pairs in an Array
jump-game-vi
You are given an array `nums` that consists of non-negative integers. Let us define `rev(x)` as the reverse of the non-negative integer `x`. For example, `rev(123) = 321`, and `rev(120) = 21`. A pair of indices `(i, j)` is **nice** if it satisfies all of the following conditions: * `0 <= i < j < nums.length` * `nu...
Let dp[i] be "the maximum score to reach the end starting at index i". The answer for dp[i] is nums[i] + max{dp[i+j]} for 1 <= j <= k. That gives an O(n*k) solution. Instead of checking every j for every i, keep track of the largest dp[i] values in a heap and calculate dp[i] from right to left. When the largest value i...
Array,Dynamic Programming,Queue,Sliding Window,Heap (Priority Queue),Monotonic Queue
Medium
239,2001
32
hello guys welcome to algorithms made easy my name is radha graval and today we will be discussing the question longest valid parenthesis in this question we are given a string containing just the characters that is open in closed parenthesis and we need to find the length of the longest well-formed parenthesis longest...
Longest Valid Parentheses
longest-valid-parentheses
Given a string containing just the characters `'('` and `')'`, return _the length of the longest valid (well-formed) parentheses_ _substring_. **Example 1:** **Input:** s = "(() " **Output:** 2 **Explanation:** The longest valid parentheses substring is "() ". **Example 2:** **Input:** s = ")()()) " **Output:** ...
null
String,Dynamic Programming,Stack
Hard
20
1,314
hey what's up guys this is sean here again so let's take a look at another lead called problem today number 1314 matrix block sum given like a m times m by n matrix and an integer k return a matrix answer where each answer each element in this answer is the sum of all elements uh in the matrix where the uh where the r ...
Matrix Block Sum
matrix-block-sum
Given a `m x n` matrix `mat` and an integer `k`, return _a matrix_ `answer` _where each_ `answer[i][j]` _is the sum of all elements_ `mat[r][c]` _for_: * `i - k <= r <= i + k,` * `j - k <= c <= j + k`, and * `(r, c)` is a valid position in the matrix. **Example 1:** **Input:** mat = \[\[1,2,3\],\[4,5,6\],\[7,8...
null
null
Medium
null
1,176
and if it is a crime that is called the performance plan, this problem is simple, well, it is the level to solve it in the most appropriate way, a method called windows is still used, what this problem is about is an arrangement with the calories consumed by a person during each day, for example, taking this example, t...
Diet Plan Performance
design-a-leaderboard
A dieter consumes `calories[i]` calories on the `i`\-th day. Given an integer `k`, for **every** consecutive sequence of `k` days (`calories[i], calories[i+1], ..., calories[i+k-1]` for all `0 <= i <= n-k`), they look at _T_, the total calories consumed during that sequence of `k` days (`calories[i] + calories[i+1] + ...
What data structure can we use to keep the players' data? Keep a map (dictionary) of player scores. For each top(K) function call, find the maximum K scores and add them.
Hash Table,Design,Sorting
Medium
null
54
Hello everyone welcome back my channel is am sunny and i am software engineer today in this video we are going to solve another problem for our daily challenge series so today's problem is spiral matrix lead code 54 today in this video In this we will learn how to approach a problem, we will try to achieve its basic in...
Spiral Matrix
spiral-matrix
Given an `m x n` `matrix`, return _all elements of the_ `matrix` _in spiral order_. **Example 1:** **Input:** matrix = \[\[1,2,3\],\[4,5,6\],\[7,8,9\]\] **Output:** \[1,2,3,6,9,8,7,4,5\] **Example 2:** **Input:** matrix = \[\[1,2,3,4\],\[5,6,7,8\],\[9,10,11,12\]\] **Output:** \[1,2,3,4,8,12,11,10,9,5,6,7\] **Const...
Well for some problems, the best way really is to come up with some algorithms for simulation. Basically, you need to simulate what the problem asks us to do. We go boundary by boundary and move inwards. That is the essential operation. First row, last column, last row, first column and then we move inwards by 1 and th...
Array,Matrix,Simulation
Medium
59,921
35
hello everyone welcome back here is vanamsen uh with another interesting coding problem today we will crack the search and search position Challenge and we will be doing it in JavaScript uh so let's get started all right so before we start coding and implementing our strategy let's understand the problem we are given a...
Search Insert Position
search-insert-position
Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You must write an algorithm with `O(log n)` runtime complexity. **Example 1:** **Input:** nums = \[1,3,5,6\], target = 5 **Output:** 2 **Exa...
null
Array,Binary Search
Easy
278
307
all right let's follow the range some query immutable so you are given the array numbers and you have to handle the multiple queries of the following type so you either update it and you either calculate the sum between the range based on the left and right and then there are three functions you need to write so one is...
Range Sum Query - Mutable
range-sum-query-mutable
Given an integer array `nums`, handle multiple queries of the following types: 1. **Update** the value of an element in `nums`. 2. Calculate the **sum** of the elements of `nums` between indices `left` and `right` **inclusive** where `left <= right`. Implement the `NumArray` class: * `NumArray(int[] nums)` Initi...
null
Array,Design,Binary Indexed Tree,Segment Tree
Medium
303,308
1,833
just completed this challenge it is passing with very good performance the challenge is Lee code 1833 maximum ice cream bars this is a labeled medium question I don't think that's appropriate I think this is an easy question I solved it very quickly just like less than five minutes and here's how easy it is I'm going t...
Maximum Ice Cream Bars
find-the-highest-altitude
It is a sweltering summer day, and a boy wants to buy some ice cream bars. At the store, there are `n` ice cream bars. You are given an array `costs` of length `n`, where `costs[i]` is the price of the `ith` ice cream bar in coins. The boy initially has `coins` coins to spend, and he wants to buy as many ice cream bar...
Let's note that the altitude of an element is the sum of gains of all the elements behind it Getting the altitudes can be done by getting the prefix sum array of the given array
Array,Prefix Sum
Easy
null
796
on everyone so today we're looking at lead code number 796 it is a question called rotate string and so here we're giving two strings a and b and we want to see if we rotate if string b is a rotation of string a so here we have input a b c d e and we can see string b is c d e a b but if we start here at this index 3 we...
Rotate String
reaching-points
Given two strings `s` and `goal`, return `true` _if and only if_ `s` _can become_ `goal` _after some number of **shifts** on_ `s`. A **shift** on `s` consists of moving the leftmost character of `s` to the rightmost position. * For example, if `s = "abcde "`, then it will be `"bcdea "` after one shift. **Example 1...
null
Math
Hard
null
122
one welcome to my channel so before starting this video um i would really appreciate if you can help subscribe this channel to help me grow and then let's get started so um for this video i'm going to cover two things the first one is um the solution uh for this specific question and the second one is how we are going ...
Best Time to Buy and Sell Stock II
best-time-to-buy-and-sell-stock-ii
You are given an integer array `prices` where `prices[i]` is the price of a given stock on the `ith` day. On each day, you may decide to buy and/or sell the stock. You can only hold **at most one** share of the stock at any time. However, you can buy it then immediately sell it on the **same day**. Find and return _t...
null
Array,Dynamic Programming,Greedy
Medium
121,123,188,309,714
1,583
when I was in college I was really struggling with programming I tried code forces code shift and even that tracking the coding interview I never felt ready for interviews I knew I needed to get better but I didn't know how that all changed in 2017 when I came across lead code I instantly fell in love with its clean an...
Count Unhappy Friends
paint-house-iii
You are given a list of `preferences` for `n` friends, where `n` is always **even**. For each person `i`, `preferences[i]` contains a list of friends **sorted** in the **order of preference**. In other words, a friend earlier in the list is more preferred than a friend later in the list. Friends in each list are denot...
Use Dynamic programming. Define dp[i][j][k] as the minimum cost where we have k neighborhoods in the first i houses and the i-th house is painted with the color j.
Array,Dynamic Programming
Hard
null
412
so this is a pretty easy question nice warm-up to if you guys haven't done lead warm-up to if you guys haven't done lead warm-up to if you guys haven't done lead code before it's very basic and it does it and it involves just a simple data structure that you probably use in your day-to-day basis as probably use in your...
Fizz Buzz
fizz-buzz
Given an integer `n`, return _a string array_ `answer` _(**1-indexed**) where_: * `answer[i] == "FizzBuzz "` if `i` is divisible by `3` and `5`. * `answer[i] == "Fizz "` if `i` is divisible by `3`. * `answer[i] == "Buzz "` if `i` is divisible by `5`. * `answer[i] == i` (as a string) if none of the above condit...
null
Math,String,Simulation
Easy
1316
142
so hello guys so today we are going to see the related questions okay so you are watching programming shift only on YouTube and we are going to see the you can say 142 questions of the lead code that is a linked list cycle to and uh I think you already knows what the link is cycle right so we'll check the link list uh ...
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
92
hey everyone welcome back and let's write some more neat code today so today let's solve the problem reversal linked list two so we did solve the first part of this problem a long time ago so let's solve the second part of it today we're given the head of a singly linked list singly means there's only one pointer going...
Reverse Linked List II
reverse-linked-list-ii
Given the `head` of a singly linked list and two integers `left` and `right` where `left <= right`, reverse the nodes of the list from position `left` to position `right`, and return _the reversed list_. **Example 1:** **Input:** head = \[1,2,3,4,5\], left = 2, right = 4 **Output:** \[1,4,3,2,5\] **Example 2:** **I...
null
Linked List
Medium
206
160
One of the very popular questions when it comes to linked list. You are given the head of two single linked lists and you have to find the intersection point. What does that mean? Let us say you have a list A and you have a list B, then one of the nodes in list B points to one of the nodes in list A and hence that inte...
Intersection of Two Linked Lists
intersection-of-two-linked-lists
Given the heads of two singly linked-lists `headA` and `headB`, return _the node at which the two lists intersect_. If the two linked lists have no intersection at all, return `null`. For example, the following two linked lists begin to intersect at node `c1`: The test cases are generated such that there are no cycle...
null
Hash Table,Linked List,Two Pointers
Easy
599
130
hello everyone welcome to clash encoder so in this video this is the question that is 130 that is surrounded regions so it is a medium level question and it is also sometimes as interviews so let's see the problem statement given a 2d board consisting or containing x and o this is actually not zero you can see the lett...
Surrounded Regions
surrounded-regions
Given an `m x n` matrix `board` containing `'X'` and `'O'`, _capture all regions that are 4-directionally surrounded by_ `'X'`. A region is **captured** by flipping all `'O'`s into `'X'`s in that surrounded region. **Example 1:** **Input:** board = \[\[ "X ", "X ", "X ", "X "\],\[ "X ", "O ", "O ", "X "\],\[ "X ", "...
null
Array,Depth-First Search,Breadth-First Search,Union Find,Matrix
Medium
200,286
1,737
hey everybody this is larry this is me going over q2 of the weekly contest 225 change minimum characters to satisfy one of three conditions um hit the like button hit the subscriber and draw me discord um if my energy is a little low today i'm just dealing with something huh uh everything will be okay but yeah um this ...
Change Minimum Characters to Satisfy One of Three Conditions
maximum-nesting-depth-of-the-parentheses
You are given two strings `a` and `b` that consist of lowercase letters. In one operation, you can change any character in `a` or `b` to **any lowercase letter**. Your goal is to satisfy **one** of the following three conditions: * **Every** letter in `a` is **strictly less** than **every** letter in `b` in the alp...
The depth of any character in the VPS is the ( number of left brackets before it ) - ( number of right brackets before it )
String,Stack
Easy
1208
869
hey everybody this is larry this is me going over march 21st lego daily challenge uh let me know what you think about this farm hit the like button the subscribe button join me on discord um and yeah we ordered power of two is today's problem uh okay starting with a positive in jan how did you do i don't know did anyon...
Reordered Power of 2
similar-string-groups
You are given an integer `n`. We reorder the digits in any order (including the original order) such that the leading digit is not zero. Return `true` _if and only if we can do this so that the resulting number is a power of two_. **Example 1:** **Input:** n = 1 **Output:** true **Example 2:** **Input:** n = 10 **...
null
Array,String,Depth-First Search,Breadth-First Search,Union Find
Hard
2276
152
hey guys welcome back to the channel today we're gonna solve lead code problem 152 maximum product sub array okay so um feel free to pause the video just to read through the problem and kind of get an understanding of what it's asking but i prefer explaining through the examples okay so given an array for example nums ...
Maximum Product Subarray
maximum-product-subarray
Given an integer array `nums`, find a subarray that has the largest product, and return _the product_. The test cases are generated so that the answer will fit in a **32-bit** integer. **Example 1:** **Input:** nums = \[2,3,-2,4\] **Output:** 6 **Explanation:** \[2,3\] has the largest product 6. **Example 2:** **I...
null
Array,Dynamic Programming
Medium
53,198,238,628,713
62
everyone so today we are looking at lead code number 62 it's called unique paths and this is a classic dynamic programming problem that really focuses on a method called tabulation and once we kind of understand this we can actually solve this quite quickly but the way you want to think about this is you want to create...
Unique Paths
unique-paths
There is a robot on an `m x n` grid. The robot is 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. Given the two integers `m` and `n`, return _the nu...
null
Math,Dynamic Programming,Combinatorics
Medium
63,64,174,2192
33
Share with your friends and condition poster and powder talk about very important question - above about very important question - above about very important question - above this question has been discussed many times on international, so today to explain it very well, the question is filter element in short and advoc...
Search in Rotated Sorted Array
search-in-rotated-sorted-array
There is an integer array `nums` sorted in ascending order (with **distinct** values). Prior to being passed to your function, `nums` is **possibly rotated** at an unknown pivot index `k` (`1 <= k < nums.length`) such that the resulting array is `[nums[k], nums[k+1], ..., nums[n-1], nums[0], nums[1], ..., nums[k-1]]` ...
null
Array,Binary Search
Medium
81,153,2273
216
hey everyone nitish's side hope you are doing good so let's start with the question so the question is combination sum three okay so there are question related combination sum and combination two so you can that you can check that out also so first we will check combinations on three so what is this we like find all va...
Combination Sum III
combination-sum-iii
Find all valid combinations of `k` numbers that sum up to `n` such that the following conditions are true: * Only numbers `1` through `9` are used. * Each number is used **at most once**. Return _a list of all possible valid combinations_. The list must not contain the same combination twice, and the combinations...
null
Array,Backtracking
Medium
39
98
Hello Everyone So In This Video Before Going To Discuss A Problem Valid Binary Search Tree So Let's See What The Problems And Use This Problem Governor Taaseer Wali Channel Don't Forget To Subscribe And Subscribe Button And Notes Person Do This Superhit Number Liquid 1 Six Speed Look Select It's Really Musalla Factory ...
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,920
hi guys welcome to algorithms Made Easy my name is kushboo and in this video we are going to see the question build array from permutation so this is an easy tag question but we are going to solve it with the follower so stay tuned and watch the video till the end now let's go through the question once given a zero bas...
Build Array from Permutation
determine-color-of-a-chessboard-square
Given a **zero-based permutation** `nums` (**0-indexed**), build an array `ans` of the **same length** where `ans[i] = nums[nums[i]]` for each `0 <= i < nums.length` and return it. A **zero-based permutation** `nums` is an array of **distinct** integers from `0` to `nums.length - 1` (**inclusive**). **Example 1:** *...
Convert the coordinates to (x, y) - that is, "a1" is (1, 1), "d7" is (4, 7). Try add the numbers together and look for a pattern.
Math,String
Easy
null
963
hey what's up guys chung here again so today let's continue uh on this minimum array rectangle problem number two here so i believe a few days back i we discussed about the minimum array rectangle number one so now this time let's take a look uh number two and if you guys still remember in the number one everything els...
Minimum Area Rectangle II
three-equal-parts
You are given an array of points in the **X-Y** plane `points` where `points[i] = [xi, yi]`. Return _the minimum area of any rectangle formed from these points, with sides **not necessarily parallel** to the X and Y axes_. If there is not any such rectangle, return `0`. Answers within `10-5` of the actual answer will...
null
Array,Math
Hard
null
67
okay let's up to this problem this 67 add binary we've been given two binary numbers in their string confirm that we should return their summation and also in binary string format so the input of both knowing every and contains only characters of one is zero so we don't need to verify that these strings are actually yo...
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
187
welcome to this video now we're going to solve a liquid problem 187 repeated dna sequences and this is a medium level of problem all dna is composed of a series of nucleotides abbreviated as ac z and t for example this string when starting dna it is sometimes useful to identify repeated sequences within the dna write a...
Repeated DNA Sequences
repeated-dna-sequences
The **DNA sequence** is composed of a series of nucleotides abbreviated as `'A'`, `'C'`, `'G'`, and `'T'`. * For example, `"ACGAATTCCG "` is a **DNA sequence**. When studying **DNA**, it is useful to identify repeated sequences within the DNA. Given a string `s` that represents a **DNA sequence**, return all the *...
null
Hash Table,String,Bit Manipulation,Sliding Window,Rolling Hash,Hash Function
Medium
null
1,004
Hello Vipin Pandey Challenge And With Just One Day Away From Getting The Dawn Electronic Solve Veer Subscribe And Do Question Self Explanatory Notes PDF To Word This Word For Example Which Nothing But Do Not Wash subscribe and subscribe the Channel subscribe that without maths diet slide presentation at after creative ...
Max Consecutive Ones III
least-operators-to-express-number
Given a binary array `nums` and an integer `k`, return _the maximum number of consecutive_ `1`_'s in the array if you can flip at most_ `k` `0`'s. **Example 1:** **Input:** nums = \[1,1,1,0,0,0,1,1,1,1,0\], k = 2 **Output:** 6 **Explanation:** \[1,1,1,0,0,**1**,1,1,1,1,**1**\] Bolded numbers were flipped from 0 to 1....
null
Math,Dynamic Programming
Hard
null
1,881
hey everybody this is larry this is me going over q2 of the weekly contest 243 maximum value after insertion which is actually now that i read that out loud it sounds a little uh sounds like an innuendo but anyway hit the like button there's a subscribe button join me on discord and you know let's chat about this probl...
Maximum Value after Insertion
closest-subsequence-sum
You are given a very large integer `n`, represented as a string,​​​​​​ and an integer digit `x`. The digits in `n` and the digit `x` are in the **inclusive** range `[1, 9]`, and `n` may represent a **negative** number. You want to **maximize** `n`**'s numerical value** by inserting `x` anywhere in the decimal represen...
The naive solution is to check all possible subsequences. This works in O(2^n). Divide the array into two parts of nearly is equal size. Consider all subsets of one part and make a list of all possible subset sums and sort this list. Consider all subsets of the other part, and for each one, let its sum = x, do binary s...
Array,Two Pointers,Dynamic Programming,Bit Manipulation,Bitmask
Hard
2108,2162
299
hi i am ayushi rawat and welcome to my channel today we will discuss the september lead code challenge day 10 problem bulls and cows now let's have a look at the problem statement you are playing the following bulls and cows game with your friend you write down a number and ask your friend to guess what's the number ea...
Bulls and Cows
bulls-and-cows
You are playing the **[Bulls and Cows](https://en.wikipedia.org/wiki/Bulls_and_Cows)** game with your friend. You write down a secret number and ask your friend to guess what the number is. When your friend makes a guess, you provide a hint with the following info: * The number of "bulls ", which are digits in the ...
null
Hash Table,String,Counting
Medium
null
1,523
hi everyone my name is steve today we're going to go through a very simple question it's actually very easy but just there is some logic that you need to sort it out to solve this problem but that's it let's take a look so problem 1523 count all numbers in that interval range so given two non-active integers low and so...
Count Odd Numbers in an Interval Range
capital-gainloss
Given two non-negative integers `low` and `high`. Return the _count of odd numbers between_ `low` _and_ `high` _(inclusive)_. **Example 1:** **Input:** low = 3, high = 7 **Output:** 3 **Explanation:** The odd numbers between 3 and 7 are \[3,5,7\]. **Example 2:** **Input:** low = 8, high = 10 **Output:** 1 **Explana...
null
Database
Medium
null
879
Hello everyone welcome to my channel, its video number is going to be 25 and liquid number is 879 and surprisingly this question is quite easy but its statement is a bit long and the question bill is incidentally say Dr. Tu zero one measure set I tell the question is very It is good, so we will read the description car...
Profitable Schemes
maximize-distance-to-closest-person
There is a group of `n` members, and a list of various crimes they could commit. The `ith` crime generates a `profit[i]` and requires `group[i]` members to participate in it. If a member participates in one crime, that member can't participate in another crime. Let's call a **profitable scheme** any subset of these cr...
null
Array
Medium
885
1,299
The next question is where is the nice Mentos Ripples? Ok, this question is telling you, let us take countries like this. I don’t know if you make us take countries like this. I don’t know if you make us take countries like this. I don’t know if you make a cup and let us make fresh here for what. It will erase all this...
Replace Elements with Greatest Element on Right Side
k-concatenation-maximum-sum
Given an array `arr`, replace every element in that array with the greatest element among the elements to its right, and replace the last element with `-1`. After doing so, return the array. **Example 1:** **Input:** arr = \[17,18,5,4,6,1\] **Output:** \[18,6,6,6,1,-1\] **Explanation:** - index 0 --> the greatest e...
How to solve the problem for k=1 ? Use Kadane's algorithm for k=1. What are the possible cases for the answer ? The answer is the maximum between, the answer for k=1, the sum of the whole array multiplied by k, or the maximum suffix sum plus the maximum prefix sum plus (k-2) multiplied by the whole array sum for k > 1.
Array,Dynamic Programming
Medium
null
77
okay let's talk about combinations so combinations is actually that you generate combination and you'll return all of possible combinations for the integer n and k so let's integer so integers like from 1 to n in case the then of the subset so you will definitely understand how do you do a picture in this video so you ...
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